Hello Srinivasan,
You need to add this line in your if(count == null) clause
..
..
session.putValue("sessionid", count);
..
..
..
You have this line only in else part.
It works for me. It remembers the session when I use it from another
window.
"Srinivasan S (Systems Engineering Group)" wrote:
>
> 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);
> }
> }
> }
>
--
Kishor Patel
i |money Inc.
"FIND A WAY OR MAKE A WAY"
Voice: 416-368-3920 Ext 5012
Fax: 416-368-5505
Email: [EMAIL PROTECTED]
Website: www.imoney.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