wood burning stoves
The moose likes JSP and the fly likes JSP And Javascript - How to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP And Javascript - How to" Watch "JSP And Javascript - How to" New topic

JSP And Javascript - How to

Harish Tam
Ranch Hand

Joined: Feb 17, 2005
Posts: 71

Hello Everybody,

Though this problem is not occuring in everyday life but would like to get a solution for this or two....

Here is the issue...........

I have a Jsp page with some javascript code in it, actually this is a jsp pop-up, from a main window, what i do is get the form textarea data using javascript opener.document.fomrname.fieldname.value and set that value in a javascript var, now i have a Java scriptlet inside my jsp and want to initialize that javascript var value to a Java variable, hope this is possible.........

If yes then can anybody tell me how this is achieved or is there any other way to to the above task....

Thanks and Regards

SCJP 1.4, SCWCD 1.4
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Harish, I guess it is not possible. You can use html code with Java but, reverse is not possible. I mean you can not use Java code with html.
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Just extension of Reddy�s answer�
Scripts such as javascripts run with the help of client browser and during execution have no interaction with server side code such as jsp/servlet. Hence it is not possible..

If you interested to pass the values to the server side code, one of the way to achive is to set some hidden html tags, set this hidden tags values from the javascripts, when you submit the page to the server read this hidden tag value can be read (from request object) and assign java(jsp/servelt) variable reverse can also be done. i.,e assign the hidden variable from server side and read it from javascripts�..
[ February 27, 2006: Message edited by: Arun Boraiah ]

Sharing is learning
I agree. Here's the link: http://aspose.com/file-tools
subject: JSP And Javascript - How to
It's not a secret anymore!