tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mihai Gheorghiu" <tane...@earthlink.net>
Subject Re: Two servlets
Date Thu, 08 Nov 2001 16:19:11 GMT
Thanks, everybody.
I really appreciate your support :-)
Best regards,
Mihai Gheorghiu

-----Original Message-----
From: Craig R. McClanahan <craigmcc@apache.org>
To: Tomcat Users List <tomcat-user@jakarta.apache.org>
Date: Wednesday, November 07, 2001 7:16 PM
Subject: Re: Two servlets


>
>
>On Wed, 7 Nov 2001, Mihai Gheorghiu wrote:
>
>> Date: Wed, 7 Nov 2001 18:00:11 -0500
>> From: Mihai Gheorghiu <tanethq@earthlink.net>
>> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
>> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
>> Subject: Re: Two servlets
>>
>> Please excuse my ignorance. I did my best to try to understand Java
servlet
>> specification v2.2, and here you saw the result :-(
>> >From what you wrote and what I read there, it results that a servlet is
>> designed to listen to requests coming from one or more components (html
>> pages, applets) located in a path that is to be declared in
>> <servlet-mapping>.
>> My problem is: can I have more than one servlet to listen to requests
coming
>> from one source?
>> Thanks again for your patience.
>>
>
>The source doesn't matter ... only the destination.
>
>Consider the following web.xml file:
>
>  <web-app>
>
>    <servlet>
>      <servlet-name>first</servlet-name>
>      <servlet-class>com.mycompany.mypackage.MyFirstServlet</servlet-class>
>    </servlet>
>
>    <servlet>
>      <servlet-name>second</servlet-name>
>
<servlet-class>com.mycompany.mypackage.MySecondServlet</servlet-class>
>    </servlet>
>
>    <servlet-mapping>
>      <servlet-name>first</servlet-name>
>      <url-pattern>/a/*</url-pattern>
>    </servlet-mapping>
>
>    <servlet-mapping>
>      <servlet-name>second</servlet-name>
>      <url-pattern>/b/*</url-pattern>
>    </servlet-mapping>
>
>  </web-app>
>
>Now, assume this web app is installed at context path "/foo".  Tomcat will
>execute the following servlets based on the request URI that is submitted:
>
>  http://localhost:8080/foo/a  --> MyFirstServlet
>
>  http://localhost:8080/foo/b  --> MySecondServlet
>
>Basically, servlet mappings are a set of rules that tell the container how
>to choose the one (and only one) servlet to process this request.  You can
>have as many servlets as you like, attached to different mappings.  You
>can even have more than one mapping that points to the same servlet.  The
>only thing you cannot do is have more than one servlet for the same
>mapping -- because that would violate the "one and only one" rule.
>
>Craig McClanahan
>
>
>
>> -----Original Message-----
>> From: Randy Layman <randy.layman@aswethink.com>
>> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
>> Date: Wednesday, November 07, 2001 4:38 PM
>> Subject: RE: Two servlets
>>
>>
>> >
>> > It doesn't have to be servlets.  If you have your servlet listen to
>> >/servlets/da then any time the users/other pages ask for exactly
>> /servlet/da
>> >then the servlet will be run.  The reason to use /servlets/da/* is to
>> enable
>> >Path Information (accessed using the getPathInfo on the request object).
>> >Its useful when you don't want users to know what is the servlet and
what
>> is
>> >the parameter (i.e. creating a URL like /servlets/bob/filename and
having
>> >bob be the servlet name and filename being a parameter).
>> >
>> > Randy
>> >
>> >
>> >> -----Original Message-----
>> >> From: Mihai Gheorghiu [mailto:tanethq@earthlink.net]
>> >> Sent: Wednesday, November 07, 2001 2:56 PM
>> >> To: Tomcat Users List
>> >> Subject: Re: Two servlets
>> >>
>> >>
>> >> Thanks a lot.
>> >> In newbie's terms, create one folder per servlet and address them
>> >> accordingly?
>> >>
>> >> -----Original Message-----
>> >> From: Randy Layman <randy.layman@aswethink.com>
>> >> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
>> >> Date: Wednesday, November 07, 2001 2:38 PM
>> >> Subject: RE: Two servlets
>> >>
>> >>
>> >> >
>> >> > You are assigning both servlets to listen for the same URL (anything
>> >> >that starts with /servlets/*).  This can not happen - each URL can be
>> >> >serviced by at most one servlet (although the servlet can
>> >> pass control to
>> >> >other servlets).  You need to assign each servlet its own unique URL
>> >> pattern
>> >> >(i.e. /servlets/da/* and /servlets/title/*).
>> >> >
>> >> > Randy
>> >> >
>> >> >
>> >> >> -----Original Message-----
>> >> >> From: Mihai Gheorghiu [mailto:tanethq@earthlink.net]
>> >> >> Sent: Wednesday, November 07, 2001 2:32 PM
>> >> >> To: tomcat-user@jakarta.apache.org
>> >> >> Subject: Two servlets
>> >> >>
>> >> >>
>> >> >> I want to use two servlets from the same applet/web page, and
>> >> >> it does not
>> >> >> work. I'm doing something definitely wrong in web.xml, as
>> >> >> tomcat.log lists
>> >> >> (among others):
>> >> >> 2001-11-07 03:03:37 - Ctx( /development ): Removing duplicate
>> >> >> /servlet/* ->TitlesServlet(Sales.TitlesServlet/null)
>> >> >> The relevant web.xml part is:
>> >> >>  <servlet>
>> >> >>   <servlet-name>TitlesServlet</servlet-name>
>> >> >>   <servlet-class>Sales.TitlesServlet</servlet-class>
>> >> >>  </servlet>
>> >> >>  <servlet-mapping>
>> >> >>   <servlet-name>TitlesServlet</servlet-name>
>> >> >>   <url-pattern>/servlet/*</url-pattern>
>> >> >>  </servlet-mapping>
>> >> >>  <servlet>
>> >> >>   <servlet-name>DaServlet</servlet-name>
>> >> >>   <servlet-class>Sales.DaServlet</servlet-class>
>> >> >>  </servlet>
>> >> >>  <servlet-mapping>
>> >> >>   <servlet-name>DaServlet</servlet-name>
>> >> >>   <url-pattern>/servlet/*</url-pattern>
>> >> >>  </servlet-mapping>
>> >> >> How do I declare more than one servlet being used from one applet?
>> >> >> Thank you all.
>> >> >>
>> >> >>
>> >> >> --
>> >> >> To unsubscribe:
>> >> <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>> >> >> For additional commands:
>> >> <mailto:tomcat-user-help@jakarta.apache.org>
>> >> >> Troubles with the list:
>> >> <mailto:tomcat-user-owner@jakarta.apache.org>
>> >> >>
>> >> >
>> >> >--
>> >> >To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>> >> >For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>> >> >Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>> >> >
>> >>
>> >>
>> >> --
>> >> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>> >> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>> >> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>> >>
>> >
>> >--
>> >To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>> >For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>> >Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>> >
>>
>>
>> --
>> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>>
>>
>
>
>--
>To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message