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

Cannot find bean

Sahina Celin
Greenhorn

Joined: Aug 25, 2004
Posts: 23
Here is my JSP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html:html locale="true">

<body>

<html:errors />

<bean:write name="user" property="title" />
<bean:write name="user" property="firstName" />
<bean:write name="user" property="lastName" />

<table>
<tr>
<td><bean:message key="adduser.email" /></td>
<td><bean:write name="user" property="email" /></td>
</tr>
<tr>
<td><bean:message key="adduser.birthdate" /></td>
<td><bean:write name="user" property="birth" /></td>
</tr>
</table>

</body>

</html:html>


Getting the following error..





javax.servlet.ServletException: Cannot find bean user in scope request
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778)
org.apache.jsp.jsp.simple2.viewinfo_jsp._jspService(org.apache.jsp.jsp.simple2.viewinfo_jsp:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:506)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.jsp.JspException: Cannot find bean user in scope request
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:879)
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:286)
org.apache.jsp.jsp.simple2.viewinfo_jsp._jspx_meth_bean_write_0(org.apache.jsp.jsp.simple2.viewinfo_jsp:191)
org.apache.jsp.jsp.simple2.viewinfo_jsp._jspx_meth_html_html_0(org.apache.jsp.jsp.simple2.viewinfo_jsp:115)
org.apache.jsp.jsp.simple2.viewinfo_jsp._jspService(org.apache.jsp.jsp.simple2.viewinfo_jsp:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:506)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Hi,
Try to add this...




Hope this help and correct me if I am wrong

thanks
daniel
Sahina Celin
Greenhorn

Joined: Aug 25, 2004
Posts: 23
Thnx for ur response.
But i got it when i changed the bean:name

<bean:write name="userViewForm" property="title" />

userViewForm - is the <form:bean name>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cannot find bean