Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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 ]
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!