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

../ in relative path?

 
Jan Sterk
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the answers of an Enthuware question:
request.getRequestDispatcher("../html/copyright.html").include(request, response);

This is valid because getRequestDispatcher() of ServletRequest interface supports absolute as well as relative paths.


How does the ../ notation work? Does it go to the app context?
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the ../ notation work? Does it go to the app context?
Like in all filesystem paths and relative hyperlinks, ".." refers to the directory above the current resource (here "relative" means relative to the request URL). So if the URL was /A/B/servletpath, then ../html/copyright.html will refer to the URL /A/html/copyright.html. Naturally if you're already at the context root for the application, trying a ".." is going to cause some problems!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic