Jump to content
Sign in to follow this  
rajanpahuja

Struts

Recommended Posts

i m gettin ERROR 500:javax.servlet.ServletException: Cannot retrieve definition for form bean LoginForm on action /doLoginorg.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)org.apache.jsp.pages.login_jsp._jspService(login_jsp.java:96)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1001)org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:560)org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:209)org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)javax.servlet.http.HttpServlet.service(HttpServlet.java:689)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)root causejavax.servlet.jsp.JspException: Cannot retrieve definition for form bean LoginForm on action /doLoginorg.apache.struts.taglib.html.FormTag.lookup(FormTag.java:761)org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:443)org.apache.jsp.pages.login_jsp._jspx_meth_html_form_0(login_jsp.java:146)org.apache.jsp.pages.login_jsp._jspx_meth_html_html_0(login_jsp.java:122)org.apache.jsp.pages.login_jsp._jspService(login_jsp.java:87)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1001)org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:560)org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:209)org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)javax.servlet.http.HttpServlet.service(HttpServlet.java:689)javax.servlet.http.HttpServlet.service(HttpServlet.java:802)Struts-Config.xml:<struts-config><data-sources>..........</data-sources><form-beans><form-bean name="LoginForm.do" type="myproject1.com.LoginForm"/></form-beans><global-forwards><forward name="Welcome" path="/LoginForm.do"/><action-mappings><action path="/LoginForm" forward="/pages/login.jsp"></action><action path="/doLogin"type="myproject1.com.LoginAction"name="LoginForm"scope= "request"validate="false"parameter="/pages/login.jsp"><forward name="success" path="/Home.do" redirect="true"/><forward name="failure" path="/LoginForm.do" /></action></action-mappings><message-resources parameter="java.MessageResources" /></struts-config>LoginForm is:package myproject1.com;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.ActionMessage;public class LoginForm extends ActionForm{private String name=null;private String password=null;public void reset(ActionMapping mapping, HttpServletRequest request) {this.name=null;this.password=null;}public ActionErrors validate(ActionMapping mapping, HttpServletRequest request ) {ActionErrors errors = new ActionErrors();if( getName() == null || getName().length() < 1 ) {errors.add("name",new ActionMessage("error.name.required"));}if( getPassword() == null || getPassword().length() < 1 ) {errors.add("password",new ActionMessage("error.password.required"));}return errors;}public String getName() {return name;}public String getPassword() {return password;}public void setName(String name) {this.name = name;}public void setPassword(String password) {this.password = password;}LoginAction Class is:package myproject1.com;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.ActionMessage;public class LoginForm extends ActionForm{private String name=null;private String password=null;public void reset(ActionMapping mapping, HttpServletRequest request) {this.name=null;this.password=null;}public ActionErrors validate(ActionMapping mapping, HttpServletRequest request ) {ActionErrors errors = new ActionErrors();if( getName() == null || getName().length() < 1 ) {errors.add("name",new ActionMessage("error.name.required"));}if( getPassword() == null || getPassword().length() < 1 ) {errors.add("password",new ActionMessage("error.password.required"));}return errors;}public String getName() {return name;}public String getPassword() {return password;}public void setName(String name) {this.name = name;}public void setPassword(String password) {this.password = password;}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...