File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Devnedra Muttalmuri
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am Using Apache TomCat 5.0/6.0 with jsdk1.4/ struts1.0 ....
here is my code .....
Login.jsp......................
_____________________________________________________________
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body bgcolor="pink">
<br></br>

<html:html>

<html:form action="/myActionForm" method="get">

Enter Plant ID:
<html:text property="Plant_ID" size="30" /><br></br>

Enter Plant Name:
<html:text property="Plant_Name" size="30" /><br></br>

Enter Kindom Name:
<html:text property="Kingdom" size="30" /><br></br>

Enter Order Name:
<html:text property="Orders" size="30" /><br></br>

Enter Family Name:
<html:text property="Family" size="30" /><br></br>

Enter Genus Name :
<html:text property="Genust" size="30" /><br></br>

Enter Species Name :
<html:text property="Species" size="30" /><br></br>

Enter Reference Name :
<html:text property="Reference" size="30" /><br></br>




<html:submit>SUBMIT</html:submit>
<br><br>
</html:form>
</html:html>
</body>
</html>


fail.jsp......
_________________________

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Failed page</title>
</head>
<body bgcolor="pink">
give all the details
</body>
</html>

success.jsp....
________________________________________________
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Success page</title>
</head>
<body bgcolor="pink">
<table><tr>sucessfully added</tr><br></br>

<%= session.getAttribute("Plant_ID") %><br></br>
<%=session.getAttribute("Plant_Name") %><br></br>
<%=session.getAttribute("Kingdom") %><br></br>
<%=session.getAttribute("Orders") %><br></br>
<%=session.getAttribute("Family") %><br></br>
<%=session.getAttribute("Genust") %><br></br>
<%=session.getAttribute("Species") %><br></br>
<%=session.getAttribute("Reference") %><br></br>

</table>
</body>
</html>

web.xml
_______________________

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>InsertDatabase</display-name>

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>

<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>


<security-constraint>
<web-resource-collection>
<web-resource-name>My secure resources</web-resource-name>
<description>Resources to be placed under security control.</description>
<url-pattern>/private/*</url-pattern>
<url-pattern>/registered/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>guest</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>WebApp</realm-name>
</login-config>

<security-role>
<description>The role allowed to access our content</description>
<role-name>guest</role-name>
</security-role>
</web-app>


struts-config.xml
________________________________

<?xml version="1.0" encoding="UTF-8"?>
<!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 type="com.de.MyModel" name ="model" />
</form-beans>
<action-mappings>
<action path="/myActionForm" type="com.de.MyController" name="model" input="/Login.jsp">
<forward name="success" path="/success.jsp" />
<forward name="error" path="/fail.jsp" />

</action>
</action-mappings>


</struts-config>

MyController.java
__________________________

package com.de;

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

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 MyController extends Action {

public ActionForward execute(ActionMapping map, ActionForm fm,
HttpServletRequest req, HttpServletResponse res)
throws Exception {

HttpSession ses = req.getSession(true);

MyModel m = (MyModel)fm;

String Plant_ID = m.getPlant_ID();
String Plant_Name=m.getPlant_Name();
String Kingdom=m.getKingdom();
String Orders=m.getOrders();
String Family=m.getFamily();
String Genust=m.getGenust();
String Species = m.getSpecies();
String Reference = m.getReference();

InsertDataBase IB=new InsertDataBase();

IB.insertData1( Plant_ID, Plant_Name, Kingdom, Orders, Family, Genust, Species, Reference);

ses.setAttribute("Plant_ID",Plant_ID);
ses.setAttribute("Plant_Name",Plant_Name);
ses.setAttribute("Kingdom",Kingdom);
ses.setAttribute("Orders",Orders);
ses.setAttribute("Family",Family);
ses.setAttribute("Genust",Genust);
ses.setAttribute("Species",Species);
ses.setAttribute("Reference",Reference);


if(Plant_ID.equals("")|| Plant_Name.equals("")|| Kingdom.equals("")||Orders.equals("")|| Family.equals("")|| Genust.equals("")||Reference.equals("")){

return map.findForward("error");
}
return map.findForward("success");

}
}

MyModel.java
____________________________

package com.de;

import org.apache.struts.action.ActionForm;

public class MyModel extends ActionForm {

/**
*
*/
private static final long serialVersionUID = 1553863750541794895L;
String Plant_ID;
String Plant_Name;
String Kingdom;
String Orders;
String Family;
String Genust;
String Species;
String Reference;

