Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

No getter method

  Asked By: Mada    Date: Oct 31    Category: Java    Views: 594
  

I am getting
javax.servlet.jsp.JspException: No getter method for property name of bean
user.
Please advise.
Clement




<struts-config>

<!-- ======================================== Form Bean Definitions -->
<form-beans>
<!-- Logon Form offers user to enter credentials to sing in -->
<form-bean
name="logonForm"
type="logon.LogonForm"/>
</form-beans>
<!-- ================================= Global Exception Definitions -->
<global-exceptions>
<!-- sample exception handler
<exception
key="expired.password"
type="app.ExpiredPasswordException"
path="/changePassword.jsp"/>
end sample -->
</global-exceptions>
<!-- =================================== Global Forward Definitions -->
<global-forwards>
<forward
name="logon"
path="/logon/Logon.do"/>
<forward
name="logoff"
path="/Welcome.do"/>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward
name="welcome"
path="/Welcome.do"/>
</global-forwards>
<!-- =================================== Action Mapping Definitions -->
<action-mappings>
<!-- Default "Welcome" action -->
<!-- Forwards to Welcome.jsp -->
<action
path="/Welcome"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/Welcome.jsp"/>
<action
path="/logon/Logon"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/logon/Logon.jsp"/>
<!-- LogonSubmit action -->
<action
path="/logon/LogonSubmit"
type="logon.LogonAction"
name="logonForm"
scope="request"
validate="true"
input="/pages/logon/Logon.jsp">
<forward
name="userpage"
path="/pages/user/User.jsp"/>
</action>
</action-mappings>
<!-- ===================================== Controller Configuration -->
<controller
processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<!-- ================================ Message Resources Definitions -->
<message-resources parameter="resources.application"/>
<!-- ======================================= Plug Ins Configuration -->
<!-- ========== Tiles plugin =================== -->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>




User.java
package logon;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* Form bean for the user profile page. This form has the following fields,
* with default values in square brackets:
* <ul>
* <li> password - Entered password value
* <li> username - Entered username value
* </ul>
*
*
*@version $Revision: 1.1 $ $Date: 2003/12/29 $
*/
public final class User extends ActionForm {

// ------------------------------------------------ Instance Variables
/**
* User Id.
*/
private int userId = 0;
/**
* User Name.
*/
private String userName = null;
/**
* Password.
*/
private String userPass = null;
/**
* Full Name.
*/
private String fullName = "";
/**
* Organisation.
*/
private String organisation = "";
/**
* Email.
*/
private String email = "test";
/**
* Phone.
*/
private String phone = "";

// ------------------------------------------------------ Properties

/**
* Return the password.
*
*@return The password value
*/
public String getUserPass()
{
return (this.userPass);
}

/**
* Set the password.
*
*@param password The new password
*/
public void setUserPass(String userPass)
{
this.userPass = userPass;
}

/**
* Return the username.
*
*@return The username value
*/
public String getUserName()
{
return (this.userName);
}

/**
* Set the username.
*
*@param username The new username
*/
public void setUserName(String userName)
{
this.userName = userName;
}
/**
* Return the name.
*
*@return The name value
*/
public String getFullName()
{
return (this.fullName);
}

/**
* Set the name.
*
*@param name The new name
*/
public void setFullName(String fullName)
{
this.fullName = fullName;
}

/**
* Return the organisation.
*
*@return The organisation value
*/
public String getOrganisation()
{
return (this.organisation);
}

/**
* Set the organisation.
*
*@param organisation The new organisation
*/
public void setOrganisation(String organisation)
{
this.organisation = organisation;
}

/**
* Return the email.
*
*@return The email value
*/
public String getEmail()
{
return (this.email);
}

/**
* Set the email.
*
*@param email The new email
*/
public void setEmail(String email)
{
this.email = email;
}

/**
* Return the phone.
*
*@return The phone value
*/
public String getPhone()
{
return (this.phone);
}

/**
* Set the phone.
*
*@param phone The new phone
*/
public void setPhone(String phone)
{
this.phone = phone;
}

// -------------------------------------------------- Public Methods

/**
* Reset all properties to their default values.
*
*@param mapping The mapping used to select this instance
*@param request The servlet request we are processing
*/
public void reset(ActionMapping mapping,
HttpServletRequest request) {
setUserName(null);
setUserPass(null);
}

/**
* Ensure that both fields have been input.
*
*@param mapping The mapping used to select this instance
*@param request The servlet request we are processing
*@return Description of the Return Value
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((userName == null) || (userName.length() < 1)) {
errors.add("username",
new ActionError("errors.username.required"));
}
if ((userPass == null) || (userPass.length() < 1)) {
errors.add("password",
new ActionError("errors.password.required"));
}
return errors;
}
}


User.jsp

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>

<html:html locale="true">
<head>
<title>Database</title>
<html:base/>
</head>
<body bgcolor="white">
<h1 align="center"><font face="ARIAL" color="#003399">
Database
</font></h1>
<hr/>
<logic:present name="user">
<font face="SANS-SERIF" color="#CC3300">
Welcome <bean:write name="user" property="userName"/>!
<bean:write name="user" property="userPass"/>

</font></logic:present>
<hr/>
<p/>


<p/>
<ul>
<font face="TOHOMA">
<uli>
<html:link forward="logoff">Sign out</html:link>
</uli>
</font>
</ul>
</body>
</html:html>


Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on No getter method Or get search suggestion and latest updates.




Tagged: