Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSP problem with Beans

843836Mar 31 2005 — edited Mar 31 2005
Hi there,

I am relatively new to Java & JSP but am learning and keen to learn more.

I am having problems storing info in Beans.

I have examples where they store info into Beans and am following the examples that I have seen .. the problem is that when I execute the JSP file, it doesn't like my Bean. I really don't know what I am doing wrong .. I feel like I am following all the instructions but it doesn't work!! Please help :-)

Here is the error I get: org.apache.jasper.JasperException: /peak/validate.jsp(39,0) The value for the useBean class attribute ora.jsp.beans.user.UserBean is invalid

Here is my validate.jsp file:
%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>


package ora.jsp.beans.user;
<%-- Remove the validUser session bean, if any --%>
<c:remove var="validUser" />
 
<c:if test="${empty param.userName || empty param.password}">
  <c:redirect url="login.jsp" >
    <c:param name="errorMsg" 
      value="You must enter a User Name and Password." />
  </c:redirect>
</c:if>

<%-- 
  See if the user name and password combination is valid. If not,
  redirect back to the login page with a message.
--%>
<sql:query var="athInfo">
  SELECT * FROM t_user  
    WHERE u_login = ? AND u_password = ?
  <sql:param value="${param.userName}" />
  <sql:param value="${param.password}" />
</sql:query>

<c:if test="${athInfo.rowCount == 0}">
  <c:redirect url="login.jsp" >
    <c:param name="errorMsg" 
      value="The User Name or Password you entered is not valid." />
  </c:redirect>
</c:if>

<%--    
  Create an EmployeeBean and save it in 
  the session scope and redirect to the appropriate page.
--%>
<c:set var="dbValues" value="${athInfo.rows[0]}" />
<jsp:useBean id="user" 
  class="ora.jsp.beans.user.UserBean" >
  <c:set target="${UserDetails}" property="u_login" 
    value="${dbValues.UserName}" />
  <c:set target="${UserDetails}" property="u_id"
    value="${dbValues.UserId}" />
  <c:set target="${UserDetails}" property="u_fname" 
    value="${dbValues.FirstName}" />
  <c:set target="${UserDetails}" property="u_lname" 
    value="${dbValues.LastName}" />
  <c:set target="${UserDetails}" property="dept" 
    value="${dbValues.Dept}" />
  <c:set target="${UserDetails}" property="empDate" 
    value="${dbValues.EmpDate}" />
  <c:set target="${UserDetails}" property="emailAddr" 
    value="${dbValues.EmailAddr}" />
</jsp:useBean>

<%--<c:set var="isValid" value="true" />--%>
<c:choose>
  <c:when test="${isValid}">
    <jsp:forward page="getworkoutdetails.jsp" />
  </c:when>
  <c:otherwise>
    <jsp:forward page="enter.jsp" />
  </c:otherwise>
</c:choose>
And my Bean (located in /usr/local/PeakJSPStuff/src/com/ora/jsp/beans/user --> note that /usr/local/PeakJSPStuff/src is in my CLASSPATH) is below:
package ora.jsp.beans.user;

import java.io.* ; 
import java.util.*;

/**
 * This class contains information about an u.
 *
 * @author Hans Bergsten, Gefion software <hans@gefionsoftware.com>
 * @version 2.0
 */
public class UserBean implements Serializable {
    // Properties
  
    private Integer u_id;
    private String u_login;
    private String u_password;
    private String u_fname; 
    private String u_lname; 
    private String u_email; 
    private String u_phone; 
    private String u_country; 
    private String u_province;
    private Integer u_typeID;
    private Integer u_sportID;
    private Integer u_coachID;
    private Integer u_levelID;    
    

    /**
     * Returns the ulogin property value.
     */
    public Integer getUserId() {
        return u_id;
    }

    /**Int
     * Sets the ulogin property value.
     */
    public void setUserId(Integer u_login) {
        this.u_id = u_id;
    } 

    /**
     * Returns the ulogin property value.
     */
    public String getUlogin() {
        return u_login;
    }

    /**Int
     * Sets the ulogin property value.
     */
    public void setUlogin(String u_login) {
        this.u_login = u_login;
    }

    /**
     * Returns the u_password property value.
     */
    public String getUpassword() {
        return u_password;
    }

    /**
     * Sets the u_password property value.
     */
    public void setUpassword(Date empDate) {
        this.u_password = u_password;
    }

    /**
     * Returns the u_fname property value.
     */
    public String getUFname() {
        return u_fname;
    }

    /**
     * Sets the u_fname property value.
     */
    public void setUFname(String emailAddr) {
        this.u_fname = u_fname;
    }

    
    /**
     * Returns the u_lname property value.
     */
    public String getULname() {
        return u_lname;
    }

    /**
     * Sets the u_lname property value.
     */
    public void setULname(String u_lname) {
        this.u_lname = u_lname;
    }

    
    /**
     * Returns the u_email property value.
     */
    public String getUEmail() {
        return u_email;
    }

    /**
     * Sets the password property value.
     */
    public void setUEmail(String u_email) {
        this.u_email = u_email;
    }

    /**
     * Returns the u_phone property value.
     */
    public String getUPhone() {
        return u_phone;
    }

    /**
     * Sets the u_phone property value.
     */
    public void setUPhone(String u_phone) {
        this.u_phone = u_phone;
    }

   /**
     * Returns the u_country property value.
     */
    public String getUCountry() {
        return u_country;
    }

    /**
     * Sets the u_country property value.
     */
    public void setUCountry(String u_phone) {
        this.u_country = u_country;
    }

    /**
     * Returns the u_province property value.
     */
    public String getUProvince() {
        return u_province;
    }

    /**
     * Sets the u_province property value.
     */
    public void setUProvince(String u_province) {
        this.u_province = u_province;
    }
   
    /**
     * Returns the u_typeID property value.
     */
    public Integer getUTypeID() {
        return u_typeID;
    }

    /**
     * Sets the u_typeID property value.
     */
    public void setUTypeID(Integer  u_typeID) {
        this.u_typeID = u_typeID;
    }

    /**
     * Returns the u_sportID property value.
     */
    public Integer getUSportID() {
        return u_sportID;
    }

    /**
     * Sets the u_sportID property value.
     */
    public void setUSportID(Integer  u_sportID) {
        this.u_sportID = u_sportID;
    }

   /**
     * Returns the u_coachID property value.
     */
    public Integer getUCoachID() {
        return u_coachID;
    }

    /**
     * Sets the u_coachID property value.
     */
    public void setUCoachID(Integer  u_coachID) {
        this.u_coachID = u_coachID;
    }

   /**
     * Returns the u_levelID property value.
     */
    public Integer getULevelID() {
        return u_levelID;
    }

    /**
     * Sets the u_levelID property value.
     */
    public void setULevelID(Integer  u_levelID) {
        this.u_levelID = u_levelID;
    }


}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 28 2005
Added on Mar 31 2005
4 comments
515 views