5:19 am - Wednesday February 21, 2018

No getter method for property firstname of bean org. apache. struts. taglib. html. BEAN in struts

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

HTTP Status 500 –


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /first.jsp:8

5: <html:html>
6:      <html:form action="/myActionForm" method="get">
7:             enetr ur name:
8:             <html:text property="firstname" size="30" />
9:             <html:submit>next</html:submit>
10:            <br><br>
11:     </html:form>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:489)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause


javax.servlet.ServletException: No getter method for property firstname of bean org.apache.struts.taglib.html.BEAN
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.first_jsp._jspService(first_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause


javax.servlet.jsp.JspException: No getter method for property firstname of bean org.apache.struts.taglib.html.BEAN
org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:1031)
org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:153)
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:96)
org.apache.jsp.first_jsp._jspx_meth_html_005ftext_005f0(first_jsp.java:165)
org.apache.jsp.first_jsp._jspx_meth_html_005fform_005f0(first_jsp.java:133)
org.apache.jsp.first_jsp._jspx_meth_html_005fhtml_005f0(first_jsp.java:100)
org.apache.jsp.first_jsp._jspService(first_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.33 logs.


Apache Tomcat/5.5.33

Error:

<html:html>
<html:form action="/myActionForm" method="get">
		enetr ur name:
		<html:text property="firstname" size="30" />
	<html:submit>next</html:submit>
	<br>
	<br>
</html:form>
</html:html>

Model Class:

MyModel.java

import org.apache.struts.action.ActionForm;

public class MyModel extends ActionForm {
	private String name;

	public void setName(String n) {
		name = n;
	}

	public String getName() {
		return name;
	}
}

Correction:

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

<html:html>
<html:form action="/myActionForm" method="get">
		enetr ur name:
		<html:text property="name" size="30" />
	<html:submit>next</html:submit>
	<br>
	<br>
</html:form>
</html:html>

Description:

This error occurs when there is mismatch in property name in jsp file and member variable in model class

Textbox property name and model classs variable name mismatch..

Filed in: Z-AStruts Codes

Comments are closed.