本文整理汇总了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);
}
}