tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: HTTP status 404
Date Wed, 08 Dec 2010 21:35:34 GMT
Lava Saleem wrote:
> Hi everyone,
> I have  a single page html file with java script embadded in it, I have
> created a war file for it and deployed it successfully but when I click on
> the page I get the below error, the structure of my war file is the
> following
> webapp --> filename --> WEB-INF--> filename.htm  + web.xml + META-INF
> +  classes + lib
> I did not modify the web.xml since I don't need the servlets do I need to
> modify anything?
> HTTP status 404
> description the requested resource (/filename/)is not available

Except the 404 error which your are getting, not much above makes any sense at all.

So it is better to forget all that, and start new.
You really have to learn to walk before you can run.

First, consider the directory structure of a standard Tomcat installation :

       |- bin (tomcat "programs" and scripts)
       |- conf (configuration files)
       |- lib (global library files)
       |- logs (logfiles)
       |- webapps (* web applications *)
             |- ROOT  (the special, top-level, default web application)
             |- app1 (a web application)
             |- app2 (another web application)
             |- ...
             |- lastapp (another web application)

In the above, "(CATALINA_HOME)" represents the top directory of your Tomcat installation,

the one under which the rest of Tomcat is found.
For example, on your system it may be "C:\tomcat" or "C:\program files\Apache Software 
Foundation\tomcat6.0" or "/usr/share/tomcat6" or "/usr/local/tomcat6" or whatever.

The "webapps" sub-directory is what is important for you now.  That is where you will put

"web applications", composed of static html pages (with or without javascript in them), 
JSP pages (special html pages with embedded Java code), java servlets (compiled java 
applications), etc..

The ROOT web application is special.  It is the "default application".
When you use a URL like :
Tomcat is going to look for "abc.html" under the webapps/ROOT directory.

The other subdirectories under "webapps" are each one separate web application.
To access for example the application named "app1", you will have to use a URL starting 
with ""
For example, if you place a html page named "xyz.html" in the subdirectory 
(CATALINA_HOME)/webapps/app1, then the URL to call it up will be

Under such a web application directory like ../webapps/app1, there is also a structure.
It looks like this :

       |- webapps (* dir, top of all web applications *)
             |- app1 (dir, contains the web application named "app1")
                 - public files (html etc..)
                 - WEB-INF (directory)
                      |- files (private)
                      |- web.xml (configuration file for the application)
                      |- classes (dir.)
                            |- compiled java classes, like servlets
                      |- lib (dir)
                            |- java libraries for this webapp
                 - META-INF (dir.)
                      |- context.xml (more settings for the application)

Basically everything under "app1" is optional.  Tomcat will supply a default if needed.
Of course, you will want at least one file under there, to make the execise meaningful.

What is in the sub-directories WEB-INF and META-INF, can never be obtained directly by a 
browser. Tomcat will not allow it.
So if you enter the following URL in the browser :
Tomcat will respond with an error, even if "something" exists.

But to start, I suggest that you just
- stop tomcat
- create a new sub-directory under ../webapps/, for example "myapp".
- under that subdirectory, place a file called "myfile.html"
- verify that the ownership and permissions of these files are such that the Tomcat user 
can read them
- start Tomcat
- in the browser, enter the URL :
and enjoy.

Now play around with the above :
- create another page "mypage2.html", place it alongside "myfile.html", start Tomcat and 
call up the new page in the browser.
- then stop Tomcat again, and create another subdirectory under "webapps", put something 
there, start Tomcat and call it up with the browser.
- then stop Tomcat again, create a sub-directory "WEB-INF" under one of your webapps, put

something in it, start Tomcat and try to call up that file.

When you understand exactly how that works, then go read this page (again) :

And then you should come back for more questions about how to make .war files and deploy 
them properly.
(tip : a .war file is just a zip file with the same content as the "app1" subdirectory 
above.  It has to be named "app1.war", and you have to copy it under /webapps/ for Tomcat

to understand what you want).

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message