Link to home
Start Free TrialLog in
Avatar of Xavior2K3
Xavior2K3

asked on

Simple JSP & Tomcat problem

Hi,

I'm currently learning JSP and i have an example in my book that i cant get working. I'm really stuck as to why. I'm using the latest Tomcat (5.5.17) and i havent changed any config files at all.

ch06_01.java
---------------
public class ch06_01 {
      public ch06_01() {}      
      public String msg() { return "Hello from JSP!" };
}

ch06_02.jsp
--------------
<%@ page import="ch06_01" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Using a JavaBean</title>
</head>
<body>
<%
      ch06_01 messenger = new ch06_01();
      out.println(messenger.msg());
%>
</body>
</html>

The java file compiles fine and i put it into the correct folder: tomcat/webapps/ch06/WEB-INF/classes/ch06_01.class

The CLASSPATH environment variable has been set to: C:\tomcat\common\lib\servlet-api.jar

And when i try and run the JSP i get an error:

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

---Generated servlet error:
---The import ch06_01 cannot be resolved

---An error occurred at line: 9 in the jsp file: /ch06_02.jsp
---Generated servlet error:
---ch06_01 cannot be resolved to a type

---An error occurred at line: 9 in the jsp file: /ch06_02.jsp
---Generated servlet error:
---ch06_01 cannot be resolved to a type

I would be very grateful if someone could point out why this isnt working.

Kind Regards,
Michael
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Xavior2K3
Xavior2K3

ASKER

Excellent that worked! Why does it have to be in a package then because i'd have thought the example they gave me in my book should work.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh i see, i thought it might be that!! Great, thanks both for your help!