wood burning stoves 2.0*
The moose likes Servlets and the fly likes Session get value of 0 is not displaying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session get value of 0 is not displaying " Watch "Session get value of 0 is not displaying " New topic
Author

Session get value of 0 is not displaying

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear Sir,
In the UserAuthenticationServlet.java file i am setting the
cmpValue 0.
But when i am trying to get the value in jsp why the cmpvalue display
the null instead of 0 value.
cmpValue = (String)session.getAttribute("cmpValue");
out.println("cmpValue"+cmpValue); //null instead of 0 value.

Could please rectify my code so that i will getting the 0 value.

UserAuthenticationServlet.java
int myInt=0;
session.setAttribute("cmpValue", new Integer(myInt));

x.jsp
cmpValue = (String)session.getAttribute("cmpValue");
out.println("cmpValue"+cmpValue);

Thanks and Regards
Sumanta Panda
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

How you get that session object in servlet , I'm interested to How you create the session object in Servlet .

It may be the case that , the session you are accessing on JSP page is different from one that you created on Servlet ..


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
did you do following in your servlet code?


this is because you have to create a session object for individual request.

try this.

Regards


i am Java +ve Now !
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Thanks to all of you.I changed the code accordingly to your advise.
Now its working.

I wish you very Happy new Year@2009 to all my Javaranch Support team.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session get value of 0 is not displaying
 
Similar Threads
Servlet API 2.2
Session value is not reflection properly for view the page in next time in post login
Can i print the HttpSession Value ??
Why the SnoopServlet in Tomcat 3.2.1 doesn't compile?
delete session with button