• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP And Javascript - How to

 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Harish
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic