Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
John-Philippe Verger
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The comments aren't important; it's smaller and easier to read if they're not included when posting fragments.
 
John-Philippe Verger
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic