This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes What could be an explanation of HTTP 404 error in my web-app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What could be an explanation of HTTP 404 error in my web-app?" Watch "What could be an explanation of HTTP 404 error in my web-app?" New topic
Author

What could be an explanation of HTTP 404 error in my web-app?

John-Philippe Verger
Greenhorn

Joined: Feb 18, 2008
Posts: 25
Hi everybody,

I'm learning Servlets and JSP technology. and I use Apache Tomcat 6 as web server and servlet container.
I try to construct a simple web-app named FirstWebApp with no java server page ,no servlet and only one html file named index.html which ,when requested, must only display:
Hello,this is my first web-app,using Servlets and JSP technology.

To achieve this , I created a directory named FirstWebApp just under Tomcat web-apps directory . I wrote my index.html file and stored it at the root of FirstWebApp directory. Here's the content of index.html:



I also created a WEB-INF directory at the root of FirstWebApp Directory. This WEB-INF directory contains no subdirectory.I create a web.xml file at the root of WEB-INF directory(I precise that it's WEB-INF directory just under FirstWebApp directory)..Here's the content of the DD file:


The problem is that when I type http://localhost:8080/FirstWebApp/index.html in the adress bar of my browser, I get the error HTTP 404. Please, I would like to know why I have this error.

Thanks in advance for your answers.


Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9307
    
  17

John you should have seen the tomcat logs to find out the error. The error says that there are some problems with your web.xml file. Use this code



I've removed the spaces before <? and between <? and xml on line 1 and between < and welcome-file-list on line 29...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The comments aren't important; it's smaller and easier to read if they're not included when posting fragments.
John-Philippe Verger
Greenhorn

Joined: Feb 18, 2008
Posts: 25
Ankit Garg,

Thank you very much for your answer. With the correction of the web.xml you provided , things work well now for my small web application.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What could be an explanation of HTTP 404 error in my web-app?