| Author |
Help Needed
|
Somesh Rathi
Ranch Hand
Joined: Apr 27, 2006
Posts: 31
|
|
Hi Ranchers, I tried to run simple program on struts as given in article in Stuts section by Thomas Paul.. I followed the following steps ( as given in tutorial) 1.Created the LoginBean.java file as follows, and compiled it. class LoginBean { String userType, userId ,passWord; public LoginBean() {} public void setParameters(HttpServletRequest request) { userId = request.getParameter("userId"); passWord = request.getParameter("passWord"); } public ActionErrors validate() { if (!userId.equals(passWord)) { ActionErrors ae = new ActionErrors(); ae.add("userId", new ActionError("error.invalid.login")); return ae; } if (userId.equals("admin")) { userType = "Adminstrator"; } else if (userId.equals("user")) { userType = "User"; } else { ActionErrors ae = new ActionErrors(); ae.add("userId", new ActionError("error.invalid.login")); return ae; } return null; } public String getUserType() { return userType; } public void setUserType(String userType) { this.userType = userType; } } 2.Copied class file to c:\tomcat5.0\webapps\struts\WEB-INF\classes\test\struts 3.Created the LoginAction.java as follows:- package test.struts; import javax.servlet.http.*; import org.apache.struts.action.*; public class LoginAction extends Action { public LoginAction() {} public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException{ LoginBean lb = new LoginBean(); request.setAttribute("LoginBean", lb); lb.setParameters(request); ActionErrors ae = lb.validate(); request.setAttribute(Action.ERROR_KEY, ae); if (ae == null || ae.size() == 0) { return mapping.findForward("valid"); } else { return mapping.findForward("invalid"); } } } While compiling the LoginAction.java , i'm getting the following error. C:\Tomcat 5.0\webapps\struts\WEB-INF\classes\test\struts\LoginAction.java:5: cannot resolve symbol symbol : class LoginBean location: package struts import test.struts.LoginBean; ^ C:\Tomcat 5.0\webapps\struts\WEB-INF\classes\test\struts\LoginAction.java:15: cannot resolve symbol symbol : class LoginBean location: class test.struts.LoginAction LoginBean lb = new LoginBean(); ^ C:\Tomcat 5.0\webapps\struts\WEB-INF\classes\test\struts\LoginAction.java:15: cannot resolve symbol symbol : class LoginBean location: class test.struts.LoginAction LoginBean lb = new LoginBean(); Please help me in resolving error. I think it might some package error, but i couldn't find it... Thanks in advance, Somesh ^
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
It sounds like the problem may be that C:\Tomcat 5.0\webapps\struts\WEB-INF\classes is not in your classpath when your'e compiling. Add it to the classpath, and that should fix the error.
|
Merrill
Consultant, Sima Solutions
|
 |
 |
|
|
subject: Help Needed
|
|
|