Hello all,
Please look into the code
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class sessiontest extends HttpServlet
{
public void doPost(HttpServletRequest req,
HttpServletResponse res) throws ServletException, IOException
{
HttpSession session = req.getSession(true);
PrintWriter out = res.getWriter();
res.setContentType("text/html");
Integer count = (Integer)session.getValue("sessionid");
out.println("The session is " + count);
if (count == null)
{
out.println("Ur new to this session<BR>");
count = new Integer(1);
}
else
{
out.println("ur old to this session<BR>");
count = new Integer(count.intValue() + 1);
session.putValue("sessionid", count);
}
}
}
This is from Jason Hunters book. Ch:7 Session tracking. What i assume is
that if we open a new browser window from a client the value will be null
for the first window and it will display the ur new to this session. But
when we open another browser window importantly fromthe same client it
should say "ur old to this session" right?? Please correct me if i have
understood it wrongly and help me to clarify my doubts. Strantegly it is
saying new session for each and every new window i open for the same
client i dont know where i am going wrong please help me to solve this
error. But whereas this works perfectly for cookies.
Thanks in advance for ur help,
Srini
#-----------------------------------------------------------------------#
# #
# "ARISE AWAKE and stop not till the GOAL is reached" #
# #
# [EMAIL PROTECTED] #
#-----------------------------------------------------------------------#
___________________________________________________________________________
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