This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Help Needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help Needed" Watch "Help Needed" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help Needed