1

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

Dori
  • 915
  • 1
  • 12
  • 20
ProgramME
  • 653
  • 3
  • 12
  • 23

2 Answers2

4

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

h3xStream
  • 6,293
  • 2
  • 47
  • 57
  • i have placed the form.html in WebContent folder,still when i run ApplicationOne as "Run as server",i get the sam error – ProgramME May 19 '11 at 02:39
  • It might be a glitch from the WTP plugin. Export the project to a WAR. 1. check that the form.html is at the root (in the war/zip archive) 2. finally deploy it manually (place it in webapps or see the manager page). – h3xStream May 19 '11 at 02:48
  • Extra note : the 'name' tag in the web.xml has no effect on the context path. – h3xStream May 19 '11 at 03:14
  • i am using tomcat5.5 as server and eclipse helios – ProgramME May 19 '11 at 15:55
  • Verify your app is locate at : [TOMCAT]/webapps/ApplicationOne/ .. the folder name will determine the context path (by default) – h3xStream May 19 '11 at 16:16
0

You should place your html or jsp file just under the WebContent Folder: like:workspace[Project Name]\WebContent\form.html and Run it through tomcat. It will work properly.