What is the exact difference between request.getRequestURI() and request.getServletPath()?

sonia wen

request.getRequestURI() contains the context path defined in your server.xml, on the other hand, request.getServletPath() does not contain this path.

For example, in your server.xml, you define:

<Context path="/mywebapp" docBase="D:workmywebapp" debug="0" reloadable="true" /> ;

under the directory d:workmywebapp, you have sub directory WEB-INF and jsps, under the directory d:workmywebappjsps, you save your jsp file, say mytest.jsp. So when you use request.getRequestURI(), the result will be: /mywebapp/jsps/mytest.jsp, the other result using request.getServletPath() will be /jsps/mytest.jsp.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact