aspose file tools*
The moose likes JSP and the fly likes JS ---> JSP variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JS ---> JSP variables" Watch "JS ---> JSP variables" New topic
Author

JS ---> JSP variables

Roberto Diaz
Ranch Hand

Joined: Mar 08, 2002
Posts: 40
How do I assign a Java Script variable to a JSP variable.
Both the variables are of string type.
TIA for all responses.
arul murug
Greenhorn

Joined: Aug 08, 2002
Posts: 24
I don't think there is direct way to assign the variable as java script executes at client side and jsp code(as a servlet) at server side.
However u can assign the java script variable to a hidden form field and pass to server where the jsp can get it using request.getParameter().


SCJP2<br />SCWCD<br />UML & OOAD - IBM 486
avina metha
Greenhorn

Joined: May 10, 2003
Posts: 3
try this way
<% String string1=request.getParameter("Name");
simillar for others..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

I'm not sure what avina is getting at, but getParameter() will not allow you to access JavaScript variables.
arul on the other hand is quite correct. Think about it for a moment.
The JSP executes on the server in order to format the HTML page which is then sent to the browser wherre it (along with any JavaScript contained within) is interpreted by the browser.
They live in completely separate worlds.
Now, as arul pointed out, the value of the JS variable can be made available to the next JSP page by submitting it as a request parameter.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JS ---> JSP variables