Hi all Iam new to struts and Iam getting the Exception javax.servlet.ServletException: Cannot find bean: "messageBean" in any scope I think the problem is with struts-config.xml,but i coudn't find out the error.Can anyone Please help me with this? my files are: signUp1.jsp-front page ContactFormBean.java-bean MessageBean.java-result bean confirmation.jsp missing-value.jsp
confirmation.jsp .... <BODY BGCOLOR="#FDF5E6"> <CENTER> <H1>Confirmation</H1> Congratulations. You are now signed up for the Single Provider of Alert Memos network! <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <UL> <LI>First name: <bean:write name="contactFormBean" property="firstName"/> <LI>Last name: <bean:write name="contactFormBean" property="lastName"/> <LI>Email address: <bean:write name="contactFormBean" property="email"/> <LI>Fax number: <bean:write name="contactFormBean" property="faxNumber"/> </UL> To be removed from the network, send email <A HREF="mailto:email@example.com">here</A>. </CENTER> </BODY></HTML>
Hi, If you see your action mapping in the struts config file, you have mapped SignupAction1 class as the action class and contactFormBean as your formbean class for which the forward page is missing-value.jsp. But if you see in missing-value.jsp you have used 'messageBean' as your formbean class for your <bean:write> tag to display the value. When you give the name property as 'messageBean' in this tag it will look for this formbean class mapped for this particular action in struts config file.In your case it is contactFormBean not MessageFormBean.(you can go through the tag library user guide for more clarification) so it will show the error as 'Cannot find bean "messageBean" in any scope '. When struts gives ActionForm classes to serve this requirment, i think there is no need to use a plain class like your messageFormBean and then set it into the request. You can solve your problem by combining your contactFormBean class and MessageFormBean class into one you want to use only one FormBean class for the both. In your action class you just need to set the value for MessageFormBean.
subject: Problem: Cannot find bean "messageBean" in any scope