Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Regarding to exercise in Head first Servlets & JSP

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Could anyone help ?

I used the Head First Servlets & JSP for studying the Servlet/JSP. And I was got stuck on the exercise in Chapter 3.

The webpage displaying is OK. But when I try to run the first edition of Controller Servlet. I got the following error:

HTTP Status 404 - /Beer-v1/SelectBeer.do

type Status report

message /Beer-v1/SelectBeer.do

description The requested resource (/Beer-v1/SelectBeer.do) is not available.

Apache Tomcat/5.5.17

My program environment is Java 5.0.06/Tomcat 5.5.17 (Window 2000 professional).

I have double checked my code spelling and the directory is follow strictly as the book suggest.

Can anyone help to give some advise ?

Thanks in advance!!

Albert
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post your servlet-mapping from web.xml.
There's probably no mapping associated with SelectBeer.do
 
Albert Liou
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response!

Here is my web.xml

<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>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>

Looking forward to hear from you soon!
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Albert Liou:
Hello,

Could anyone help ?

I used the Head First Servlets & JSP for studying the Servlet/JSP. And I was got stuck on the exercise in Chapter 3.

The webpage displaying is OK. But when I try to run the first edition of Controller Servlet. I got the following error:

HTTP Status 404 - /Beer-v1/SelectBeer.do

type Status report

message /Beer-v1/SelectBeer.do

description The requested resource (/Beer-v1/SelectBeer.do) is not available.

Apache Tomcat/5.5.17

My program environment is Java 5.0.06/Tomcat 5.5.17 (Window 2000 professional).

I have double checked my code spelling and the directory is follow strictly as the book suggest.

Can anyone help to give some advise ?

Thanks in advance!!

Albert



Might be a wrong guess.

Did you compile the servlet???
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you also post your FORM tag please ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another thing. What is the name of your web application ?
Is is "Beer-v1" ? (the folder under webapps in Tomcat)
 
Albert Liou
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Rathi,

yes, I did compile the servlet file and put it in the directory according to the book suggest.(\Tomcat_5.5\webapps\Beer-v1\WEB-INF\classes\com\example\web\)

Any more advise ?

Thanks!
 
Albert Liou
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Satou,

Following is my form tag file :

<html><body>
<h1 align="center">啤酒選擇畫面</h1>
<form method="POST"
action="SelectBeer.do">
選出想喝的啤酒<p>
顏色:
<select name="color" size="1">
<option>Light
<option>amber
<option>brown
<option>dark
</select>
<br><br>
<center>
<input type="SUBMIT">
</center>
</form></body></html>

And I put this file in \Tomcat_5.5\webapps\Beer-v1\

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you put web.xml ?
 
Albert Liou
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Satou,

I put the web.xml in \Tomcat_5.5\webapps\Beer-v1\WEB-INF\


Appreciate for your response.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mmmm... I don't know. The error message seems to point out that the mapping between your form action and your servlet is not found.
The mapping is either wrong (but it seems correct here), or web.xml is not found.

Are you sure you have \Tomcat_5.5\webapps\Beer-v1\WEB-INF\web.xml, with the exact content you've posted above ?
And Did you try to restart Tomcat ?
 
Albert Liou
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still can not resolve the problem, But I am still try to work it out. Can anyone help to explain the meaning of "...:classes:." in the following command, I do not know what this for ?

"cd MyProjects/beerV1

javac -classpath /Users/bert/Applications2/tomcat/commom/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java"

Thanks a lot!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"classes" is the name of the directory where your class files are.
So it says : put the "classes" directory into the CLASSPATH, so that the compiler can find my class files.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably want to type /Users/bert/Applications2/tomcat/common/lib/servlet-api.jar, not /Users/bert/Applications2/tomcat/commom/lib/servlet-api.jar
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try creating a new directory under webapps say "beer" and transfer all your files there. restart tomcat and enter the new url it might work. i had the same problem.

regards
vinay
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Albert,

I think you might have done mistacke when you are compiling your servlet java file in package.. you need use the cpmmand like
javac -d servlet.java

Then only all your packages will be created and you can run your program successfully..

Thanking You
SuneelKota
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to remove one or more documentory under C:\Tomcat\webapps\ such as "webdav". I had the same experience as yours and found that way would be useful. (A BUG in Tomcat?)
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Weichia Huang,

Welcome to Javaranch.

The thread you've posted to is months old.
It should be safe to assume that the original poster has moved on from this issue by now.

Also, Tomcat is one of (if not the) most popular servlet containers in the world. The Head First series is also extremely popular. If there was a bug in Tomcat that kept the examples in that book from running, there would be many Many posts in here from people complaining about it. Since there are not, it is usually best to assume first, that the problem is with your code.
 
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic