Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    12

    Unanswered: jsp script for login and register

    can someone tell me wats wrong wif my code?
    i run html page and when i click on login or register button, it should show login.jsp or register.jsp but 'the page cannot be displayed' shown.

    my login.jsp coding is:

    <?xml version = "1.0"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <!-- login.jsp -->

    <%-- page settings --%>
    <%@ page errorPage = "registerErrorPage.jsp" %>

    <%-- beans used in this JSP --%>
    <jsp:useBean id = "customer" scope = "page"
    class = "com.deitel.advjhtp1.products.CustomerBean" />
    <jsp:useBean id = "customerData" scope = "request"
    class = "com.deitel.advjhtp1.products.CustomerDataBean " />

    <html xmlns = "http://www.w3.org/1999/xhtml">

    <head>
    <title>Member Login</title>

    <style type = "text/css">
    body {
    font-family: tahoma, helvetica, arial, sans-serif;
    }

    table, tr, td {
    font-size: .9em;
    border: 3px groove;
    padding: 5px;
    background-color: #dddddd;
    }
    </style>
    </head>

    <body>
    <jsp:setProperty name = "customer" property = "*" />

    <% // start scriptlet

    if (customer.getEmail() == null ||
    customer.getPwd() == null ) {


    %> <%-- end scriptlet to insert fixed template data --%>

    <form method = "post" action = "login.jsp">
    <p>Please enter your email and password
    to login.</p>
    <div align="center">
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p><b><font size="+3" color="#CC6633">Existing Member</font></b></p>
    <p align = "center"> <b>Login Name:
    <input type = "text" name = "email">
    </b></p>
    <p align = "center"><b> Password: </b>
    <input type = "password" name = "password">
    </p>
    <p>&nbsp;</p>
    <input type = "submit" name = "action"
    value = "Submit" />
    </div>
    </form>

    <% // continue scriptlet

    } // end if
    else {
    customer = customerData.findUser(customer.getEmail(),customer .getPwd());
    %> <%-- end scriptlet to insert jsp:forward action --%>
    if(customer!=null){
    <%-- forward to display customer database contents --%>
    <jsp:forward page = "product.jsp" />
    }


    <% // continue scriptlet


    } // end else

    %> <%-- end scriptlet --%>
    </body>

    </html>


    and my register.jsp is like:

    <?xml version = "1.0"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <!-- register.jsp -->

    <%-- page settings --%>
    <%@ page errorPage = "registerErrorPage.jsp" %>

    <%-- beans used in this JSP --%>
    <jsp:useBean id = "customer" scope = "page"
    class = "com.deitel.advjhtp1.products.CustomerBean" />
    <jsp:useBean id = "customerData" scope = "request"
    class = "com.deitel.advjhtp1.products.CustomerDataBean " />

    <html xmlns = "http://www.w3.org/1999/xhtml">

    <head>
    <title>Register As New Member</title>

    <style type = "text/css">
    body {
    font-family: tahoma, helvetica, arial, sans-serif;
    }

    table, tr, td {
    font-size: .9em;
    border: 3px groove;
    padding: 5px;
    background-color: #dddddd;
    }
    </style>
    </head>

    <body>
    <jsp:setProperty name = "customer" property = "*" />

    <% // start scriptlet

    if ( customer.getEmail() == null ||
    customer.getFirstName() == null ||
    customer.getLastName() == null ){

    %> <%-- end scriptlet to insert fixed template data --%>

    <form method = "get" action = "register.jsp">
    <p>Please enter your first name, last name and email
    address to register as a new member.</p>

    <table>

    <tr>
    <td>Email</td>

    <td>
    <input type = "text" name = "email" />
    </td>
    </tr>


    <tr>
    <td>First name</td>

    <td>
    <input type = "text" name = "firstName" />
    </td>
    </tr>

    <tr>
    <td>Last name</td>

    <td>
    <input type = "text" name = "lastName" />
    </td>
    </tr>

    <tr>
    <td>Password</td>

    <td>
    <input type = "password" name = "password" />
    </td>
    </tr>

    <tr>
    <td>Confirm Password</td>

    <td>
    <input type = "password" name = "verify" />
    </td>
    </tr>

    <tr>
    <td>Address</td>

    <td>
    <input type = "text" name = "address" />
    </td>
    </tr>

    <tr>
    <td>Phone Number</td>

    <td>
    <input type = "text" name = "phone" />
    </td>
    </tr>

    <tr>
    <td>Credit Card Number</td>

    <td>
    <input type = "text" name = "creditCard" />
    </td>
    </tr>



    <tr>
    <td colspan = "2">
    <input type = "submit"
    value = "Submit" />
    </td>
    </tr>
    </table>
    </form>

    <% // continue scriptlet

    } // end if
    else {
    customerData.addCustomer( customer );

    %> <%-- end scriptlet to insert jsp:forward action --%>

    <%-- forward to display customer database contents --%>
    <jsp:forward page = "login.jsp" />

    <% // continue scriptlet

    } // end else

    %> <%-- end scriptlet --%>
    </body>

    </html>

    register should add a new record into db.
    thanks.

  2. #2
    Join Date
    Sep 2003
    Posts
    12
    the error message that i got was:
    Cannot create bean of class com.deitel.advjhtp1.products.CustomerBean

  3. #3
    Join Date
    Sep 2003
    Posts
    1

    Re: jsp script for login and register

    hi jess...
    check out whether ur bean class is public and it resides in the package what u have mentioned. and check whether this package is puth in the right folder, ie; WEB-INF\Classes

    rgds
    SaSas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •