Search code examples
javaservletstomcat5.5

Unable to run Web project on eclipse on tomcat server


i have made a small web application with form.html in the WebContent/WEB-INF/Form.html location

There are servletOne.java Servlet.java, Icecream.java in the src folder of my project named "ApplicaitonOne"

Form.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <p><kbd>SELECT VALUE</kbd></p>
  <p>
    <label>
      <input type="radio" name="RadioGroup1" value="Vanilla" id="RadioGroup1_0" />
      Vanilla</label>
    <br />
    <label>
      <input type="radio" name="RadioGroup1" value="Chocolate" id="RadioGroup1_1" />
      CHocholate</label>
    <br />
    <label>
      <input type="radio" name="RadioGroup1" value="Strawberry" id="RadioGroup1_2" />
      Strawberry</label>
    <br />
  </p>
  <p>
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    <br />
  </p>
</form>
<p>&nbsp;</p>
</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>ApplicationOne</display-name>
    <welcome-file-list>

        <welcome-file>Form.html</welcome-file>
    </welcome-file-list>

    <servlet>
    <servlet-name>ServletOne</servlet-name>
    <servlet-class>com.example.ServletOne</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>ServletOne</servlet-name>
    <url-pattern>/Welcome</url-pattern>
    </servlet-mapping>

    <session-config>
    <session-timeout>
    15
    </session-timeout>
    </session-config>

    <context-param>
    <param-name>flavour</param-name>
    <param-value>Choclate</param-value>
    </context-param>

    <listener>
    <listener-class>
    com.example.ServletInt
    </listener-class>
    </listener>

</web-app>

When running project as server, I get:

address in address bar: http://localhost:8080/ApplicationOne/
HTTP Status 404 - /ApplicationOne/
type Status report
message /ApplicationOne/
description The requested resource (/ApplicationOne/) is not available.
Apache Tomcat/5.5.31

When running form.html as server, I get:

address in address bar: http://localhost:8080/ApplicationOne/WEB-INF/Form.html
HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/5.5.31


Solution

  • WEB-INF is a private directory (It will contains configs and compile code). form.html should be directly under WebContent/.

    To double check the context path of your application you can visit: http://localhost:8080/manager/html