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
JSP

Avatar of undefined
Last Comment
Xavior2K3

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
bloodredsun

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
TimYates

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Xavior2K3

ASKER
Oh i see, i thought it might be that!! Great, thanks both for your help!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23