Thanks. Your idea works but your code took me to better
solution. I was looking in ServletContext, ServletConfig, etc.
But looking at getURI() and getServletPath() I found
the answer in HttpServletRequest.
The method is getServletPath().
Thanks!.
-----Original Message-----
From: PUB: Kevin Baynes
public String getRootURL(String requestURI, String servletPath) {
rootURL =
requestURI.substring(0,requestURI.indexOf(servletPath));
return rootURL;
}
Calling Request.getURI() from a servlet at:
http://www.mydomain.com/myapp/servlet/TestServlet returns
"/myapp/servlet/TestServlet"
Calling Request.getServletPath() from a servlet at:
http://www.mydomain.com/myapp/servlet/TestServlet returns
"/servlet/TestServlet"
Using the function above will return: "/myapp" as the root url.
Now you can use: "<img src=" + rootURL + "/pathToImage/img.gif>"
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html