• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Tomcat 5.0.30 - 404 error with HTML file (Head First Beer example)

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I know this is a newbie problem but I'm really lost. I'm starting with the first example in the Head First Servlet & JSP book and even though I am doing everything as laid out in the book (at least I think I am), I can't get Tomcat to load a simple html file.

Details

- Tomcat 5.0.30 on Windows XP
- tomcat installed under c:\tomcat
- I can access http://localhost:8080/
- My file is C:\tomcat\webapps\Beer-v1\form.html
- I try to access it with http://localhost:8080/Beer-v1/form.html and get a 404 error

I'm not even writting servlets yet or playing with web.xml files so I can't see why I can't even load a simple html file.

I know the answer is probably staring me in the face but after 2 hours of trying I give up and confess my stupidity

Help!
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your setup looks right to me... Your server must be running or you wouldn't be able to hit the localhost. Hmmmm... Have you tried shutting down Tomcat and restarting it?

You picked a good book to learn from by the way!
 
Jean-Christian Imbeault
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, I shut down and restarted the server but that didn't help.

Is a restart needed though if you only put html into a directory under webapps?

If I put my file under C:\tomcat\webapps\ROOT get displayed by tomcat if I access it using http://localhost:8080/form.html

But when under C:\tomcat\webapps\Beer-v1 ... nothing but a big 404

Are there any environment variables I need to set perhaps?


In case it's any help here is the complete error message:

HTTP Status 404 - /Beer-v1/form.html
type Status report
message /Beer-v1/form.html

description The requested resource (/Beer-v1/form.html) is not available.
Apache Tomcat/5.0.30
 
Jean-Christian Imbeault
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to mention that I am running this with j2sdk1.4.2_06. Don't know if that make a difference or not as tomcat 5.5 needs java 1.5

I've even tried adding this file, C:\tomcat\webapps\test\a.txt and I cannot load that either using http://localhost:8080/test/a.txt

So it looks like I can not access anything I create under C:\tomcat\webapps, but the directories already there by tomcat (like jsp-examples) are accessible.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try creating a WEB-INF directory under your Beer-v1/ directory and restarting Tomcat. I think that Tomcat needs to see this folder in order to consider it a web application.

Hope it helps.

andrew
 
Jean-Christian Imbeault
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That did it! Thanks.

Now my only question is why!? That is not something I would have expected. Why would a WEB_INF folder be needed is all you want to do is server up static pages?
 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why would a WEB_INF folder be needed is all you want to do is server up static pages?



Jean, I believe the issue is not about serving static or dynamic pages. You have created a new context, hence the need for a corresponding WEB-INF folder.

Regards,
Saket
 
Jean-Christian Imbeault
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, but it's an empty directory. I've added exactly 0 in terms of information. Is the presence of this directory required by the specs? Even if empty?
 
Andrew Eccleston
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My thought process on why is this (and it's only a guess):

Tomcat looks at each Application in the 'webapps' directory upon startup for a deployment descriptor ( WEB-INF/web.xml ). It seems that if the directory is there, but not the file, Tomcat simply uses default deployment attributes. If the directory doesn't exist, my guess is that Tomcat gets a different error condition, and decides that this must not be a valid web application, therefore Tomcat doesn't load that context.

FWIW

andrew
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic