• Post Reply Bookmark Topic Watch Topic
  • New Topic

web applications and directory structure.  RSS feed

 
Bala Krishna
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a web application 'testwebapp', with it's document root as /home/user/web. Now, when I try serving a JSP thru the URL http://hostname/testwebapp/pathtojsp.jsp, it works perfectly well. However, I take a look at how the App.Server resolves this request, and I do not understand something.
When I do a application.getRealPath("/"), it gives me the root directory of my web app('/home/user/web'), as it should. When I do 'application.getRealPath("/testwebapp"), what should it show? Shouldn't it show the root directory of the application again? My understanding is that the appserver uses the contextpath(here, hostname/testwebapp), to forward the request to this specific web.app, and hence, application.getRealPath("/testwebapp") should read /home/user/web which is the document root for this web application. Instead, it reads /home/user/web/testwebapp. Is this correct? Is this in accordance with the web application specifications mentioned in Servlet 2.2 specifications? Before I forget, I've tested this across WebSphere, Tomcat and Resin and the behaviour seems to be the same every where. Any insight into this would be greatly appreciated. Thanks.
-Bala.
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bala Krishna:
Hi,
I have a web application 'testwebapp', with it's document root as /home/user/web. Now, when I try serving a JSP thru the URL http://hostname/testwebapp/pathtojsp.jsp, it works perfectly well. However, I take a look at how the App.Server resolves this request, and I do not understand something.
When I do a application.getRealPath("/"), it gives me the root directory of my web app('/home/user/web'), as it should. When I do 'application.getRealPath("/testwebapp"), what should it show? Shouldn't it show the root directory of the application again? My understanding is that the appserver uses the contextpath(here, hostname/testwebapp), to forward the request to this specific web.app, and hence, application.getRealPath("/testwebapp") should read /home/user/web which is the document root for this web application. Instead, it reads /home/user/web/testwebapp. Is this correct? Is this in accordance with the web application specifications mentioned in Servlet 2.2 specifications? Before I forget, I've tested this across WebSphere, Tomcat and Resin and the behaviour seems to be the same every where. Any insight into this would be greatly appreciated. Thanks.
-Bala.

What you see is correct. It shows you the REAL path for
that directory, not the ROOT path for the application.
When you ask for the real path of \, you get the application
root. When you ask for the real path of something below the
root, you get it.
HTH,
Joe
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!