• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic