Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP - cannot resolve symbol

 
H Singh
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 2 in the jsp file: /result.jsp
Generated servlet error:
C:\Tomcat5\work\Catalina\localhost\Persons\org\apache\jsp\result_jsp.java:43: cannot resolve symbol
symbol : class Person
location: class org.apache.jsp.result_jsp
Person person = null;

Code for PersonServlet, Person and result.jsp is below:

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class PersonServlet extends HttpServlet{

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
doPost(request,response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{

Person p = new Person();

p.setName("Evan");
request.setAttribute("person",p);

RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request,response);
}
}

public class Person{

private String name;

public void setName(String name){
this.name = name;
}

public String getName(){
return name;
}
}

<html><body>
<jsp:useBean id="person" class="Person" scope="request" />
Person created: <jsp:getProperty name="person" property="name" />
</body></html>

PersonServlet and Person class files are under:
webapps\Persons\WEB-INF\classes directory

and result.jsp is at webapp level ( \Persons\result.jsp)

I have set up my classpath as well:

C:\Tomcat5\webapps\Persons\WEB-INF\classes;C:\Tomcat5\common\lib\servlet-api.jar;

Any help will be appreciated.
[ June 14, 2005: Message edited by: HS ]
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you put in the import statement in the jsp for Person.java . This should match the package structure within classes where Person.java is located
 
H Singh
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shiva ..thanks a lot..it worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic