aspose file tools*
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
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
 
jQuery in Action, 2nd edition
 
subject: how to store a js value in a java or jsp variable