Hello all,
Please go through this code to understand the problem
public class testServlet extends HttpServlet{
private String UserName=null;
public void init()....{
...}
public void doPost(..)..{
{
PrintWriter out=res.getWriter();
out.println("First:"+UserName);
..
..
UserName="somevalue";
out.println("Second:"+UserName);
}
}
When I run this Servlet ,output->First: null Second:somevalue
Run this Servlet in another browser(second time), I got the output as ,
First:somevalue Second:somevalue.
How the old value is retained.Each time the servlet is called,it is
initiated and so the First value should be null.
Kindly let me know the reason for this behaviour.
This I avoided by declaring the UserName inside the doPost method.
Thanks,
Rajesh
___________________________________________________________________________
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