This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes JavaScript varialble in a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JavaScript varialble in a Servlet" Watch "JavaScript varialble in a Servlet" New topic
Author

JavaScript varialble in a Servlet

Madhav T Murthy
Greenhorn

Joined: Aug 28, 2001
Posts: 2
I am developing an JSP application where, i would like to use a JavaScript variable in the Java servlet Code. Please tell me how do i do it?
Thomas Goorden
Ranch Hand

Joined: Aug 15, 2001
Posts: 39
Well, the way I understand it, you can't do this directly:
the javascript is executed in the client's browser, *after* your jsp page has already done it's thing.
Therefor, the JSP page needs to be executed again.
The way I'd do it is to let let the javascript address the same page with your needed value as a GET or POST parameter.
Hope this solves it.
Madhav T Murthy
Greenhorn

Joined: Aug 28, 2001
Posts: 2
Thank you for answering my query Mr Thomas.
But could please clear my doubt with an example ??
I just got the idea what should be done..but please give an example.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript varialble in a Servlet
 
Similar Threads
How i write in a servlet response an javascript array?
Calling a Java function from a href tag
Please Help! How to create Modal Dialog Box in Servlet.
Servlet Called From Javascript
String Arraylist from Java to Javascript