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 JSP and the fly likes how to store a js value in a java or jsp variable 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 » JSP
Bookmark "how to store a js value in a java or jsp variable" Watch "how to store a js value in a java or jsp variable" New topic
Author

how to store a js value in a java or jsp variable

hashmukh punamia
Greenhorn

Joined: Aug 14, 2007
Posts: 22
HI Ranchers,

I have an javascript function in a jsp file

function encodeTxt(s){
............
.........

}

I want to assign the return value of this function to a java variable.
How is it possible.

I have one method but dont know how efficient it would be,
I try assigning return value of a js function to a form object say textbox and then use request.getParameter to retrieve the value in java.

Thanks & Regards,
Hashmukh
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

That is the correct way to do it.

Remember, Javascript and HTML are both interpreted on the client's machine after all of the JSP code has already been run on the server.
The two do not ever directly interact.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to store a js value in a java or jsp variable
 
Similar Threads
Java embedded in .JS file not working
interpret java code <% ..%> in .js file
assign return value of function from javascript to variable in jsp
missing name after . operator ?
Passing a value from Javascript to JSP