Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Url/Path

 
Aleks V. Pascoal
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hellow everybody,
i was looking and found just two places where url/path is relative to webapps directory(not to root of application and to the uri), they are:
1) HttpServletResponse.sendRedirect where if you start with a / it will refer to the root of webapps
2) ServletContext.getResource(ou getResourceasStream) where / is mandatory and refer to the root of webapps.
Does anyone knows another place where / refer to webapps root, it may be in web.xml, directives, anywhere...thanks!!!
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletContext.getRequestDispatcher(String path)
from SCWCD Exam Study Kit, pg 57
There is an important difference between the getRequestDispatcher() method of ServletContext and that of ServletRequest: you can pass a relative path to the getRequestDispatcher() method of ServletRequest but not to the getRequestDispatcher() method of ServletContext. For example, request.getRequestDispatcher("../html/copyright.html") is valid, and the getRequestDispatcher() method of ServletRequest will evalute the path relative to the path of the request. For the getRequestDispatcher() method of ServletContext, the path parameter cannnot be relative and must start with /. This makes sense because ServletRequest has a current request path to evaluate the relative path while ServletContext does not.

[ July 17, 2002: Message edited by: Jessica Sant ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic