Are you returning "false" from the onSubmit event after showing the
alert? Typically an onSubmit JavaScript event would look something like
the following, but you have to return "false" from the validate_form
method to prevent the submit.

<form name="form"
    method="post"
    action="/servlet/myapp.jsp"
    onSubmit="return validate_form()">

Paul Copeland, JOT Object Technologies, http://www.jotobjects.com

>
> ------------------------------
>
> Date:    Sat, 6 Jul 2002 14:04:45 -0500
> From:    John Vanderbrook <[EMAIL PROTECTED]>
> Subject: Re: HTML Form submit action and JSP interaction...
>
> This is a common problem. Search for how to handle sensetive form submission in JSP. 
>Struts has functionality to do that.
> John
> ----- Original Message -----
> From: "Rajkumar, Haripriya (Haripriya)" <[EMAIL PROTECTED]>
> Date:         Wed, 26 Jun 2002 12:36:04 -0400
> To: [EMAIL PROTECTED]
> Subject:      HTML Form submit action and JSP interaction...
>
> > Hi,
> >
> > I am writing a simple login validation pgm. I have a HTML file which has the
> >
> > login form and it action points to a JSP page that needs to be displayed
> > ONLY AFTER the
> > user has been successfully validated.
> >
> > Also, I have a JavaScript file that holds function to check for empty fields
> > in the form and
> > sends an alert.
> >
> > Basically
> >
> > 1. If empty fields are present the JavaScript, alert needs to be called and
> > the HTML form page
> > should still be visible.
> >
> > 2. If userId and password are entered but are not valid, then the JSP page
> > that prints out the
> > error message has to be displayed.
> >
> >
> > Here is what happens. When the HTML form is called in the browser, and
> > userid or password is not entered
> > then the alert is displayed properly. After entering the userid and
> > password, it goes to the JSP
> > page properly.
> >
> > BUT when, I use the browser's BACK button, and go to the HTML form page, and
> > if the password field is not
> > present and try to hit submit button, The Alert message is displayed AS WELL
> > AS the JSP page too, seems
> > like the SUBMIT action is getting called. How do I fix this, so that even if
> > teh user, hits the
> > BACK button and tries to login giving empty fields, ONLY the alert has to be
> > displayed.
> >
> > Any pointers???
> > Thanks
> > PHR

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to