Yes you can use javascript in your servlet. Here is an example. It also
answers the question that has been floating around on this list on how to
keep the submit button from being pressed more than once (disabling it after
the first submit. I use it all the time & it works great.

T. Kochanowicz

        // JavaScript To prevent user hitting Submit button too many times.
                                htmlPage.append("<SCRIPT LANGUAGE=\"JavaScript\"> <!-- 
Hide script from
old browsers\n ");
                                htmlPage.append(" var submitted = false;");
                                htmlPage.append(" function doSubmit(form)");
                                htmlPage.append(" {");
                                htmlPage.append(" if (!submitted) {");
                                htmlPage.append(" submitted = true;");
                                htmlPage.append(" form.submit();");
                                htmlPage.append(" }");
                                htmlPage.append(" }");
                                htmlPage.append("// End hiding script from old 
browsers-->\n</SCRIPT>");

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Kevin
Mukhar
Sent: Wednesday, April 18, 2001 8:22 AM
To: [EMAIL PROTECTED]
Subject: Re: Question??


Purushotham Das K wrote:
>
> 1.If my browser does not support Cookie,and my server sends a cookie
> instance What will happen ?

The browser refuses the cookie. When the browser sends the next request,
it will not send the session id. Because the client does not join the
session, the server will not be able to perform session tracking (by
returning the session id cookie, the client "joins" the session).
However, the server could still perform session tracking by using URL
rewriting or hidden form fields.

> 2. Can we use javaScript in Servlets??

No, you can't use Javascript IN a servlet. Javascript is a scirpting
language embedded into an html page and which is interpreted by a
browser. A Servlet is neither an html page nor is it executed in a
browser. However, the servlet can insert javascript into the html that
is sent to a client. Anything that can be done in static html can be
done by a servlet because the servlet output is (usually) html which is
rendered by a browser.

> 3. What are the types of protocols used in HttpServlet ?

Between client and servlet, only HTTP. But the servlet can act as a
client to other servers and use other protocols: TCP, RMI, SMTP, etc.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to