aspose file tools*
The moose likes Struts and the fly likes javax.servlet.jsp.JspException: No getter method for property ID of bean org.apache.struts.taglib.ht Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "javax.servlet.jsp.JspException: No getter method for property ID of bean org.apache.struts.taglib.ht" Watch "javax.servlet.jsp.JspException: No getter method for property ID of bean org.apache.struts.taglib.ht" New topic
Author

javax.servlet.jsp.JspException: No getter method for property ID of bean org.apache.struts.taglib.ht

h patel
Greenhorn

Joined: Jun 22, 2013
Posts: 5
Here is my code for displaying input fields on the page whatever is being entered in field firstname, lastname and ID.....

I am getting error as No getter method for property ID. Can anyne please shed light o it as to where i am going wrong ?...

Below is my code ....


ackage java.struts.example;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


public class CustomerAction extends Action
{

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
ActionForward nextPage = null;
if (isCancelled(request))
{
System.out.println("Cancel Operation Performed");
return mapping.findForward("mainpage");
}

CustomerForm custForm = (CustomerForm) form;

if ("Save".equals(custForm.getStep()))
{
String firstName = custForm.getFirstName();
String lastName = custForm.getLastName();
String ID= custForm.getID();

System.out.println("Customer First name is " + firstName);
System.out.println("Customer Last name is " + lastName);
System.out.println("Customer ID is "+ ID);

nextPage = mapping.findForward("success");
}
return nextPage;
}

}





-----------------------------------------------------------------------------------------

package java.struts.example;

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;


public class CustomerForm extends ActionForm
{

/** Customer First Name */
private String firstName;

/** Customer Last Name */
private String lastName;

private String ID;


private String step;

public CustomerForm()
{
firstName = "";
lastName = "";
ID="";
}

public String getFirstName()
{
return firstName;
}

public void setFirstName(String s)
{
this.firstName = s;
}

public String getLastName()
{
return lastName;
}

public void setLastName(String s)
{
this.lastName = s;
}

public String getID() {
return ID;
}


public void setID(String id) {
ID = id;
}

public String getStep()
{
return step;
}

public void setStep(String string)
{
step = string;
}



public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();

// Firstname cannot be empty
if (firstName == null || firstName.trim().equals(""))
{
errors.add("firstName", new ActionError("error.cust.firstname.empty"));
}

// Lastname cannot be empty
if (lastName == null || lastName.trim().equals(""))
{
errors.add("lastName", new ActionError("error.cust.lastname.empty"));
}

if(firstName.length()<5)
{
errors.add("lastName", new ActionError("less length"));
}

return errors;
}



}

-----------------------------------------------------------------------------------------------------------------


<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<html:html xhtml="true">

<head>
<title><bean:message key="exercise01.formpage.title"/></title>
<html:base/>
<link rel="stylesheet" href="css/struts-training.css" charset="ISO-8859-1" type="text/css"/>
</head>

<body background="images/blueAndWhiteBackground.gif">
<div align="center">
<h2><bean:message key="exercise01.formpage.title"/></h2>

<html:errors/>

<html:form action="/submitCustomerForm" method="GET">

<bean:message key="prompt.customer.firstname"/>:
<html:text property="firstName" size="16" maxlength="16"/>
<BR/>

<bean:message key="prompt.customer.lastname"/>:
<html:text property="lastName" size="16" maxlength="16"/>

<BR/>

<bean:message key="prompt.customer.id"/>:
<html:text property="ID" size="16" maxlength="16"/>

<P/>

<html:submit property="step">
<bean:message key="button.save"/>
</html:submit>

 

<html:cancel>
<bean:message key="button.cancel"/>
</html:cancel>

</html:form>
</div>
</body>

</html:html>

----------------------------------------------------------------------------------------------------------------------------

success.jsp




<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<html:html xhtml="true">

<head>
<title><bean:message key="exercise01.successpage.title"/></title>
<html:base/>
<link rel="stylesheet" href="css/struts-training.css" charset="ISO-8859-1" type="text/css"/>
</head>

<body background="images/blueAndWhiteBackground.gif">

<p/><p/><p/><p/><p/>

<div align="center">
<h2><bean:message key="exercise01.successpage.title" />
<bean:write name="CustomerForm" property="firstName" />
<bean:write name="CustomerForm" property="lastName" />
</h2>
<h3><bean:message key="exercise01.successpage.message" /></h3>

<html:img src="images/Picture079.jpg"/>
<p/><p/>

<html:link page="/CustomerForm.jsp">Go Back</html:link>

</body>

</html:html>

--------------------------------------------------------
MessageResources.properties


########################################
# Common
########################################
errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
errors.footer=</ul><hr>
errors.prefix=<li>
errors.suffix=</li>

########################################
# Exercise01 index page strings
########################################
exercise01.indexpage.title=Welcome to Exercise01

########################################
# Exercise01 CustomerForm strings
########################################
exercise01.formpage.title=Please enter your details
prompt.customer.firstname=First Name EMP
prompt.customer.lastname=Last Name

button.save=Save
button.cancel=Cancel

error.cust.firstname.empty=First Name is Required
error.cust.lastname.empty=Last Name is Required
less.length = Your length was insu

########################################
# Exercise01 Success Page strings
########################################
exercise01.successpage.title=Congratulations
exercise01.successpage.message=Your First Struts Application is a Success



-------------------------------------------------------------------------------------------------------

struts-config.xml


<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>

<form-beans>

<form-bean name="CustomerForm" type="struts.example.CustomerForm" />



</form-beans>


<global-forwards>

<forward name="mainpage" path="/index.jsp" />

</global-forwards>

<action-mappings>

<action path="/showCustomerForm"
parameter="/CustomerForm.jsp"
type="org.apache.struts.actions.ForwardAction" />

<action path="/submitCustomerForm"
type="struts.example.CustomerAction"
name="CustomerForm"
scope="request"
validate="true"
input="/CustomerForm.jsp">
<forward name="success" path="/Success.jsp" />

</action>

</action-mappings>

<controller processorClass="org.apache.struts.action.RequestProcessor" />

<message-resources parameter="struts.example.MessageResources" null="false"/>

</struts-config>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.servlet.jsp.JspException: No getter method for property ID of bean org.apache.struts.taglib.ht