Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

JSP - cannot resolve symbol

 
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 ]
 
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.
 
catch it before it slithers away! Oh wait, it's a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic