• 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

hidden field retrieval

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am setting a variable in the session using in the java script but am not able to retrieve it...

at the web page :


the alert works just fine but when i try to retrieve it at the servlet


gets a null value

i even tried

thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Nothing will be in the session unless it is explicitly put it there. So unless there's a session.put("send", ...) somewhere, it won't be in the session.

As regards the JavaScript code, is the form where you're setting the value submitted after it's set? Have you verified that the value gets transmitted to the server? If not, the Firefox extension LiveHttpHeaders is a great tool to observe what gets sent to the server, and what the server sends back (in other words, it logs HTTP requests and responses).
 
AbhisheK Aggarwal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i was submitting the form before setting the variable...thanks for your prompt reply
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



HttpSession session= req.getSession(false);String saveString = session.getattribute("send");



These lines, my friend, I hope you understand, what they are doing.
Why dont you change your first line from this

to this


and let us know what happened. I am assuming you have a hidden variable named "send"
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

These lines, my friend, I hope you understand, what they are doing.
Why dont you change your first line from this


That can't possibly be the problem, because in that case a NullPointerException would have been thrown during when calling session.getattribute("send"). But that's moot, since the problem is solved already.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic