I'm not sure if this is efficient or even a reasonable thing to do, but
could you could put the subsession id in the path itself and set up a
servlet to translate the path. There are probably some subtle nuances that
you may have to deal with, but here is the general idea:
Set up a servlet that extracts a subsession Id from the incoming path and
then does a forward to the rest of the path after the subsession. I set up a
test where I mapped this path translation servlet to "/pathtrans/" and then
put all my application files in "/appsubdir/".
Here is the servlet:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class PathServlet extends HttpServlet
{
public void service(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
String extraInfo = request.getPathInfo();
// Locate the next slash in the path (assume there is one at position 0)
int slashPos = extraInfo.indexOf('/', 1);
if (slashPos > 0)
{
// Get the subsession id and the real path to access
String virtSession = extraInfo.substring(1, slashPos);
String fullPath = extraInfo.substring(slashPos);
// Store the subsession where a JSP can get it
request.setAttribute("subsessionId", virtSession);
// Assume the real path is under /appsubdir
getServletContext().getRequestDispatcher("/appsubdir"+fullPath).
forward(request, response);
}
}
}
When I ask for "/localhost/pathtrans/abc123/hellotest.jsp, I end up running
/appsubdir/hellotest.jsp with the subsession id of "abc123" stored in the
request.
If I happen to navigate through a few html files before I get to
hellotest.,jsp, everything still works and I didn't have to rewrite URLs in
the html files.
Here is hellotest.jsp:
<html>
<body>
Your sub-session id is <%= request.getAttribute("subsessionId") %>
</body>
</html>
I tested this under JRun and I had to map "/appsubdir/" to "file" so I was
able to forward to html files as well as JSP, other than that, it was pretty
easy to set this up.
When you first get to a situation where the user needs a subsession,
generate some random key and redirect the user to /pathtrans/<random
key>/whatever. You can stick a hash table in the session indexed by the
random key. Put your subsession variables in the hash table.
Mark
> >
> >In your case, you apparently want multiple sessions in the same browser
> >instance -- much trickier.
>
> That's it ;-) In fact, that it is exactly what happens when you browse
with
> multiple windows on x sites, which have different urls. The problem is
also
> much trickier I first thought, because it does work with cookies, as long
as
> the urls are different. But I may not be able to split this site in as
many
> different adresses than I need (potentially a whole ballpark). Part that
may
> not be separated will be in subdomain, and in this case, I may not be able
> to use cookies. Hence, url rewriting
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets