aspose file tools*
The moose likes Struts and the fly likes Getting problem  With bean tag in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting problem  With bean tag in jsp" Watch "Getting problem  With bean tag in jsp" New topic
Author

Getting problem With bean tag in jsp

piyal sengupta
Greenhorn

Joined: Apr 17, 2010
Posts: 8
Hi,

I am modeling a sample application in struts.And getting the following error.



javax.servlet.ServletException: org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/search.jsp at line 68

65: <logic:iterate id="result" name="searchForm" property="results" >
66: <tr>
67: <td>
68: <bean:write name="result" property="name"/>
69: </td>
70: <td>
71: <bean:write name="result" property="ssNum"/>


Stacktrace:
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/search.jsp at line 68

65: <logic:iterate id="result" name="searchForm" property="results" >
66: <tr>
67: <td>
68: <bean:write name="result" property="name"/>
69: </td>
70: <td>
71: <bean:write name="result" property="ssNum"/>




root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: No getter method for property: "name" of bean: "result"




My code is like bellow

SearchAction.java

public class SearchAction extends Action{

public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
{
EmployeeSearchService services=new EmployeeSearchService();
ArrayList results=null;
searchForm searchForm=(searchForm)form;



String name=searchForm.getName();
if(Constants.NULL!= name && name.trim().length()>0)
{
results=services.searchByName(name);

}

searchForm.setResults(results);
return mapping.getInputForward();
}
}


SearchFrom.java

public class searchForm extends ActionForm{

private String name=null;
private String ssNum=null;
private List results=null;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSsNum() {
return ssNum;
}
public void setSsNum(String ssNum) {
this.ssNum = ssNum;
}
public List getResults() {
return results;
}
public void setResults(List rults) {
this.results = rults;
}
public void reset(ActionMapping map,HttpServletRequest request)
{
name=this.name;
ssNum=this.ssNum;
results=this.results;
}
public ActionErrors validate(ActionMapping mappin,HttpServletRequest request)
{
ActionErrors err=new ActionErrors();
boolean nameEntered=false;
boolean ssNumEntered=false;

if(Constants.NULL!=name && name.length()>0)
{
nameEntered=true;
}
if(Constants.NULL!=ssNum && ssNum.length()>0)
{
ssNumEntered=true;
}

if(!ssNumEntered && !nameEntered)
{
err.add(Constants.NULL,new ActionMessage("error.serch.criteria.missing"));
}
if(!isValidSSnumber(ssNum))
{
err.add("ssNum",new ActionMessage("error.search.ssNum invalid"));
}
return err;
}
private static boolean isValidSSnumber(String ssNum)
{
if(ssNum.length()>5 && !ssNum.startsWith("s"))
{
return false;
}
for(int i=0;i<ssNum.length();i++)
{
if(i!=0)
{
if(Constants.numerics.indexOf(ssNum.charAt(i))==-1)
{
return false;
}
}
}
return true;
}

}

JSP code snippet

><logic:iterate id="result" name="searchForm" property="results" >
<tr>
<td>
<bean:write name="result" property="name"/>
</td>
<td>
<bean:write name="result" property="ssNum"/>
</td>
</tr>
</logic:iterate>
</table>
</logic:greaterThan>
</logic:present>
</body>
</html>

Struts config entries:


<action path="/search" name="searchForm" validate="true" type="action.SearchAction"
scope="request" input="/jsp/search.jsp">
</action>

My comments:

In bean class I have already declared the getter and setter method for name and ssNum attribute. Then why I am getting the error?

Experts please help me to find out the mistake which is causing the error.

Thanks in advance.

Piyal
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting problem With bean tag in jsp