Well you can always put a "default value" to your "hidden" field so that you
need not do a try catch,,, or use the getparameter meathod,
        <input type=hidden name="input_jscript_data" value="_MY_DEFAULT">

but if the javascript fails this "might" give a null pointer exception, just
for precaution. also it can act as a pointer to denote the JS facility of
the browser is
1. turned off
2. not available

then you have to do quite a bit which i assume you are doing with your
script.

I T H

Amit

> -----Original Message-----
> From: Ola Sandstr�m (QDT) [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, December 21, 1999 1:17 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Java Script  To JSP
>
> 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

===========================================================================
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

Reply via email to