Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Servlet cannot determine install directory on WebSphere 4

Status
Not open for further replies.

RobertCMyers

Programmer
Jul 10, 2002
3
US
We have a Servlet and a set of image files that we're installing as an EAR on WebSphere 4. Whenever one of the image files is added to an HTML page, it works just fine. WebSphere finds the correct file in the installed images directory under the EAR directory.

The problem is that the Servlet occasionally needs to check to see if one of the images is present BEFORE rendering the page. But the Servlet cannot figure out where the installed EAR directory is located. We've looked at the user.dir property, and it's ".../Application Server/bin/" or something similar. (When we manually copy the EAR's "images" subdirectory to the bin directory, everything works fine, but that's not a long-term solution. The IT department will hate us if installation includes a step: "Now, copy this directory to your WebSphere bin directory...")

We've dumped ALL System properties, and there's nothing pointing us to OUR EAR directory. Is there any way for the Servlet to ask "Where am I installed?"

Thanks!

Rob
 
Robert,

Try this

ServletContext servletContext = getServletContext();
String sRealPath = servletContext.getRealPath( "/" );

This will give you the root of your web context now
just place any files you need in your ear and the path
to them is relative to the root of your web context.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top