`

ServletRequest.getRequestDispatcher() and ServletContext.getRequestDispatcher()

    博客分类:
  • web
阅读更多

The difference between ServletRequest.getRequestDispatcher(String path) and ServletContext.getRequestDispatcher(String path) is that the former can accept a relative path as well whereas the latter can accept paths relative to the current context root only.

If the path starts with a ‘/’ in the getRequestDispatcher(String path) of the ServletRequest interface then it’s interpreted as being relative to the current context root otherwise it’ll be a relative to the request of the calling servlet. Whereas, the path of the getRequestDispatcher(String path) of the ServletContext interface must start with ‘/’ only – being relative to the current context root.

Another difference between the two is that path of the getRequestDispatche(String path) of the ServletRequest interface cannot extend outside the current servlet context whereas getRequestDispatcher(String path) of the ServletContext can use the getContext(String uripath) method to obtain RequestDispatcher for resources in foreign contexts.

分享到:
评论

相关推荐

    javaWEB总结(6):ServletRequest

    javaWEB总结(6):ServletRequest测试代码

    servlet-api-2.4.jar.zip

    javax.servlet.ServletContext javax.servlet.ServletRequest javax.servlet.http.HttpUtils javax.servlet.ServletResponse javax.servlet.ServletException javax.servlet.http.HttpServlet javax.servlet....

    servlet2.4doc

    Adds a response header with the given name and date-value. addHeader(String, String) - Method in class javax.servlet.http.HttpServletResponseWrapper The default behavior of this method is to return ...

    javax.servlet.jar下载

    javax.servlet.ServletRequest.class javax.servlet.ServletResponse.class javax.servlet.ServletConfig.class javax.servlet.ServletInputStream.class javax.servlet.ServletOutputStream.class javax.servlet....

    Filter_Listener相信代码使用

    import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain;... request.getRequestDispatcher("error.jsp").forward(request, response); 里面有更详细的代码。。。

    Java™ Servlet 规范.

    目录 前言 ............................... 3 其他资料 ......................................................................................................................................................

    Servlet3.1规范(最终版) PDF

    Servlet3.1规范(最终版) JavaTM Servlet 规范 版本 3.1(最终版) Shing Wai Chan Rajiv Mordani [作者] 穆茂强 张开涛 [译者] 2012年6月翻译 2013年7月修订 目录 前言 ..................................

    ServletRequest使用介绍.docx

    HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求中的所有信息都封装在这个对象中,开发人员通过这个对象的方法,可以获得客户这些信息;

    EL表达式的详细使用

    将请求参数名称映射到单个字符串参数值(通过调用 ServletRequest.getParameter (String name) 获得)。getParameter (String) 方法返回带有特定名称的参数。表达式 $(param.name) 相当于 request.getParameter ...

    servlet电子书籍 pdf格式

    2.5 ServletRequest ....................................................................8 request.getInputStream()方法................................................8 request.getReader()方法 ..........

    jboss中access 日志的配置

    There is also support to write information from the cookie, incoming header, outgoing response headers, the Session or something else in the ServletRequest. It is modeled after the apache syntax: %{...

    ServletRequest过滤程序

    提供了ServletRequest过滤程序,重新构造对象内容,并有效规避request.getParameter()、request.getInputStream()冲突的问题,同时提供了对跨站脚本攻击XSS和SQL注入的过滤程序。

    jspsmart.upload chm

    File An abstract representation of an uploaded file. Files A collection of uploaded ...Request The equivalent of ServletRequest Class. SmartUpload The object which perfoms the upload. date: 11 Jul 2000

    c3p0工具包(jdbc)

    * See the License for the specific language governing permissions and * limitations under the License. */ package cn.secondteam.utils; import java.io.IOException; import java.lang.reflect....

    request.setAttribute 语句前总显示红色感叹号解决办法 HTTP Status 500 -

    The method setAttribute(String, Object) in the type ServletRequest is not applicable for the arguments (String, double) y2ssh.sg.chp1.action.AddAction.execute(AddAction.java:18) y2ssh.sg.chp1....

    学习servlet的实例和参考api

    类 ServletConfig ServletOutputStream ServletContext ServletInputStream ServletResponse GenericServlet ServletRequest Servlet <br>javax.servlet.http<br>接口 类 HttpSession Cookie...

    html笔记.txt

    Request(Javax.servlet.ServletRequest)它包含了有关浏览器请求的信息.通过该对象可以获得请求中的头信息、Cookie和请求参数。 Response(Javax.servlet.ServletResponse)作为JSP页面处理结果返回给用户的响应存储在...

    JSP 9 大内置对象详解.txt

    Request(Javax.servlet.ServletRequest)它包含了有关浏览器请求的信息.通过该对象可以获得请求中的头信息、Cookie和请求参数。 Response(Javax.servlet.ServletResponse)作为JSP页面处理结果返回给用户的响应存储在...

    Java+javabean

    The method setAttribute String Object in the type ServletRequest is not applicable for the arguments String int

    javaee-ServletRequest 类相关源代码解析

    NULL 博文链接:https://sunfish.iteye.com/blog/1485374

Global site tag (gtag.js) - Google Analytics