Hi,

I seem to be confused about how web-apps and their context play into
relative and aboslute paths on JSP pages and servlets.

I have two applications deployed. One uses 3 web-apps, the other is just
one. In the one with 3 web-apps, they all 3 share the common www dir, (the
only difference is a variable that indicates what "media" they belong in..so
as to get the right database connection). I have them as 3 separate web-apps
to keep the 3 from being able to share memory..so each web-app has its own
memory space in Orion. When I access any images in the /www/images folder
(where /www is from the root of the application), I have to use <img
src="./images/imagename.gif">. But in my single app, I only use
/images/imagename.gif..no . before the first / . I also set a variable on
every page called contextPath that is like:

<%
  String contextPath = request.getServletPath().substring(0,
request.getServletPath().lastIndexOf("/"));
%>

I can't use getContextPath() because our site runs in production on JRun
2.3.2 right now (please..no flame mail ;), which only supports Servlet
2.1/JSP 1.0. The getContext() method doesn't exist in Servlet 2.1. That is
why I get a substring of the requestURI.

At any rate..what is the true facts on relative and absolute paths? I
thought in any web-app, I can use / and that gets me to the root of the app.
So, using /images should always get me to the root of the web-app, not the
root of the application itself. It appears when running 3 web-apps all
pointing to the same one www dir, the root is the / BEFORE the www, not the
www itself. That is why I use ./images.

Thanks for any explanation on this.

Reply via email to