I'm having problems invalidating and reallocating sessions in Jserv (1.0b4).
below is the test servlet (which will invalidate the session after 5 hits
and allocate
a new one). it appears that calling request.getSession(true) after
session.invalidate()
will not allocate a new session. the code getSession() code in
JservConnection
make this behavior fairly obvious:
public HttpSession getSession( boolean create ) {
// FIXME: What happen if someone calls invalidate on a new session
// and calls this method again ? Should we create another one, or
// return the invalid one ?
if (session != null) {
return session;
}
...
should the if () test be:
if ((session != null) && session.isValid()) {
return session;
}
I checked the source in 1.0b5 and it is unchange (in this part of the method
at least).
package vv.page;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessTest extends HttpServlet
{
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
String title = "Session invalidation Servlet";
response.setContentType("text/html");
HttpSession session = request.getSession(true);
Integer hits = (Integer) session.getValue("hits");
if (hits == null) {
hits = new Integer(0);
}
if (hits.intValue() > 5) {
session.invalidate();
session = request.getSession(true);
hits = new Integer(0);
}
hits = new Integer( hits.intValue() + 1 );
// then write the data of the response
PrintWriter out = response.getWriter();
out.println("<HTML><HEAD><TITLE>>");
out.println(title);
out.println("</TITLE></HEAD><BODY>");
out.println("alive <br>");
out.println("session: " + session.getId());
out.println("number of accesses: " + hits + "\n");
out.println("</BODY></HTML>");
out.close();
session.putValue("hits", hits);
}
}
cheers.
Paul Gibson [EMAIL PROTECTED]
Virtual Vineyards http://www.virtualvin.com
3803 East Bayshore Rd. 650 919 1975 x310
Suite 175 650 919 1977 fax
Palo Alto, CA 94303
-- --------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
READ THE FAQ!!!! <http://java.apache.org/faq/>
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]