0

I've built this very basic servlet and trying to run it with Tomcat7[Ubuntu 14.04]. But I keep getting Http Status 404 not found error.

Info:

CATALINA_HOME in /usr/share/tomcat7 and CATALINA_BASE in /var/lib/tomcat7.

Deployment Structure: Deployed in CATALINA_BASE as follows:

webapps
\
 ROOT
 \
  BeerV1
  \
   index.html
   WEB-INF
   \
    web.xml
    classes
    \
      tk
      \
       sjsbook
       \
        web
        \
         BeerSelect.class

web.xml file:

<?xml version="1.0" encoding="utf-8" ?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0" metadata-complete="true">

  <servlet>
    <servlet-name>MyBeer</servlet-name>
    <servlet-class>tk.sjsbook.web.BeerSelect</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>MyBeer</servlet-name>
    <url-pattern>/SelectBeer.do</url-pattern>
  </servlet-mapping>
</web-app>

Whenever I run the servlet BeerSelect from index.html as SelectBeer.do, the container gives 404 error.

<form method="POST" action="SelectBeer.do">

Please Suggest!!

Chaitanya
  • 719
  • 9
  • 23
  • please add the link from `index.html` which contains the URL to `MyBeer` to your question – JimHawkins Jun 13 '16 at 08:39
  • I see that you deployed `BeerV1` under `ROOT`, that's wrong. You have to deploy it in webapps – JimHawkins Jun 13 '16 at 08:41
  • @Ulrich - I think the container is set to webapps/ROOT by default, as on opening `localhost:8080` in browser, webapps/ROOT/index.html gets opened – Chaitanya Jun 13 '16 at 09:17
  • after installation of tomcat, `ROOT` contains the default homepage of tomcat. This is the page where you see the version of tomcat, the link to the manager application and other informations. This what you see when you enter `http://localhost:8080` in your browser. You should deploy your webapp to `/webapps/BeerV1`. If you wantyour webapp to be the default application, then delete the directory `ROOT` and rename your webapps war from `BeerV1.war` to `ROOT. war`, and deploy it. I wouldn't do this – JimHawkins Jun 13 '16 at 09:34
  • I was unaware of this. Thanks @Ulrich – Chaitanya Jun 13 '16 at 11:18

0 Answers0