Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running first example of head first Servlets & JSP

 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys. I know this is a very, very stupid question but i havent been able to make this work. I have just started to study the Head First Servlets & JSP book and i am trying to run the very first example. I am having a problem with this, because what I get from the browser is a 404 error saying that it cant find the resource i am looking for. I am running windows 7, 64 bits and the apache server with tomcat V 5.5. I have set the JAVA_HOME to C:\Program Files\Java\jre6 and the TOMCAT_HOME to C:\Program Files\Apache Software Foundation\Tomcat 5.5 where it is installed. I have checked the structure asked in the book:
webapps
|
ch1
|
WEB-INF
|
web.xml
|
classes
Ch1Servlet.class

Here is what the web.xml contains:
<?xml version=”1.0” encoding=”ISO-8851-1” ?>
<web-app xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”
version=”2.4”>
<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>
</web-app>


Here is what i am writing in the URL field:

http://localhost:8080/ch1/Serv1

I have tried the examples included during the installation of the web server and they work. Could some one please help me with that??? Thanks a lot!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any errors in any of Tomcat's log files (you'll find a bunch of logs in Tomcat's "logs" directory).

Also, can you show the code for Ch1Servlet ? (UseCodeTags)
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if this helps you. I am running Tomcat 6. When I ran your web.xml in my environment, I reproduced your error. When I changed the first part of the web.xml with the following, it worked in my environment:
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 2.4 declaration should be fine, as described here. But now that Tom pointed to it, I see that your double-quotations are strange. Did you copy/paste it from a pdf or something ? Change all ” into ". (check WeirdWordCharacters)
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually got that error when building in Eclipse but didn't see the problem because it pointed at the line version=”2.4”. Good to know...
 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:Are there any errors in any of Tomcat's log files (you'll find a bunch of logs in Tomcat's "logs" directory).

Also, can you show the code for Ch1Servlet ? (UseCodeTags)


Hello Christophe. I have been looking for errors in the log files, but I cant find anything related. Or at least I am looking for corresponding dates and there are not any...

Here is the servlet's code. Thanks a lot!

 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:The 2.4 declaration should be fine, as described here. But now that Tom pointed to it, I see that your double-quotations are strange. Did you copy/paste it from a pdf or something ? Change all ” into ". (check WeirdWordCharacters)


You are right. The double quotations were strange. I fixed them, but the problem persists...

 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Reilly wrote:I don't know if this helps you. I am running Tomcat 6. When I ran your web.xml in my environment, I reproduced your error. When I changed the first part of the web.xml with the following, it worked in my environment:

Hi Tom. I changed the first part as you told, but the problem persists...

I dont know if it is for some of the environmet variable, or something like that. But what seems to me strange is that the examples run well, so that means the problem is in my code....

Thanks for your help
 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends. I have just solved the problem. It seems there is something wrong with the installer under windows, because I downloaded the non-installer zip file, configured environment variables (JAVA_HOME to jdk TOMCAT_HOME) and it went OK...well, now I am ready to continue with my book, jeje.

Thanks a lot for helping me with this.
 
martin ramboäpple
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran into this problem as well, My issue was that I created a "tomcat"-folder in the mainfolder, but the directory-tree should be in my case:

...\apache-tomcat-6.0.43\webapps\ch1\WEB-INF\classes

webapps-folder already existed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic