wood burning stoves 2.0*
The moose likes JSP and the fly likes Please help me. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Please help me." Watch "Please help me." New topic
Author

Please help me.

Michael Zhang
Greenhorn

Joined: Dec 03, 2002
Posts: 17
Hi, all.
I want to use JavaScript's variable in JSP block. I know JavaScript is Client-Side script and JSP is Server-Side script, so, following code is impossible, but I hope it's another way to achieve my aim. Please help me.
SCRIPT language=JavaScript>
function loadSubMenu(Value){
<% Vector term1 = teacher.getTerm(Value); //I want to use JavaScript's variable "Value"
%>
}
</SCRIPT>
xia zhi
Greenhorn

Joined: Mar 27, 2003
Posts: 2
no way......
it's impossible.
Peter Daly
Greenhorn

Joined: Jan 04, 2002
Posts: 17
Here is the flow of things:
JSP Run -> client receives page -> JavaScript Runs
JavaScript can never talk directly to JSP, since in a Page's life, JSP is "done" by the time JavaScript starts executing.
What you want to do may be possible, but not the way you are thinking about doing it. You could load the page again (controlled by JavaScript) passing the value of the JavaScript variable as a parameter on the request. For example "mypage.jsp?field=value".
We might be able to provide more help if we knew more (from and end user perspective) what you were trying to accomplish.
-Pete
[ March 27, 2003: Message edited by: Peter Daly ]
Michael Zhang
Greenhorn

Joined: Dec 03, 2002
Posts: 17
Thanks a lot.
Arron Zhang
Greenhorn

Joined: Dec 27, 2002
Posts: 15
try this,
<form name="form1" action="">
<input type="hidden" name="a" value="">
</input>
<script language="javascript">
//set value of "a"
//set action of "form1"
form1.submit()
</script>


novelist & programmer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help me.