• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session get value of 0 is not displaying

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ..
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bring out your dead! Or a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic