• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JSP - cannot resolve symbol

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shiva ..thanks a lot..it worked.
reply
    Bookmark Topic Watch Topic
  • New Topic