Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I get the real path to a servlet using ServletContext.getRealPath when the servlet is mapped

807567Jul 25 2002 — edited Nov 18 2002
I am running into problems when tyring to retrieve the 'real path' of a servlet running on iPlanet WebServer 4.0 sp6. The iPlanet servlet container always returns a <i>null</i> result.

The servlet returning the <i>null</i> resides in a war file as part of a J2EE application deployed to the iAS 6.0 env. iPlanet unpackages ear and war files so this shouldn't be a problem of there truly not being a 'real path'.

The servlet being accessed is a mapped servlet with the mapping information contained within the web.xml file. I came across an article stating that iPlanet does not support ServletContext.getRealPath when a servlet is 'mapped'. As an alternative they suggest using ServletRequest.getRealPath (which is deprecated in Servlet API 2.3 BTW). So according to iPlanet using the code below I should be able to get the 'real path' of a servlet running on an iPlanet webserver (I am also checking to see if the file exists in a packaged war) but I STILL get a <i>null</i>.

Does anyone out there have any suggestions? Users? iPlanet/SUN?


Code:

ServletContext servletContext = getServletConfig().getServletContext();

String pathInfo = req.getPathInfo();
String realpath = servletContext.getRealPath(req.getServletPath());

if (realpath == null) {
realpath = req.getRealPath(req.getServletPath());

if (realpath == null) {
URL pathURL = servletContext.getResource(req.getServletPath());
realpath = pathURL.getFile();
}
}


My enviornment:

OS: Solaris
iWS: 4.0 sp6
iAS: 6.0 sp4


references:
Servlet 2.3 API regarding ServletRequest.getRealPath:
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletRequest.html#getRealPath(java.lang.String)

iPlanet clarification document:
http://docs.iplanet.com/docs/manuals/enterprise/41/servlets/g-apifix.htm#23105

-thanks
-matt
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2002
Added on Jul 25 2002
1 comment
826 views