0
votes

I'm trying to follow the headfirst jsp and servlets book and I've encountered the following error. HTTP Status 404 - /Beer/form.html

My folders are organised as following

tomcat -> webapps -> Beer -> form.html

Also inside the Beer folder I have another folder WEB-INF which contains the web.xml file.

First I thought maybe my tomcat is not working at all so I tested it using a previous servlet I've done. It worked.

I restarted the web server but I'm still getting this error. I'm running Windows tomcat 7.0.47.

Here is my web.xml file:

<servlet>
    <servlet-name>Beer Expert Project</servlet-name>
    <servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>Beer Expert Project<servlet-name>
    <url-pattern>/beer.do</url-pattern>
</servlet-mapping>

The URL that I'm entering is

http://localhost:8080/Beer/form.html

I'm aware there is a similar question I cannot deploy a basic html file in apache tomcat

But nothing from the answer accepted by that question works for me. Closing the web server does make the page dissapear. I checked that it's capital letters etc ...

Also the windows that pops up when starting tomcat doesn't have any warnings nor errors.

1
tomcat doesn't have any warnings nor errors. Can you see in the logs that whether Beer application is actually getting loaded or not ?Saif Asif
If that's all you have in your web.xml file, it's obviously not valid. It's not even well-formed.JB Nizet
@JBNizet unless there are things they did not show in the book then I'm not sure how this same web.xml file worked for themBula
It didn't. The book probably only shows the relevant parts of the web.xml file, and not the whole file. Here is an example of a complete web.xml file: tutorials.jenkov.com/java-servlets/web-xml.html. This is an old tutorial though and you should have 3.0/3_0 instead of 2.3/3_0. If you used a more recent book or tutorial, you would learn that you don't even need a web.xml file anymore to declare and map a servlet. That is done with annotations nowadays.JB Nizet
@JBNizet It could be that they are hiding code from me but I think it is that I've missed a slash before servlet-name.Bula

1 Answers

0
votes

Ok. I have found the reason why this did not work.

I've missed a single slash before servlet-name.