I am unable to run the servlet version 2 given on page 85(of Head First Servlets and JSP 2nd edition) even after building the directory structures as shown in the book. Specifically, i am unable to compile the servlet called BeerSelect.java. The error shown is "unable to find package com.example.model.*". I have checked and rechecked the directory structures. I am compiling the servlet from MyProjects/beerV1 directory with the command "javac -d classes src/com/example/web/BeerSelect.java" as i have already set the classpath elsewhere. Moreover version 1 of the same servlet is running fine.
Also i would like to report that the deployment descriptor given on page 30 in chapter 1 of the same book does not work well. Tomcat 5.5 shows error in the first line of the web.xml file i.e. "<?xml version=�1.0� encoding=�ISO-8851-1� ?>". Upon removing this line the servlet runs fine.
Please help guys.
help your PC help you best
Originally posted by seetharaman venkatasamy: Hi ravi,
2.which version of tomcat you are using?
sorry, your using tomcat5.5 ...then try this web.xml and put it into the WEB-INF directory
try and let me know [ August 07, 2008: Message edited by: Ulf Dittmer ]
Joined: Jul 15, 2006
I have copied servlet-api.jar and jsp-api.jar files in the C:\Program Files\Java\jdk1.5\jre\lib\ext directory. This serves the same purpose. Moreover, rest examples are running fine i.e. chapter1,2,3.The problem is with this one only.
Joined: Jul 30, 2008
well it seems that you are putting your .java files and .class files in different directories.
so in your case you have to make sure that the package "com.example.model" is in the both directories.
You said that you are compiling like this: "javac -d classes src/com/example/web/BeerSelect.java" So the directory you are in must look like this: MyProjects/beerV1/src/com/example/web/BeerSelect.java BeerSelect.java must try to import "com.example.model.*" which is probably found at: MyProjects/beerV1/src/com/example/model/ The problem is that com.example.model is NOT in your classpath. Your classpath begins in the MyProjects/beerV1/ directory (because that is where you are when you run the javac command) and the package is in the MyProjects/beerV1/src/ directory.
Try running javac from inside the MyProjects/beerV1/src/ directory and compile with: "javac -d classes com/example/web/BeerSelect.java"
That should fix the problem. [ August 07, 2008: Message edited by: Steve Luke ]