aspose file tools*
The moose likes Servlets and the fly likes hidden field retrieval Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "hidden field retrieval" Watch "hidden field retrieval" New topic
Author

hidden field retrieval

AbhisheK Aggarwal
Greenhorn

Joined: Jul 06, 2008
Posts: 4
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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
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).


Ping & DNS - my free Android networking tools app
AbhisheK Aggarwal
Greenhorn

Joined: Jul 06, 2008
Posts: 4
i was submitting the form before setting the variable...thanks for your prompt reply
Mike Anna
Ranch Hand

Joined: Jul 08, 2007
Posts: 117


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
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
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.
 
jQuery in Action, 2nd edition
 
subject: hidden field retrieval