aspose file tools*
The moose likes Servlets and the fly likes Tomcat 5.0.30 - 404 error with HTML file (Head First Beer example) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat 5.0.30 - 404 error with HTML file (Head First Beer example)" Watch "Tomcat 5.0.30 - 404 error with HTML file (Head First Beer example)" New topic
Author

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

Jean-Christian Imbeault
Greenhorn

Joined: Dec 08, 2004
Posts: 19
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!
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
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!


“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Jean-Christian Imbeault
Greenhorn

Joined: Dec 08, 2004
Posts: 19
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

Joined: Dec 08, 2004
Posts: 19
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.
Andrew Eccleston
Ranch Hand

Joined: Jul 07, 2004
Posts: 140
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


The statement below is true.<br />-------------------------------<br />The statement above is false.
Jean-Christian Imbeault
Greenhorn

Joined: Dec 08, 2004
Posts: 19
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?
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
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

Joined: Dec 08, 2004
Posts: 19
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

Joined: Jul 07, 2004
Posts: 140
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat 5.0.30 - 404 error with HTML file (Head First Beer example)