views:

61

answers:

1

I have an assignment to use JavaBeans to create an online Banking application. I am trying to make the signup form but I am having some issues. When the form submits I am not able to get the values.

The Form:

<jsp:include page="header.html"></jsp:include>

<h3>Create An Account</h3>
    <form action="process_new_user_account.jsp" method="post"  onsubmit="return validate_form(this)" >
    <fieldset>
     <legend>Personal Info</legend>

    <table width="650px" border="0" align="center">
      <tr>
        <td width="25%"><div align="right">First Name: </div></td>
        <td width="75%">
            <input type="text" onblur="return validate_field(this)" onchange="return validate_field(this)"  onfocus="return validate_field(this)" name="fname" tabindex="1" size="50"/>
     </td>
      </tr>
      <tr>
        <td><div align="right">Last Name: </div></td>
        <td><input type="text" onblur="return validate_field(this)" onchange="return validate_field(this)"  onfocus="return validate_field(this)" name="lname" tabindex="2" size="50"/></td>
      </tr>
      <tr>
        <td><div align="right">Address:</div></td>
        <td><input type="text" onblur="return validate_field(this)" onchange="return validate_field(this)"  onfocus="return validate_field(this)" name="streetAddress" tabindex="3" size="50"/></td>
      </tr>
      <tr>
        <td><div align="right">City:</div></td>
        <td><input type="text" onblur="return validate_field(this)" onchange="return validate_field(this)"  onfocus="return validate_field(this)" name="city" tabindex="4" size="50"/> </td>
      </tr>
          <td><div align="right">State:</div></td>
       <td>
       <select name="state" style="width: 300px;" tabindex="5" onblur="return validate_field(this)" onchange="return validate_field(this)"  onfocus="return validate_field(this)">
       <option value="">Select A State</option>
       <option value="AL" >Alabama</option>
       <option value="AK" >Alaska</option>
       <option value="AZ" >Arizona</option>
       <option value="AR" >Arkansas</option>
       <option value="CA" >California</option>
       <option value="CO" >Colorado</option>
       <option value="CT" >Connecticut</option>
       <option value="DE" >Delaware</option>
       <option value="DC" >District of Columbia</option>
       <option value="FL" >Florida</option>
       <option value="GA" >Georgia</option>
       <option value="HI" >Hawaii</option>
       <option value="ID" >Idaho</option>
       <option value="IL" >Illinois</option>
       <option value="IN" >Indiana</option>
       <option value="IA" >Iowa</option>
       <option value="KS" >Kansas</option>
       <option value="KY" >Kentucky</option>
       <option value="LA" >Louisiana</option>
       <option value="ME" >Maine</option>
       <option value="MD" >Maryland</option>
       <option value="MA" >Massachusetts</option>
       <option value="MI" >Michigan</option>
       <option value="MN" >Minnesota</option>
       <option value="MS" >Mississippi</option>
       <option value="MO" >Missouri</option>
       <option value="MT" >Montana</option>
       <option value="NE" >Nebraska</option>
       <option value="NV" >Nevada</option>
       <option value="NH" >New Hampshire</option>
       <option value="NJ" >New Jersey</option>
       <option value="NM" >New Mexico</option>
       <option value="NY" >New York</option>
       <option value="NC" >North Carolina</option>
       <option value="ND" >North Dakota</option>
       <option value="OH" >Ohio</option>
       <option value="OK" >Oklahoma</option>
       <option value="OR" >Oregon</option>
       <option value="PA" >Pennsylvania</option>
       <option value="RI" >Rhode Island</option>
       <option value="SC" >South Carolina</option>
       <option value="SD" >South Dakota</option>
       <option value="TN" >Tennessee</option>
       <option value="TX" >Texas</option>
       <option value="UT" >Utah</option>
       <option value="VT" >Vermont</option>
       <option value="VI" >Virgin Islands</option>
       <option value="VA" >Virginia</option>
       <option value="WA" >Washington</option>
       <option value="WV" >West Virginia</option>
       <option value="WI" >Wisconsin</option>
       <option value="WY" >Wyoming</option>
      </select>   </td>
     </tr>
     <tr>
          <td><div align="right">Zip:</div></td> 
          <td><input name="zip" type="text" id="zip" tabindex="6"  onblur="return validate_field(this)" onfocus="return validate_field(this)" onchange="return validate_field(this)" size="50"/></td>
     </tr>
      <tr>
        <td><div align="right">Phone:</div></td>
        <td> <input name="phone" type="text" id="phone" tabindex="7"  onblur="return validate_field(this)" onfocus="return validate_field(this)" onchange="return validate_field(this)" size="50"/></td>
      </tr>
      <tr>
        <td><div align="right">Email:</div></td>
        <td><input name="email" type="text" id="email" tabindex="8"  onblur="return validate_field(this)" onfocus="return validate_field(this)" onchange="return validate_field(this)" size="50"/></td>
      </tr>   
</table>

    </fieldset>

    <fieldset>
     <legend>Login Info</legend>

     <table width="650px" border="0" align="center">
      <tr>
        <td width="25%"><div align="right">Username:</div></td>
        <td width="75%"><input name="username" type="text" id="username" tabindex="9"  onblur="return validate_field(this)" onfocus="return validate_field(this)" onchange="return validate_field(this)" size="50"/></td>
      </tr>
      <tr>
        <td><div align="right">Password:</div></td>
        <td><input name="password" type="password" id="password" tabindex="10"  onblur="return validate_field(this)" onfocus="return validate_field(this)" onchange="return validate_field(this)" size="50"/></td>
      </tr>   
      <tr>
        <td><div align="right">Reenter Password: </div></td>
        <td><input name="passwordRE" type="password" id="passwordRE" tabindex="11"  onblur="return validate_field(this)" onfocus="return validate_field(this)" onchange="return validate_field(this)" size="50"/></td>
      </tr>                   
    </table>
    </fieldset>

     <div align="center">
          <input type="reset" name="Reset" value="Clear" />
          <input type="submit" name="Submit" value="Create Account" tabindex="12" />
        </div>

    </form>

    <br /><br />

       <jsp:include page="footer.html"></jsp:include>

The JSP page that the for submits to (its is short just for testing until I get it to work):

<%@page import="WebBank.Customer"%>
<jsp:useBean id="customer" scope="session" class="WebBank.Customer"/>
<jsp:setProperty name="customer" property="zip"/>


<jsp:include page="header.html"></jsp:include>

<h3>Welcome!</h3>
<p>Thank you for creating a new account with JAC Bank!</p>


<%
 System.out.println("Testing.....");
 System.out.println("Name: " + customer.getZip());
 %>

<jsp:include page="footer.html"></jsp:include>

There is also a class called Customer that has a default constructor and a String getZip() and void setZip( String zip ) methods.

A: 

I don't see a servlet to unpack the values from the input form, bind them to a Customer object, and add it to session. Where does that happen in your code?

It's called Model-2 MVC. Add a servlet and funnel requests to it. You'll fare better.

I'd also recommend that you learn JSTL and remove all scriptlet code from your JSPs.

duffymo
the second jsp (=servlet) is supposed to do that. and should do, if everything is set-up correctly.
Bozho
"...if everything is set-up correctly..." - there's the rub.
duffymo