This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes how can i put java script value into jsp variable?  Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "how can i put java script value into jsp variable?  " Watch "how can i put java script value into jsp variable?  " New topic
Author

how can i put java script value into jsp variable?

eric lee
Ranch Hand

Joined: Nov 04, 2002
Posts: 86
dear sir:
i know how to put jsp value into java script variable
but how to put java script vaule into jsp variable? thanks;

<%
String s="hello",b="";
%>
<script language="javascript">
var name="<%=s%>";
<%b%>=name;<=== is this correct?
</script>
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1697
YOu can put JSP value into JavaScript variable, but reverse is not possible.
Your code dont work.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

The JSP variables exist when the JSP is being processed on the server. At that point the Javascript variables are just markup. Later, when the output of the JSP is processed on the client, the Javascript variables exist but the JSP variables are long gone.

So you can't do that. I would attempt to answer the real question behind your question but I can't tell what it is.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56191
    
  13

Please read this article for information on the life-cycle of a JSP and why what you are asking is not possible.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how can i put java script value into jsp variable?
 
Similar Threads
javascript passing value to JSP
Problem with script tag
setting and retrieving cookies using javascript on a jsp
setting value for hidden tag
Jsp & JavaScript