File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session get value of 0 is not displaying

 
sumanta panda
Ranch Hand
Posts: 224
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2905
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ..
 
Amir Iqbal
Ranch Hand
Posts: 97
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you do following in your servlet code?


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

try this.

Regards
 
sumanta panda
Ranch Hand
Posts: 224
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic