Oliver, instead of:

     if( Password1 != Password2 )

don't you want:

     if ( ! Password1.equals (Password2))

Jim

Oliver Kaljuvee wrote:

> Hi Everybody,
>
> I am testing out a simple form that takes four values.  The starting
> page is called test.jsp, which has an action to process.jsp (the code
> below). The insertion to the database works fine, however, the code
> has a flaw when checking for the passwords; it always considers the
> passwords being different; in other words it keeps going in a loop.
> For instance, when on test.jsp I fill in the values; it will go to
> process.jsp and always executes the code after the if-statement
> regardless whether the passwords were identical or not.  Can anyone
> see right off the back what the problem might be?
>
> Thank you in advance.
>
> -- Oliver
>
>
> <HTML>
> <HEAD>
>       <TITLE>TestResults</TITLE>
> </HEAD>
>
> <BEAN NAME="jspDb"
> TYPE="com.livesoftware.jrun.plugins.jsp.beans.JSPDBConnection"
> SCOPE="session">
> </BEAN>
>
> <!--#include file="dbsettings.jsp"-->
>
> <%
>
>  // declare variables
>  String FirstName = "";
>  String LastName = "";
>  String Password1 = "";
>  String Password2 = "";
>
>  String sql = "";
>
>  // set up the database connection
>
>  jspDb.setDriver(JDBC_DRIVER);
>  jspDb.setUrl(JDBC_URL);
>  jspDb.setPoolSize(JDBC_POOLSIZE);
>  jspDb.setUser(JDBC_USR);
>  jspDb.setPass(JDBC_PWD);
>  jspDb.open(JDBC_DBNAME);
>
>  // get the values from the form
>  FirstName = ((String) Request.Form("FirstName"));
>  LastName = ((String) Request.Form("LastName"));
>  Password1 = ((String) Request.Form("Password1"));
>  Password2 = ((String) Request.Form("Password2"));
>
>  if( Password1 != Password2 )
>  {
>
> // this the html from the starting page (test.jsp):
> %>
>
>  <html>
>  <body>
>  </head>
>  <body>
>  <form NAME="register" METHOD="POST" ACTION="process.jsp">
>  <h1>The passwords have to be identical!</h1><br><br>
>  FNM: <input type="text" name="FirstName" size=20>*<br>
>  LNM: <input type="text" name="LastName" size=20>*<br>
>  PWD: <input type="password" name="Password1" size=20><br>
>  PWD: <input type="password" name="Password2" size=20><br><br>
>  * Required Fields<br><br>
>  <input type="submit" name="submit" value="Submit">
>  </form>
>  </body>
>  </html>
>
> <% }
>  else
>  {
>   sql = "INSERT INTO test (UserID, FirstName, LastName, Password1,
> Password2) values " +
>   "(DEFAULT, '" + FirstName + "', '" + LastName + "', '" + Password1 +
> "'," +
>   "'" + Password2 + "')";
>
>   jspDb.setSql(sql);
>   JSPDBResult[] rs = jspDb.execute();
>  }
> %>
>
> Password 1:
> <%= Password1 %>
> <p>
> Password 2:
> <%= Password2 %>
> <p>
> <center>Thank you for submitting...</center>
>
> </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