This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes    cannot find BEAN in any scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "   cannot find BEAN in any scope" Watch "   cannot find BEAN in any scope" New topic
Author

cannot find BEAN in any scope

athadu pokiri
Greenhorn

Joined: Jul 09, 2006
Posts: 5
I am getting the error the following error while deploying struts application .can any one tell where to look in? to find the error


:Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This error is frequently encountered in a Struts application. In order for us to help you with it, we need you to post:

1-The JSP you were trying to display when the error occurred
2-The ActionForm bean used by the JSP
3-The entries for the Action and ActionForm in your struts-config.xml file.


Merrill
Consultant, Sima Solutions
Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
Hi,

I too having the same problem

My Jsp:

<BODY>
<center>
<h1> Account Control </h1>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<html:form action="/AccountMod.do">
<bean:write name="accountFormBean" property="warning" filter="false" />
Email
<html:text property="email" />
Password
<html:text property="password" />
<table>
<tr>
<td><html:radio property="operation" value="createAccount" />Create Account</td>
<td><html:radio property="operation" value="modifyAccount" />Modify Account</td>
<td><html:radio property="operation" value="deleteAccount" />Delete Account</td>
</tr>
</table>
<html:submit value="Perform Selected Operation" />
</html:form>
</center>
</BODY>

ActionForm:

package com.sunesh.struts;

import org.apache.struts.action.*;

public class AccountFormBean extends ActionForm
{
private String email = "sample@xyz.com";
private String password = "null";

//for error messages
private String warning = "";

public String getEmail()
{
return this.email;
}

public void setEmail(String email)
{
this.email = email;
}

public String getPassword()
{
return this.password;
}

public void setPassword(String password)
{
this.password = password;
}

public String getWarning()
{
return this.warning;
}

public void setWarning(String warning)
{
this.warning = "<H2>Invalid or missing <FONT color=red>" + warning + "</FONT></H2>";
}
}

struts-comfig.xml :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="accountFormBean"
type="com.sunesh.struts.AccountFormBean" />
</form-beans>

<action-mappings>
<action path="/AccountMod"
type="com.sunesh.struts.AccountAction"
name="accountFormBean"
parameter="operation"
scope="session">

<forward name="create-success" path="admin/create-confirm.jsp" />
<forward name="create-failure" path="accountMod.jsp" />
</action>

</action-mappings>
</struts-config>


can u please help me..

Bye


Thanks & Regards<br />Sunesh Kumar Baachu
Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
Hi,

Sorry I forgot to say this..

First i am trying for only "createAccount" operation only.

But I cant even able to display the "accountMod.jsp" file

could you please help me...

Bye
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Sunesh,

You need to add an "operation" property to your AccountFormBean class with a corresponding getter and setter. Also, it's a good idea to change:

<html:form action="/AccountMod.do">

to

<html:form action="/AccountMod">
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot find BEAN in any scope