Hi.
I've got a problem with switching contexts, but first the basics:
The first part of the URI is the application context, eg:
http://tomcathost:8080/app/xxx/xxx
'/app' can be mapped to any real path.
I want to keep the archived data accessed by the application in a separate
location and therefore in a different context, eg '/appdata'.
Changing context can be done as follows, assuming a main index.html in the
top level directory of the archive:
ServletContext dataContext = getServletContext().getContext("/appdata");
RequestDispatcher reqDisp = dataContext.getRequestDispatcher("/index.html");
reqDisp.forward(request,response);
The output from the servlet (or jsp) to the browser is then effectively this
index.html page. The PROBLEM is the hot links in this page, which are all
relative. The browser appends these to the original context so that for
example
<a href=page01.html>page01</a>
becomes
http://tomcathost:8080/app/page01.html
This does not work because 'app' is resolved to the wrong place.
One workaround to this is to forward instead to a servlet that throws back a
short-lived html page which automatically redirects to the right place.
The page sent back would look something like:
<html>
<head>
<title>xxx</title>
<meta http-equiv="refresh" content="1;URL=/appdata/index.html">
</head>
<body>
This page should automatically forward after a brief delay.<BR><BR>
If not then click on
<a href=/appdata.html>application data home page</a> to continue.
</body>
</html>
This is messy, not least because the user has to suffer double the WWWait !!
I've got a feeling in my bones that there is another way round this.
What is it?
Alex Peterson
mailto:[EMAIL PROTECTED]
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
___________________________________________________________________________
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