velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve O'Hara" <>
Subject RE: Probably Spam Newb: SampleServlet Example not working
Date Tue, 02 Aug 2005 12:17:48 GMT
Hi Mike,

The problem is in your Tomcat configuration.  Here's how it works:-

When Tomcat cranks up, it looks in the server.xml file to determine what
servlets/plugins etc to load.
You need to make sure that you have a <context> descriptor in here like the
following for your application;
        <Context path="/CorrMan" docBase="D:\GLA\CorrMan"
         debug="0" reloadable="false"> </Context>
This tells Tomcat that a servlet exists in "D:\GLA\CorrMan" and that
requests that start with /CorrMan should be directed to it e.g.

A servlet directory MUST contain a WEB-INF subdirectory (e.g.
D:/GLA/CorrMan/WEB-INF) within which there MUST be a web.xml file.
The web.xml file tells Tomcat which class to invoke when it recieves a
request destined for your servlet.
Here's a typical one;
This maps requests like http://localhost/CorrMan/main/blahblahblah to the
class com.pivotal.CorrManServlet

You need to make sure that the Tomcat servlet container can find your class.
You do this by either putting it in a jar file within a lib subdirectory of
WEB-INF, a war file in the root of WEB-INF or explicitly within the classes
subdirectory of WEB-INF e.g.

That's about it - I haven't looked at your example to know the specific
details, but this should be enough for you to work the rest out.


-----Original Message-----
[]On Behalf Of Mike D'Ambrogia
Sent: 01 August 2005 23:41
Subject: Probably Spam Newb: SampleServlet Example not working


New/inexperienced in Tomcat 5.0.28 but getting there slowly, currently
reading the tomcat tutorial.  I've searched the V-U archives on without luck.  Trying to get the simpleservlet
example up and running without luck.  I've gone overboard with info here
in the hopes that the configuration mistake I'm making will be readily
apparent to someone.

TC located in C:\apache\tomcat\ on Win2kpro system,
JAVA_HOME=j2sdk1.4.2_04 but also have jdk1.5.0_04 on the system too

Per the instructions in
velocity-1.4\examples\servlet_example1\readme.txt I've done the

 - made a new directory structure as follows :


 - put the velocity.jar into the velexample/WEB-INF/lib directory (it
came named as velocity-1.4.jar, have not renamed)

 - put the SampleServlet.class into the velexample/WEB-INF/classes

 - put the sample.vm template into the velexample directory.

 - restart tomcat and access the servlet at

I've done nothing else to TC other than stop/start it.  on restart the
console output shows this:

Aug 1, 2005 3:18:18 PM org.apache.catalina.core.StandardHostDeployer
INFO: Installing web application at context path /velexample from URL
Aug 1, 2005 3:18:18 PM org.apache.catalina.startup.ContextConfig
INFO: Missing application web.xml, using defaults only
Aug 1, 2005 3:18:18 PM org.apache.catalina.core.StandardHost start

after restart I go to the url above and get this:

HTTP Status 404 - /velexample/servlet/SampleServlet
type Status report
message /velexample/servlet/SampleServlet
description The requested resource (/velexample/servlet/SampleServlet)
is not available.

If I go to I get a dir listing

If I click on the sample.vm file in the listing I get the actual
contents of the .vm file without the velocity substitutions for $name,
$list, etc displayed which is probably correct given that I'm not
running thru the servlet.

Notes towards the bottom of \velocity-1.4\docs\developer-guide.html make
reference to changes that need to be made to the web.xml file, adding:


Is this chg to web.xml required to run this example code??  Info is abit
thin (for me at least) on what the values for servlet-name and
servlet-class should be, looking for some help with these.  If this chg
is necessary can I add it to a web.xml file in

All help appreciated, looking fwd to coming up to speed


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

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

View raw message