Hi people. I am new to this forum. In fact the reason why i registered here is my problems about making a JSP page work.

I am using Apache-Tomcat

I just wanted to test an html file. It was form.html.When i start tomcat and type ht*tp://localhost:8080/ everything works fine. But when i try to run my page

ht*tp://localhost:8080/myfirstwebapp/form.html it does not work.

What am i doing wrong? As i read from the book; testing html files like this was OK.

Can anybody help me please?

9 Years
Discussion Span
Last Post by ~s.o.s~

What sort of error you getting?
Are you sure that your html document is in correct place as Tomcat_directory/webapps/myfirstwebapp?
Does your folder myfirstwaebapp has proper structure something like on attached image bellow?

Attachments tomcat.gif 17.67 KB

No i don't . i just have myfirstwebapp folder under webapps folder. And in that folder i have a simple html document. Should i create all other files to test my html pages? Or should i just create WEB-INF folder.

I will appreciate if you tell me how to test my html document before getting into creating web.xml and jsp,class files...


Good in detail information you can find here and ofcourse Apache Tomcat site. However for your case it would be enought to follow these steps
1) Create work directory under Tomcat_directory/webapps (you already have it this called myfirstwebapp)
2) In this directory (myfirstwebapp) you should place all your html and jsp documents, images can be also place here but is much better to create new folder in this directory for them to avoid mess
3) Create new folder called WEB-INF, this will contain web.xml, foldder class for java files and often another folder lib that holds custom jar files required by your application (lib folder was not showed on the attached image)
4) Simple web.xml document can look something like this

<?xml version="1.0" encoding="ISO-8859-1"?> <!-- xml tag MUST be header of .xml file -->

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    <display-name>My first web application</display-name>
    <description>Testing my first web application if it works.</description>



You can actually replace the last part with call to your document to open it automaticaly


I think this should be enought to get you started. If you still have problems let me know...


> Or should i just create WEB-INF folder.

Simply put, your application will be treated as a web application only if it has a WEB-INF (case matters) directory in it's tree structure. From the Servlet Specification:

A special directory exists within the application hierarchy named “WEB-INF”.
This directory contains all things related to the application that aren’t in the
document root of the application. The WEB-INF node is not part of the public
document tree of the application. No file contained in the WEB-INF directory may
be served directly to a client by the container. However, the contents of the WEBINF
directory are visible to servlet code using the getResource and getResource-
AsStream method calls on the ServletContext, and may be exposed using the
RequestDispatcher calls. Hence, if the Application Developer needs access, from
servlet code, to application specific configuration information that he does not
wish to be exposed directly to theWeb client, he may place it under this directory.
Since requests are matched to resource mappings in a case-sensitive manner,
client requests for ‘/WEB-INF/foo’, ‘/WEb-iNf/foo’, for example, should not result
in contents of the Web application located under /WEB-INF being returned, nor
any form of directory listing thereof.

The contents of the WEB-INF directory are:
• The /WEB-INF/web.xml deployment descriptor.
• The /WEB-INF/classes/ directory for servlet and utility classes. The classes
in this directory must be available to the application class loader.
• The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets,
beans, and other utility classes useful to the Web application. The Web application
class loader must be able to load classes from any of these archive

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.