Forums Register Login

web applications and directory structure.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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
a wee bit from the empire
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 605 times.
Similar Threads
Servlet Mapping in WebSphere
The value for the useBean class attribute *class* is invalid.
where to put the servlets
servlet deploymnt on weblogic...u had difficulties too????
static content (css and EXT-JS JavaScript) not found 404 (SOLVED)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:41:38.