You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeff Brewer <je...@3brewers.org> on 2003/03/23 19:53:35 UTC
Help with Servlets
I've spent DAYS and DAYS and DAYS trying to get tomcat to run servlets. Nothing I try works. I have followed the instructions in three books, several online tutorials and attempted to decipher tomcat documentation on the apache site. I've installed and reinstalled two versions to Tomcat (currently on 4.1.24). I've modified server.xml and web.xml files until my fingers are sore from typing. Any help would be GREATLY appreciated. Nothing helps; nothing works except the tomcat examples which mock me!
Here is my problem:
>From a clean install of tomcat, create a new directory under webapps called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
Copy the file "HelloWorldExample.class" from "webapps/examples/WEB-INF/classes" and paste it into "webapps/dumfries/WEB-INF/classes"
Create the following file and save as "web.xml" in the "webapps/dumfries/WEB-INF" directory:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<servlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>HelloWorldExample</servlet-class>
</servlet>
<web-app>
</web-app>
Add the following tag to the server.xml file:
<Context path="/dumfries" docBase="dumfries" debug="0" reloadable="true" />
Start the server and browse to "http://localhost:8080/examples/servlet/HelloWorldExample"
Note that the page displays.
Now browse to "http://localhost:8080/dumfries/servlet/HelloWorldExample" and behold the error message.
What am I doing wrong!!!! How can I make this work??? I'm supposed to be half way done with my project and I can't get my first servlet to work!!! Help!
Re: Help with Servlets
Posted by Jeff Brewer <je...@3brewers.org>.
Thanks to everyone who helped. I have one final question; where can I find
documentation for how to maintain these files?
Thanks
----- Original Message -----
From: "p niemandt" <ma...@acesurfer.co.za>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Sunday, March 23, 2003 3:06 PM
Subject: Re: Help with Servlets
> First, as a suggestion, you will need to understand XML and DTD's: This
> will explain what the web.xml file can and can not do.
>
> Then: There are multiple ways of doing servlet mappings: I tend to stay
> away from war files, for no particular reason at all, so, in that case,
> I need to map all my servlets and their requests in the web.xml file. I
> have no experience with war files, but understand you do / can do it
> differently using that.
>
> web.xml
> You need to publish every and all servlets, FIRST.
> You need to map all the servlets to their requests, after publishing all
> the servlets ...
>
> <web-app>
> <!-- Publish the servlet to the container -->
> <servlet>
> <servlet-name>Servlet1</servlet-name>
> <servlet-class>JavaPackage.ServletClass</servlet-class>
> </servlet>
>
> <servlet>
> <servlet-name>Servlet2</servlet-name>
> <servlet-class>JavaPackage.ServletClass</servlet-class>
> </servlet>
>
>
> <servlet>
> <servlet-name>Servlet3</servlet-name>
> <servlet-class>JavaPackage.ServletClass</servlet-class>
> </servlet>
>
>
> <!-- Map requests to servlet -->
> <servlet-mapping>
> <servlet-name>Servlet1</servlet-name>
> <url-pattern>/Servlet1/*</url-pattern>
> </servlet-mapping>
>
> <servlet-mapping>
> <servlet-name>Servlet2</servlet-name>
> <url-pattern>/Servlet2/*</url-pattern>
> </servlet-mapping>
>
> <servlet-mapping>
> <servlet-name>Servlet3</servlet-name>
> <url-pattern>/Servlet3/*</url-pattern>
> </servlet-mapping>
>
>
> </web-app>
>
> etc, ad infinitum ...
>
> hth,
> Paul
>
>
>
>
> On Sun, 2003-03-23 at 19:46, Jeff Brewer wrote:
> > Thank you. I am seeing some success with this!
> >
> > If I have multiple servlets, do I need to publish all to the container
> > individually and map each request to the servlet individually and does
the
> > order matter?
> >
> > Thanks again...
> > Jeff
> > ----- Original Message -----
> > From: "p niemandt" <ma...@acesurfer.co.za>
> > To: <to...@jakarta.apache.org>
> > Sent: Sunday, March 23, 2003 2:22 PM
> > Subject: Re: Help with Servlets
> >
> >
> > > At least you didn't say you've tried everything: I hate that, if you
> > > have tried everything, something would have worked ;-),
> > > but anyways, I'm going of on a tangent ...
> > >
> > > Firstly, your web.xml looks kinda screwed: You have nothing mapped
> > > int the wep app.
> > >
> > > Then, quite likely your major problem is that you have not
> > > mapped any requests to your servlet.
> > >
> > > You need to map your web application to it's implementation. It's not
> > > enough to just state your web descriptor {Like your post shows}, you
> > > will also need something like
> > >
> > > <!-- Map requests to servlet -->
> > > <servlet-mapping>
> > > <servlet-name>ServletName</servlet-name>
> > > <url-pattern>/*</url-pattern>
> > > </servlet-mapping>
> > >
> > > after ALL the <servlet /> definitions.
> > >
> > > So something like ...
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > > <!DOCTYPE web-app
> > > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > > "http://java.sun.com/dtd/web-app_2_3.dtd">
> > > <web-app>
> > > <!-- Publish the servlet to the container -->
> > > <servlet>
> > > <servlet-name>YourServletName</servlet-name>
> > > <servlet-class>JavaPackage.ServletClass</servlet-class>
> > >
> > > </servlet>
> > >
> > > <!-- Map requests to servlet -->
> > > <servlet-mapping>
> > > <servlet-name>YourServletName</servlet-name>
> > > <url-pattern>/*</url-pattern>
> > > </servlet-mapping>
> > >
> > > </web-app>
> > >
> > > That's of course, assuming a few things ...
> > > 1. Your servlet is compiled, and a proper extension of HttpServlet
> > > 2. You want everything under
> > > http://yourservername.domain/YourServletName to go to your servlet.
> > > 3. And probably another few things,
> > >
> > > Hopefully this will help you in the right direction ...
> > >
> > > Paul
> > >
> > > On Sun, 2003-03-23 at 18:53, Jeff Brewer wrote:
> > > > I've spent DAYS and DAYS and DAYS trying to get tomcat to run
servlets.
> > Nothing I try works. I have followed the instructions in three books,
> > several online tutorials and attempted to decipher tomcat documentation
on
> > the apache site. I've installed and reinstalled two versions to Tomcat
> > (currently on 4.1.24). I've modified server.xml and web.xml files until
my
> > fingers are sore from typing. Any help would be GREATLY appreciated.
Nothing
> > helps; nothing works except the tomcat examples which mock me!
> > > >
> > > > Here is my problem:
> > > >
> > > > >From a clean install of tomcat, create a new directory under
webapps
> > called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
> > > >
> > > > Copy the file "HelloWorldExample.class" from
> > "webapps/examples/WEB-INF/classes" and paste it into
> > "webapps/dumfries/WEB-INF/classes"
> > > >
> > > > Create the following file and save as "web.xml" in the
> > "webapps/dumfries/WEB-INF" directory:
> > > >
> > > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > > >
> > > > <!DOCTYPE web-app
> > > > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > > > "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
> > > > <servlet>
> > > > <servlet-name>HelloWorldExample</servlet-name>
> > > > <servlet-class>HelloWorldExample</servlet-class>
> > > > </servlet>
> > > > <web-app>
> > > > </web-app>
> > > >
> > > > Add the following tag to the server.xml file:
> > > >
> > > > <Context path="/dumfries" docBase="dumfries" debug="0"
reloadable="true"
> > />
> > > >
> > > > Start the server and browse to
> > "http://localhost:8080/examples/servlet/HelloWorldExample"
> > > > Note that the page displays.
> > > >
> > > > Now browse to
"http://localhost:8080/dumfries/servlet/HelloWorldExample"
> > and behold the error message.
> > > >
> > > > What am I doing wrong!!!! How can I make this work??? I'm supposed
to be
> > half way done with my project and I can't get my first servlet to
work!!!
> > Help!
> > > --
> > > p niemandt <ma...@acesurfer.co.za>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> > >
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> --
> p niemandt <ma...@acesurfer.co.za>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help with Servlets
Posted by p niemandt <ma...@acesurfer.co.za>.
First, as a suggestion, you will need to understand XML and DTD's: This
will explain what the web.xml file can and can not do.
Then: There are multiple ways of doing servlet mappings: I tend to stay
away from war files, for no particular reason at all, so, in that case,
I need to map all my servlets and their requests in the web.xml file. I
have no experience with war files, but understand you do / can do it
differently using that.
web.xml
You need to publish every and all servlets, FIRST.
You need to map all the servlets to their requests, after publishing all
the servlets ...
<web-app>
<!-- Publish the servlet to the container -->
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>JavaPackage.ServletClass</servlet-class>
</servlet>
<servlet>
<servlet-name>Servlet2</servlet-name>
<servlet-class>JavaPackage.ServletClass</servlet-class>
</servlet>
<servlet>
<servlet-name>Servlet3</servlet-name>
<servlet-class>JavaPackage.ServletClass</servlet-class>
</servlet>
<!-- Map requests to servlet -->
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/Servlet1/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/Servlet2/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet3</servlet-name>
<url-pattern>/Servlet3/*</url-pattern>
</servlet-mapping>
</web-app>
etc, ad infinitum ...
hth,
Paul
On Sun, 2003-03-23 at 19:46, Jeff Brewer wrote:
> Thank you. I am seeing some success with this!
>
> If I have multiple servlets, do I need to publish all to the container
> individually and map each request to the servlet individually and does the
> order matter?
>
> Thanks again...
> Jeff
> ----- Original Message -----
> From: "p niemandt" <ma...@acesurfer.co.za>
> To: <to...@jakarta.apache.org>
> Sent: Sunday, March 23, 2003 2:22 PM
> Subject: Re: Help with Servlets
>
>
> > At least you didn't say you've tried everything: I hate that, if you
> > have tried everything, something would have worked ;-),
> > but anyways, I'm going of on a tangent ...
> >
> > Firstly, your web.xml looks kinda screwed: You have nothing mapped
> > int the wep app.
> >
> > Then, quite likely your major problem is that you have not
> > mapped any requests to your servlet.
> >
> > You need to map your web application to it's implementation. It's not
> > enough to just state your web descriptor {Like your post shows}, you
> > will also need something like
> >
> > <!-- Map requests to servlet -->
> > <servlet-mapping>
> > <servlet-name>ServletName</servlet-name>
> > <url-pattern>/*</url-pattern>
> > </servlet-mapping>
> >
> > after ALL the <servlet /> definitions.
> >
> > So something like ...
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <!DOCTYPE web-app
> > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > "http://java.sun.com/dtd/web-app_2_3.dtd">
> > <web-app>
> > <!-- Publish the servlet to the container -->
> > <servlet>
> > <servlet-name>YourServletName</servlet-name>
> > <servlet-class>JavaPackage.ServletClass</servlet-class>
> >
> > </servlet>
> >
> > <!-- Map requests to servlet -->
> > <servlet-mapping>
> > <servlet-name>YourServletName</servlet-name>
> > <url-pattern>/*</url-pattern>
> > </servlet-mapping>
> >
> > </web-app>
> >
> > That's of course, assuming a few things ...
> > 1. Your servlet is compiled, and a proper extension of HttpServlet
> > 2. You want everything under
> > http://yourservername.domain/YourServletName to go to your servlet.
> > 3. And probably another few things,
> >
> > Hopefully this will help you in the right direction ...
> >
> > Paul
> >
> > On Sun, 2003-03-23 at 18:53, Jeff Brewer wrote:
> > > I've spent DAYS and DAYS and DAYS trying to get tomcat to run servlets.
> Nothing I try works. I have followed the instructions in three books,
> several online tutorials and attempted to decipher tomcat documentation on
> the apache site. I've installed and reinstalled two versions to Tomcat
> (currently on 4.1.24). I've modified server.xml and web.xml files until my
> fingers are sore from typing. Any help would be GREATLY appreciated. Nothing
> helps; nothing works except the tomcat examples which mock me!
> > >
> > > Here is my problem:
> > >
> > > >From a clean install of tomcat, create a new directory under webapps
> called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
> > >
> > > Copy the file "HelloWorldExample.class" from
> "webapps/examples/WEB-INF/classes" and paste it into
> "webapps/dumfries/WEB-INF/classes"
> > >
> > > Create the following file and save as "web.xml" in the
> "webapps/dumfries/WEB-INF" directory:
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > >
> > > <!DOCTYPE web-app
> > > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > > "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
> > > <servlet>
> > > <servlet-name>HelloWorldExample</servlet-name>
> > > <servlet-class>HelloWorldExample</servlet-class>
> > > </servlet>
> > > <web-app>
> > > </web-app>
> > >
> > > Add the following tag to the server.xml file:
> > >
> > > <Context path="/dumfries" docBase="dumfries" debug="0" reloadable="true"
> />
> > >
> > > Start the server and browse to
> "http://localhost:8080/examples/servlet/HelloWorldExample"
> > > Note that the page displays.
> > >
> > > Now browse to "http://localhost:8080/dumfries/servlet/HelloWorldExample"
> and behold the error message.
> > >
> > > What am I doing wrong!!!! How can I make this work??? I'm supposed to be
> half way done with my project and I can't get my first servlet to work!!!
> Help!
> > --
> > p niemandt <ma...@acesurfer.co.za>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
--
p niemandt <ma...@acesurfer.co.za>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help with Servlets
Posted by James Carman <ja...@carmanconsulting.com>.
Yes, you do need to provide a servlet mapping for each of your servlets you
wish to run, unless you want to run the invoker servlet (not recommended).
Usually you map a different url pattern for each servlet in your webapp.
This can be somewhat tedious, so I use XDoclet to generate my web.xml file
for me! But, for simple projects, this is not necessary.
----- Original Message -----
From: "Jeff Brewer" <je...@3brewers.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Sunday, March 23, 2003 2:46 PM
Subject: Re: Help with Servlets
> Thank you. I am seeing some success with this!
>
> If I have multiple servlets, do I need to publish all to the container
> individually and map each request to the servlet individually and does the
> order matter?
>
> Thanks again...
> Jeff
> ----- Original Message -----
> From: "p niemandt" <ma...@acesurfer.co.za>
> To: <to...@jakarta.apache.org>
> Sent: Sunday, March 23, 2003 2:22 PM
> Subject: Re: Help with Servlets
>
>
> > At least you didn't say you've tried everything: I hate that, if you
> > have tried everything, something would have worked ;-),
> > but anyways, I'm going of on a tangent ...
> >
> > Firstly, your web.xml looks kinda screwed: You have nothing mapped
> > int the wep app.
> >
> > Then, quite likely your major problem is that you have not
> > mapped any requests to your servlet.
> >
> > You need to map your web application to it's implementation. It's not
> > enough to just state your web descriptor {Like your post shows}, you
> > will also need something like
> >
> > <!-- Map requests to servlet -->
> > <servlet-mapping>
> > <servlet-name>ServletName</servlet-name>
> > <url-pattern>/*</url-pattern>
> > </servlet-mapping>
> >
> > after ALL the <servlet /> definitions.
> >
> > So something like ...
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <!DOCTYPE web-app
> > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > "http://java.sun.com/dtd/web-app_2_3.dtd">
> > <web-app>
> > <!-- Publish the servlet to the container -->
> > <servlet>
> > <servlet-name>YourServletName</servlet-name>
> > <servlet-class>JavaPackage.ServletClass</servlet-class>
> >
> > </servlet>
> >
> > <!-- Map requests to servlet -->
> > <servlet-mapping>
> > <servlet-name>YourServletName</servlet-name>
> > <url-pattern>/*</url-pattern>
> > </servlet-mapping>
> >
> > </web-app>
> >
> > That's of course, assuming a few things ...
> > 1. Your servlet is compiled, and a proper extension of HttpServlet
> > 2. You want everything under
> > http://yourservername.domain/YourServletName to go to your servlet.
> > 3. And probably another few things,
> >
> > Hopefully this will help you in the right direction ...
> >
> > Paul
> >
> > On Sun, 2003-03-23 at 18:53, Jeff Brewer wrote:
> > > I've spent DAYS and DAYS and DAYS trying to get tomcat to run
servlets.
> Nothing I try works. I have followed the instructions in three books,
> several online tutorials and attempted to decipher tomcat documentation on
> the apache site. I've installed and reinstalled two versions to Tomcat
> (currently on 4.1.24). I've modified server.xml and web.xml files until my
> fingers are sore from typing. Any help would be GREATLY appreciated.
Nothing
> helps; nothing works except the tomcat examples which mock me!
> > >
> > > Here is my problem:
> > >
> > > >From a clean install of tomcat, create a new directory under webapps
> called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
> > >
> > > Copy the file "HelloWorldExample.class" from
> "webapps/examples/WEB-INF/classes" and paste it into
> "webapps/dumfries/WEB-INF/classes"
> > >
> > > Create the following file and save as "web.xml" in the
> "webapps/dumfries/WEB-INF" directory:
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > >
> > > <!DOCTYPE web-app
> > > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > > "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
> > > <servlet>
> > > <servlet-name>HelloWorldExample</servlet-name>
> > > <servlet-class>HelloWorldExample</servlet-class>
> > > </servlet>
> > > <web-app>
> > > </web-app>
> > >
> > > Add the following tag to the server.xml file:
> > >
> > > <Context path="/dumfries" docBase="dumfries" debug="0"
reloadable="true"
> />
> > >
> > > Start the server and browse to
> "http://localhost:8080/examples/servlet/HelloWorldExample"
> > > Note that the page displays.
> > >
> > > Now browse to
"http://localhost:8080/dumfries/servlet/HelloWorldExample"
> and behold the error message.
> > >
> > > What am I doing wrong!!!! How can I make this work??? I'm supposed to
be
> half way done with my project and I can't get my first servlet to work!!!
> Help!
> > --
> > p niemandt <ma...@acesurfer.co.za>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help with Servlets
Posted by James Carman <ja...@carmanconsulting.com>.
Oh, yes the order matters how you define things in your web.xml file. It
has to follow the DTD.
----- Original Message -----
From: "Jeff Brewer" <je...@3brewers.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Sunday, March 23, 2003 2:46 PM
Subject: Re: Help with Servlets
> Thank you. I am seeing some success with this!
>
> If I have multiple servlets, do I need to publish all to the container
> individually and map each request to the servlet individually and does the
> order matter?
>
> Thanks again...
> Jeff
> ----- Original Message -----
> From: "p niemandt" <ma...@acesurfer.co.za>
> To: <to...@jakarta.apache.org>
> Sent: Sunday, March 23, 2003 2:22 PM
> Subject: Re: Help with Servlets
>
>
> > At least you didn't say you've tried everything: I hate that, if you
> > have tried everything, something would have worked ;-),
> > but anyways, I'm going of on a tangent ...
> >
> > Firstly, your web.xml looks kinda screwed: You have nothing mapped
> > int the wep app.
> >
> > Then, quite likely your major problem is that you have not
> > mapped any requests to your servlet.
> >
> > You need to map your web application to it's implementation. It's not
> > enough to just state your web descriptor {Like your post shows}, you
> > will also need something like
> >
> > <!-- Map requests to servlet -->
> > <servlet-mapping>
> > <servlet-name>ServletName</servlet-name>
> > <url-pattern>/*</url-pattern>
> > </servlet-mapping>
> >
> > after ALL the <servlet /> definitions.
> >
> > So something like ...
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <!DOCTYPE web-app
> > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > "http://java.sun.com/dtd/web-app_2_3.dtd">
> > <web-app>
> > <!-- Publish the servlet to the container -->
> > <servlet>
> > <servlet-name>YourServletName</servlet-name>
> > <servlet-class>JavaPackage.ServletClass</servlet-class>
> >
> > </servlet>
> >
> > <!-- Map requests to servlet -->
> > <servlet-mapping>
> > <servlet-name>YourServletName</servlet-name>
> > <url-pattern>/*</url-pattern>
> > </servlet-mapping>
> >
> > </web-app>
> >
> > That's of course, assuming a few things ...
> > 1. Your servlet is compiled, and a proper extension of HttpServlet
> > 2. You want everything under
> > http://yourservername.domain/YourServletName to go to your servlet.
> > 3. And probably another few things,
> >
> > Hopefully this will help you in the right direction ...
> >
> > Paul
> >
> > On Sun, 2003-03-23 at 18:53, Jeff Brewer wrote:
> > > I've spent DAYS and DAYS and DAYS trying to get tomcat to run
servlets.
> Nothing I try works. I have followed the instructions in three books,
> several online tutorials and attempted to decipher tomcat documentation on
> the apache site. I've installed and reinstalled two versions to Tomcat
> (currently on 4.1.24). I've modified server.xml and web.xml files until my
> fingers are sore from typing. Any help would be GREATLY appreciated.
Nothing
> helps; nothing works except the tomcat examples which mock me!
> > >
> > > Here is my problem:
> > >
> > > >From a clean install of tomcat, create a new directory under webapps
> called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
> > >
> > > Copy the file "HelloWorldExample.class" from
> "webapps/examples/WEB-INF/classes" and paste it into
> "webapps/dumfries/WEB-INF/classes"
> > >
> > > Create the following file and save as "web.xml" in the
> "webapps/dumfries/WEB-INF" directory:
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
> > >
> > > <!DOCTYPE web-app
> > > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > > "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
> > > <servlet>
> > > <servlet-name>HelloWorldExample</servlet-name>
> > > <servlet-class>HelloWorldExample</servlet-class>
> > > </servlet>
> > > <web-app>
> > > </web-app>
> > >
> > > Add the following tag to the server.xml file:
> > >
> > > <Context path="/dumfries" docBase="dumfries" debug="0"
reloadable="true"
> />
> > >
> > > Start the server and browse to
> "http://localhost:8080/examples/servlet/HelloWorldExample"
> > > Note that the page displays.
> > >
> > > Now browse to
"http://localhost:8080/dumfries/servlet/HelloWorldExample"
> and behold the error message.
> > >
> > > What am I doing wrong!!!! How can I make this work??? I'm supposed to
be
> half way done with my project and I can't get my first servlet to work!!!
> Help!
> > --
> > p niemandt <ma...@acesurfer.co.za>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help with Servlets
Posted by Jeff Brewer <je...@3brewers.org>.
Thank you. I am seeing some success with this!
If I have multiple servlets, do I need to publish all to the container
individually and map each request to the servlet individually and does the
order matter?
Thanks again...
Jeff
----- Original Message -----
From: "p niemandt" <ma...@acesurfer.co.za>
To: <to...@jakarta.apache.org>
Sent: Sunday, March 23, 2003 2:22 PM
Subject: Re: Help with Servlets
> At least you didn't say you've tried everything: I hate that, if you
> have tried everything, something would have worked ;-),
> but anyways, I'm going of on a tangent ...
>
> Firstly, your web.xml looks kinda screwed: You have nothing mapped
> int the wep app.
>
> Then, quite likely your major problem is that you have not
> mapped any requests to your servlet.
>
> You need to map your web application to it's implementation. It's not
> enough to just state your web descriptor {Like your post shows}, you
> will also need something like
>
> <!-- Map requests to servlet -->
> <servlet-mapping>
> <servlet-name>ServletName</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
>
> after ALL the <servlet /> definitions.
>
> So something like ...
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
> <!-- Publish the servlet to the container -->
> <servlet>
> <servlet-name>YourServletName</servlet-name>
> <servlet-class>JavaPackage.ServletClass</servlet-class>
>
> </servlet>
>
> <!-- Map requests to servlet -->
> <servlet-mapping>
> <servlet-name>YourServletName</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
>
> </web-app>
>
> That's of course, assuming a few things ...
> 1. Your servlet is compiled, and a proper extension of HttpServlet
> 2. You want everything under
> http://yourservername.domain/YourServletName to go to your servlet.
> 3. And probably another few things,
>
> Hopefully this will help you in the right direction ...
>
> Paul
>
> On Sun, 2003-03-23 at 18:53, Jeff Brewer wrote:
> > I've spent DAYS and DAYS and DAYS trying to get tomcat to run servlets.
Nothing I try works. I have followed the instructions in three books,
several online tutorials and attempted to decipher tomcat documentation on
the apache site. I've installed and reinstalled two versions to Tomcat
(currently on 4.1.24). I've modified server.xml and web.xml files until my
fingers are sore from typing. Any help would be GREATLY appreciated. Nothing
helps; nothing works except the tomcat examples which mock me!
> >
> > Here is my problem:
> >
> > >From a clean install of tomcat, create a new directory under webapps
called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
> >
> > Copy the file "HelloWorldExample.class" from
"webapps/examples/WEB-INF/classes" and paste it into
"webapps/dumfries/WEB-INF/classes"
> >
> > Create the following file and save as "web.xml" in the
"webapps/dumfries/WEB-INF" directory:
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> >
> > <!DOCTYPE web-app
> > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
> > <servlet>
> > <servlet-name>HelloWorldExample</servlet-name>
> > <servlet-class>HelloWorldExample</servlet-class>
> > </servlet>
> > <web-app>
> > </web-app>
> >
> > Add the following tag to the server.xml file:
> >
> > <Context path="/dumfries" docBase="dumfries" debug="0" reloadable="true"
/>
> >
> > Start the server and browse to
"http://localhost:8080/examples/servlet/HelloWorldExample"
> > Note that the page displays.
> >
> > Now browse to "http://localhost:8080/dumfries/servlet/HelloWorldExample"
and behold the error message.
> >
> > What am I doing wrong!!!! How can I make this work??? I'm supposed to be
half way done with my project and I can't get my first servlet to work!!!
Help!
> --
> p niemandt <ma...@acesurfer.co.za>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help with Servlets
Posted by p niemandt <ma...@acesurfer.co.za>.
At least you didn't say you've tried everything: I hate that, if you
have tried everything, something would have worked ;-),
but anyways, I'm going of on a tangent ...
Firstly, your web.xml looks kinda screwed: You have nothing mapped
int the wep app.
Then, quite likely your major problem is that you have not
mapped any requests to your servlet.
You need to map your web application to it's implementation. It's not
enough to just state your web descriptor {Like your post shows}, you
will also need something like
<!-- Map requests to servlet -->
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
after ALL the <servlet /> definitions.
So something like ...
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Publish the servlet to the container -->
<servlet>
<servlet-name>YourServletName</servlet-name>
<servlet-class>JavaPackage.ServletClass</servlet-class>
</servlet>
<!-- Map requests to servlet -->
<servlet-mapping>
<servlet-name>YourServletName</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
That's of course, assuming a few things ...
1. Your servlet is compiled, and a proper extension of HttpServlet
2. You want everything under
http://yourservername.domain/YourServletName to go to your servlet.
3. And probably another few things,
Hopefully this will help you in the right direction ...
Paul
On Sun, 2003-03-23 at 18:53, Jeff Brewer wrote:
> I've spent DAYS and DAYS and DAYS trying to get tomcat to run servlets. Nothing I try works. I have followed the instructions in three books, several online tutorials and attempted to decipher tomcat documentation on the apache site. I've installed and reinstalled two versions to Tomcat (currently on 4.1.24). I've modified server.xml and web.xml files until my fingers are sore from typing. Any help would be GREATLY appreciated. Nothing helps; nothing works except the tomcat examples which mock me!
>
> Here is my problem:
>
> >From a clean install of tomcat, create a new directory under webapps called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
>
> Copy the file "HelloWorldExample.class" from "webapps/examples/WEB-INF/classes" and paste it into "webapps/dumfries/WEB-INF/classes"
>
> Create the following file and save as "web.xml" in the "webapps/dumfries/WEB-INF" directory:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
> <servlet>
> <servlet-name>HelloWorldExample</servlet-name>
> <servlet-class>HelloWorldExample</servlet-class>
> </servlet>
> <web-app>
> </web-app>
>
> Add the following tag to the server.xml file:
>
> <Context path="/dumfries" docBase="dumfries" debug="0" reloadable="true" />
>
> Start the server and browse to "http://localhost:8080/examples/servlet/HelloWorldExample"
> Note that the page displays.
>
> Now browse to "http://localhost:8080/dumfries/servlet/HelloWorldExample" and behold the error message.
>
> What am I doing wrong!!!! How can I make this work??? I'm supposed to be half way done with my project and I can't get my first servlet to work!!! Help!
--
p niemandt <ma...@acesurfer.co.za>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help with Servlets
Posted by Jeff Brewer <je...@3brewers.org>.
Thank you very much.
I did just try that and it didn't help, but perhaps it's only one of many
things I have wrong.
Thanks.
----- Original Message -----
From: "Kaarle Kaila" <ka...@iki.fi>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Sunday, March 23, 2003 1:59 PM
Subject: Re: Help with Servlets
> At 13:53 23.3.2003 -0500, you wrote:
> >I've spent DAYS and DAYS and DAYS trying to get tomcat to run servlets.
> >Nothing I try works. I have followed the instructions in three books,
> >several online tutorials and attempted to decipher tomcat documentation
on
> >the apache site. I've installed and reinstalled two versions to Tomcat
> >(currently on 4.1.24). I've modified server.xml and web.xml files until
my
> >fingers are sore from typing. Any help would be GREATLY appreciated.
> >Nothing helps; nothing works except the tomcat examples which mock me!
>
> You need also something like
>
> <servlet-mapping>
> <servlet-name>HelloWorldExample</servlet-name>
> <url-pattern>/mytest</url-pattern>
> </servlet-mapping>
>
> in your web.xml
>
> Kaarle
>
>
> >Here is my problem:
> >
> > >From a clean install of tomcat, create a new directory under webapps
> > called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
> >
> >Copy the file "HelloWorldExample.class" from
> >"webapps/examples/WEB-INF/classes" and paste it into
> >"webapps/dumfries/WEB-INF/classes"
> >
> >Create the following file and save as "web.xml" in the
> >"webapps/dumfries/WEB-INF" directory:
> >
> ><?xml version="1.0" encoding="ISO-8859-1"?>
> >
> ><!DOCTYPE web-app
> >PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> >"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
> ><servlet>
> ><servlet-name>HelloWorldExample</servlet-name>
> ><servlet-class>HelloWorldExample</servlet-class>
> ></servlet>
> ><web-app>
> ></web-app>
> >
> >Add the following tag to the server.xml file:
> >
> ><Context path="/dumfries" docBase="dumfries" debug="0" reloadable="true"
/>
> >
> >Start the server and browse to
> >"http://localhost:8080/examples/servlet/HelloWorldExample"
> >Note that the page displays.
> >
> >Now browse to "http://localhost:8080/dumfries/servlet/HelloWorldExample"
> >and behold the error message.
> >
> >What am I doing wrong!!!! How can I make this work??? I'm supposed to be
> >half way done with my project and I can't get my first servlet to work!!!
Help!
>
> ---------------------------------------------
> Kaarle Kaila
> http://www.iki.fi/kaila
> mailto:kaarle.kaila@iki.fi
> tel: +358 50 3725844
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help with Servlets
Posted by Kaarle Kaila <ka...@iki.fi>.
At 13:53 23.3.2003 -0500, you wrote:
>I've spent DAYS and DAYS and DAYS trying to get tomcat to run servlets.
>Nothing I try works. I have followed the instructions in three books,
>several online tutorials and attempted to decipher tomcat documentation on
>the apache site. I've installed and reinstalled two versions to Tomcat
>(currently on 4.1.24). I've modified server.xml and web.xml files until my
>fingers are sore from typing. Any help would be GREATLY appreciated.
>Nothing helps; nothing works except the tomcat examples which mock me!
You need also something like
<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/mytest</url-pattern>
</servlet-mapping>
in your web.xml
Kaarle
>Here is my problem:
>
> >From a clean install of tomcat, create a new directory under webapps
> called "dumfries". Create subdirectories dumfries/WEB-INF/classes.
>
>Copy the file "HelloWorldExample.class" from
>"webapps/examples/WEB-INF/classes" and paste it into
>"webapps/dumfries/WEB-INF/classes"
>
>Create the following file and save as "web.xml" in the
>"webapps/dumfries/WEB-INF" directory:
>
><?xml version="1.0" encoding="ISO-8859-1"?>
>
><!DOCTYPE web-app
>PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
><servlet>
><servlet-name>HelloWorldExample</servlet-name>
><servlet-class>HelloWorldExample</servlet-class>
></servlet>
><web-app>
></web-app>
>
>Add the following tag to the server.xml file:
>
><Context path="/dumfries" docBase="dumfries" debug="0" reloadable="true" />
>
>Start the server and browse to
>"http://localhost:8080/examples/servlet/HelloWorldExample"
>Note that the page displays.
>
>Now browse to "http://localhost:8080/dumfries/servlet/HelloWorldExample"
>and behold the error message.
>
>What am I doing wrong!!!! How can I make this work??? I'm supposed to be
>half way done with my project and I can't get my first servlet to work!!! Help!
---------------------------------------------
Kaarle Kaila
http://www.iki.fi/kaila
mailto:kaarle.kaila@iki.fi
tel: +358 50 3725844
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org