• 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!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!