本文整理匯總了Java中javax.servlet.GenericServlet.service方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericServlet.service方法的具體用法?Java GenericServlet.service怎麽用?Java GenericServlet.service使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.GenericServlet
的用法示例。
在下文中一共展示了GenericServlet.service方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleJSP
import javax.servlet.GenericServlet; //導入方法依賴的package包/類
/**
* Handles a request for a JSP page. It checks to see if a servlet is mapped
* for the JSP URL. If one is found, request handling is passed to it. If no
* servlet is found, a 404 error is returned.
*
* @param pathInfo the extra path info.
* @param request the request object.
* @param response the response object.
* @throws ServletException if a servlet exception occurs while handling the request.
* @throws IOException if an IOException occurs while handling the request.
*/
private void handleJSP(String pathInfo, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// Strip the starting "/" from the path to find the JSP URL.
String jspURL = pathInfo.substring(1);
GenericServlet servlet = servlets.get(jspURL);
if (servlet != null) {
servlet.service(request, response);
}
else {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
}
示例2: handleServlet
import javax.servlet.GenericServlet; //導入方法依賴的package包/類
/**
* Handles a request for a Servlet. If one is found, request handling is passed to it.
* If no servlet is found, a 404 error is returned.
*
* @param pathInfo the extra path info.
* @param request the request object.
* @param response the response object.
* @throws ServletException if a servlet exception occurs while handling the request.
* @throws IOException if an IOException occurs while handling the request.
*/
private void handleServlet(String pathInfo, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// Strip the starting "/" from the path to find the JSP URL.
GenericServlet servlet = getServlet(pathInfo);
if (servlet != null) {
servlet.service(request, response);
}
else {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
}