public String getPlant_ID() {
return Plant_ID;
}
public void setPlant_ID(String plantID) {
this.Plant_ID = plantID;
}
public String getPlant_Name() {
return Plant_Name;
}
public void setPlant_Name(String plantName) {
this.Plant_Name = plantName;
}
public String getKingdom() {
return Kingdom;
}
public void setKingdom(String kingdom) {
this.Kingdom = kingdom;
}
public String getOrders() {
return Orders;
}
public void setOrders(String orders) {
this.Orders = orders;
}
public String getFamily() {
return Family;
}
public void setFamily(String family) {
this.Family = family;
}
public String getGenust() {
return Genust;
}
public void setGenust(String genust) {
this.Genust = genust;
}
public String getSpecies() {
return Species;
}
public void setSpecies(String species) {
this.Species = species;
}
public String getReference() {
return Reference;
}
public void setReference(String reference) {
this.Reference = reference;
}



}


InsertDatabase.java
_____________________
package com.de;
import java.sql.*;

public class InsertDataBase {

public void insertData1(String Plant_ID,String Plant_Name,String Kingdom,String Orders,String Family,String Genust,String Species,String Reference) throws Exception{

System.out.println("jdbc connection");
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String url="jdbc:mysql://localhost/medicinal_plant";
String un="root";
String pwd="lareunion";

String Plant_ID1 =Plant_ID;
String Plant_Name1=Plant_Name;
String Kingdom1=Kingdom;
String Order1=Orders;
String Family1=Family;
String Genus1=Genust;
String Species1=Species;
String Reference1=Reference;


try{
Connection c=DriverManager.getConnection(url,un,pwd);
try{
Statement st = c.createStatement();
int val = st.executeUpdate("INSERT INTO Plant_Classification(Plant_ID,Plant_Name,Kingdom,Orders,Family,Genust,Species,Reference) VALUES('"+Plant_ID1+"','"+Plant_Name1+"','"+Kingdom1+"','"+Order1+"','"+Family1+"','"+Genus1+"','"+Species1+"','"+Reference1+"')");
System.out.println("1 row affected");
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!" + ex);
}
c.close();
}
catch (Exception e){
e.printStackTrace();
}
}
}

AND I AM GETTING ERROR ....
_________________________

javax.servlet.ServletException: No getter method for property Plant_ID of bean org.apache.struts.taglib.html.BEAN
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.Login_jsp._jspService(Login_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

javax.servlet.jsp.JspException: No getter method for property Plant_ID of bean org.apache.struts.taglib.html.BEAN
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:176)
org.apache.jsp.Login_jsp._jspx_meth_html_text_0(Login_jsp.java:167)
org.apache.jsp.Login_jsp._jspx_meth_html_form_0(Login_jsp.java:120)
org.apache.jsp.Login_jsp._jspx_meth_html_html_0(Login_jsp.java:92)
org.apache.jsp.Login_jsp._jspService(Login_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

PLEASE LET ME KNOW WHERE I AM GOING WRONG ......................................................










 
Gopakumar Naryanan
Ranch Hand
Posts: 72
Eclipse IDE Hibernate Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably this issue must have been resolved . Only change you require is your DTO object that is MyModel class must follow Java Beans naming conventions.
Please use code tag for better readability of the code.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic