JSP (servlets) are executed on the server, while (then) Javascripts are executed on
the client.
What you can do is submitting the javascript variable in a form field to a servlet
(e.g. JSP page):
page1.html ---------------------------
<HTML>
<BODY>
> <SCRIPT LANGUAGE="JavaScript">
> function a() {
> var jscript_data = 1;
>
document.form.jscript_data.value = jscript_data;
document.form.submit();
> }
> </SCRIPT>
<FORM name=form action="page2.jsp" method="POST">
<input type=hidden name="input_jscript_data">
<input type=submit>
</FORM>
</BODY>
</HTML>
page2.jsp ---------------------------------------
<%! int id = Integer.parseInt( request.getParameter( "input_jscript_data" ) ); %>
<HTML>
<!-- use your variable here -->
</HTML>
/Ola
> -----Original Message-----
> From: Tran, Fon Francis (CAP, GECF, Japan)
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 21, 1999 8:33 AM
> To: [EMAIL PROTECTED]
> Subject: Java Script To JSP
>
>
> Dear all,
>
> Does anyone know how we can pass a JavaScript variable into JSP?
>
> For example, when I try to following simple JSP file, it
> will say that
> jscript_data is not found. Does anyone know how I can achieve this?
> Any help will be greatly appreciate it. Thanks.
>
> Francis
>
> <%! int id; %>
> <html>
> <head>
> </head>
>
> <SCRIPT LANGUAGE="JavaScript">
>
> function a() {
> var jscript_data = 1;
>
> <% id = jscript_data; %>
> }
>
> </SCRIPT>
> <BODY>
> </BODY>
> </HTML>
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html