• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Head First Servlet JSP: BeerSelect example: requested resource not available

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

I also have problems getting the Head First Servlets and JSP example of chapter 3 (page 81) run.

After pressing the submit button of form.html I got an 404 error, saying
"description The requested resource (/Beer-v1/SelectBeer.do) is not available."

##########

What I did before:

0) Run Windows-XP-Home, Apache Tomcat/5.5.16, firefox-1.5.0.1-win with extension LiveHTTPHeader-0.12

1) I put the form.html to the place:
<tomcat-path>\webapps\ROOT\Beer-v1\form.html
with:
...
<form method="POST" action="SelectBeer.do">
...

2) Place the web.xml to:
<tomcat-path>\webapps\ROOT\Beer-v1\WEB-INF\web.xml

with:
...
<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>
...

3) Compiled BeerSelect.java and placed BeerSelect.class to:
<tomcat-path>\webapps\ROOT\Beer-v1\WEB-INF\classes\com\example\web\BeerSelect.class

4) Restart Tomcat

5) type URL:
localhost:8080/Beer-v1/form.html which is transformed in my firefox-1.5.0.1-win to http://localhost:8080/Beer-v1/form.html

The html page is rendered.

After pressing the submit button, firefox extension LiveHTTPHeader shows /Beer-v1/SelectBeer.do is called:
...
POST /Beer-v1/SelectBeer.do HTTP/1.1
...

6) Got:
"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.16"

###########

7) I tried also Ben Southers "Simple Servlet" (http://simple.souther.us./ar01s02.html) from his "Simple Servlets Examples" and got also error 404
(with his path structure <tomcat-path>\webapps\ROOT\mjs_SimpleServlet\WEB-INF\classes\us\souther\simple\SimpleServlet.class
instead of mine <tomcat-path>\webapps\ROOT\Beer-v1\WEB-INF\classes\com\example\web\BeerSelect.class ):

"HTTP Status 404 - /mjs_SimpleServlet/simple-servlet

type Status report

message /mjs_SimpleServlet/simple-servlet

description The requested resource (/mjs_SimpleServlet/simple-servlet) is not available.
Apache Tomcat/5.5.16"

######################

Does any of you has a hint for me?

Greetings Mike
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

3) Compiled BeerSelect.java and placed BeerSelect.class to:
<tomcat-path>\webapps\ROOT\Beer-v1\WEB-INF\classes\com\example\web\BeerSelect.class



Don't put your Beer-v1 app inside ROOT folder.

You should have structured it as follows:

<tomcat-path>\webapps\Beer-v1
[ April 09, 2006: Message edited by: Eduardo Dela Rosa ]
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your project folder(Beer-V1) should be present in the webapps directory.


Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
 
Mike Just
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, now it works after moving <tomcat-path>\webapps\ROOT\Beer-v1 to <tomcat-path>\webapps\Beer-v1.

Also Ben Southers "Simple Servlet" is running now after moving from <tomcat-path>\webapps\ROOT\SimpleServlet\ to <tomcat-path>\webapps\SimpleServlet\

That ROOT-Folder already existed after the Tomcat installation. There is the default jsp-page in which one sees after typing the URL: "localhost:8080".

There are still two questions:
1) Why the URL: "localhost:8080" leads to an error now after moving my Beer-v1 folder? [ "description The requested resource (Servlet org.apache.jsp.index_jsp is not available) is not available." ]

2) Why do the <tomcat-path>\webapps\jsp-examples don't run, as they are already in webapps folder?

Any suggestions?
 
Eduardo Dela Rosa
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest reinstalling your Tomcat, as you might have messed it up because of your Beer?

Otherwise, check that the <tomcat-dir>\webapps\ROOT\WEB-INF\web.xml is
intact and its content is still in order.

Take note of the following "NOTE" when you first install and run TOMCAT for the first time:


NOTE: This page is precompiled. If you change it, this page will not change since it was compiled into a servlet at build time. (See $CATALINA_HOME/webapps/ROOT/WEB-INF/web.xml as to how it was mapped.)



So whatever you do, don't blow it up, else the only option you've got is
really - a reinstall.

HTH.
 
Mike Just
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I would suggest reinstalling your Tomcat



Ok I did a reinstall after deinstallation and total delete of ALL Tomcat files. After the reinstall i have in folder "<tomcat-dir>\webapps\":
  • balancer
  • jsp-examples
  • servlets-examples
  • ROOT
  • tomcat-docs
  • webdav


  • What is the sutuation with these webapps:

  • A) "http://localhost:8080/" (ROOT), "localhost:8080/tomcat-docs" and "localhost:8080/webdav" succeed while displaying the rendered content.
  • B) "localhost:8080/balancer" brings me to "http://jakarta.apache.org/"
  • C) "localhost:8080/jsp-examples/", "localhost:8080/servlets-examples" failed with "The requested resource (/jsp-examples/) is not available." and "The requested resource (/servlets-examples/) is not available."



  • After copy back both folder "Beer-v1" and "SimpleServlet" into "<tomcat-dir>\webapps\" both ("localhost:8080/Beer-v1/form.html" and "localhost:8080/SimpleServlet") are sucessful. Section C still does not work.

    I cant see any rule nor reason for that behaviour.

    Anyway, my Beer-v1 webapp runs and I cant go on with the exercise in the book.

    Eduardo thanks for your help.
    If anybody has a hint for that new behaviour please let me know.

    Mike
     
    Something must be done about this. Let's start by reading this tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic