Reputation: 21
JSP code:
<%@ page import = "action.LoginCheckAction" %>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
LoginCheckAction ls = new LoginCheckAction();
ls.printSomething(username);
%>
Java class:
package action;
public class LoginCheckAction{
public LoginCheckAction(){
super();
}
public void printSomething(String username){
System.out.println(username);
}
}
Another JSP file is sending post data to the JSP code posted here.
I am trying to use the method available in my Java file that is located in another directory, inside the package action, however it keeps giving me a LoginCheckAction cannot be resolved to a type
.
I tried importing action.*
instead, and it did not work.
Can anyone please explain what the problem is?
Upvotes: 1
Views: 5039
Reputation: 734
if you have build your project using maven, sometimes it's unable to compile classes and generate the war and jar file.Build the project to eclipse or netbeans project by :-
shift
and right click and click on open command prompt here
mvn eclipse:eclipse
if you want to build the project for eclipse IDE or mvn netbeans:netbeans
if you want to build the project for netbeansUpvotes: 0
Reputation: 315
if you have build your project using maven, sometimes it's unable to compile classes and generate the war and jar file.Build the project to eclipse or netbeans project by :-
1. Go to the directory of the project
2. Hold shift
and right click and click on open command prompt here
3. Type mvn eclipse:eclipse
if you want to build the project for eclipse IDE or mvn netbeans:netbeans
if you want to build the project for netbeans
4. Close and open the project and your errors should be resolved
Upvotes: 0
Reputation: 1543
The only thing I can think off is that LoginCheckAction source code is not being compilled properly or added to the war or EAR of your web application deployment.
Upvotes: 1