Posted By:
A_E
Posted On:
Friday, September 20, 2002 11:37 PM
Say I don't want to use cookies or URL rewriting or some other part of the extra baggage that Sun wrapped up in HttpSessions, but I want to make use the existing objects without having to roll up my own objects. I want to do something like this: public class MyServlet extends HttpServlet { public void init() throws ServletException { //... SessionHandler[] sessionpool = SessionHandler.createSessionPool(NUM_SESSIONS); servletcontext.setAttribute("sessionpool", sessionpool); } public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { SessionHandler currentSession
More>>
Say I don't want to use cookies or URL rewriting or some other part of the extra baggage that Sun wrapped up in HttpSessions, but I want to make use the existing objects without having to roll up my own objects. I want to do something like this:
public class MyServlet extends HttpServlet
{
public void init()
throws ServletException
{
//...
SessionHandler[] sessionpool = SessionHandler.createSessionPool(NUM_SESSIONS);
servletcontext.setAttribute("sessionpool", sessionpool);
}
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
SessionHandler currentSession = SessionHandler.getSession();
String id = getSessionIDMyWay(request);
currentSession.setID(id);
//...
}
}
Is there anything that does what I want? I would like to be able to create() and setID() for sessions, as well as manage persistence on my own.
Before you ask "why?" and explain to me why I really do want to do it the way that sessions have been implemented, realize that the best answer I can come up with is "because." Of course I'm also eager to learn "why" my practice is stupid, and why I really do want to handle sessions the way Sun taught me to, as long as the answer isn't simply "because."
<<Less