You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tod Olson <to...@uchicago.edu> on 2011/09/18 19:37:49 UTC

Running two versions of servlet in same tomcat instance

I would like to run two versions of the same servlet (same servlet-class, but with different WAR filename, servlet-name and url-pattern) under a single instance of Tomcat 6.0.33.  Basically, the aim  is to run both test and production versions of the servlet under the same instance.  Better to run them under separate instances, but getting a suitable second instance is proving difficult.  I thought that the same servlet-class would be fine as long as the servlet-name and url-pattern were different, but does not seem to be enough.

The problem I encounter is that while the production version is deployed by Tomcat just fine, the test version is not loaded. The test version is unbundled in web apps directory and there is a deployment message in the catalina log, but when I point a web browser to the servlet, the result is just HTTP 404 error: "The requested resource (/testvsb/) is not available."  

I've been unable to find any kind of useful debugging clues in the catalina logs, like a servlet deployment or invocation error, but my knowledge of Tomcat is meagre.

The web.xml files for the two servlets are included below, in case they are of interest. The init-param sections are the same because I'm still testing out the two-servlets-in-one-tomcat concept on my laptop.

Any ideas or advice on how to proceed would be appreciated.

-Tod


Tod Olson <to...@uchicago.edu>
Systems Librarian     
University of Chicago Library


browse.war
browse/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

   <servlet>
     <servlet-name>Browse</servlet-name>
  	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
  	<init-param>
    	<param-name>vsiUrl</param-name>
    	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
    	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
    	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
   	</init-param>
     <init-param>
       <param-name>libraryName</param-name>
       <param-value>The University of Chicago Library</param-value>
     </init-param>
     <init-param>
       <param-name>libraryShortName</param-name>
       <param-value>UChicago</param-value>
     </init-param>
     <init-param>
       <param-name>catalogBaseUrl</param-name>
       <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
     </init-param>
     
   </servlet>
    
  <servlet-mapping>
    <servlet-name>Browse</servlet-name>
    <url-pattern>/browse/*</url-pattern>
  </servlet-mapping>
  
  <session-config>
    <session-timeout>
            30
        </session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>
            browse
        </welcome-file>
  </welcome-file-list>
 <error-page>
  	<exception-type>
  		java.lang.Exception
  	</exception-type>
  	<location>
  		/jsp/error.jsp
  	</location>
  </error-page>
</web-app>


testvsb.war:
testvsb/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

   <servlet>
     <servlet-name>TestVSB</servlet-name>
  	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
  	<init-param>
    	<param-name>vsiUrl</param-name>
    	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
    	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
    	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
   	</init-param>
     <init-param>
       <param-name>libraryName</param-name>
       <param-value>The University of Chicago Library</param-value>
     </init-param>
     <init-param>
       <param-name>libraryShortName</param-name>
       <param-value>UChicago</param-value>
     </init-param>
     <init-param>
       <param-name>catalogBaseUrl</param-name>
       <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
     </init-param>
     
   </servlet>
    
  <servlet-mapping>
    <servlet-name>TestVSB</servlet-name>
    <url-pattern>/testvsb/*</url-pattern>
  </servlet-mapping>
  
  <session-config>
    <session-timeout>
            30
        </session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>
            browse
        </welcome-file>
  </welcome-file-list>
 <error-page>
  	<exception-type>
  		java.lang.Exception
  	</exception-type>
  	<location>
  		/jsp/error.jsp
  	</location>
  </error-page>
</web-app>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running two versions of servlet in same tomcat instance

Posted by André Warnier <aw...@ice-sa.com>.
Actually, the explanation below was a bit approximative (late Sunday night thing).
It's not really "relative".
The formal explanation is given in the Servlet Specification, but it's more like this :

a) Tomcat uses the first path component of the URL, to map a request to a web application.
(in your case e.g. "/testvsb").
b) assuming that happened, it then strips this first component from the path, and uses the 
rest of the path to map the request to a servlet within the application, using the 
<url-mapping> elements for ditto (and the longest match wins).

If (a) did not find a matching webapp, then Tomcat maps the request to the default 
application (the one living under /webapps/ROOT/), does not subtract anything from the URL 
path, and uses the "rest" of the URL path to map the request to a servlet withing the 
default application, using the <url-mapping> elements for this.

In your case, it means that you should not have to change the <url-mapping> elements in 
the web.xml, because by the time these mappings are considered, the mapping to the webapp 
has already taken place, and the first path component has already been removed if needed be.

But you'd better go read how they really say this precisely in the Servlet Spec.



Tod Olson wrote:
> Aha, that fixes it.
> 
> Thanks for that explanation, I had completely missed that about the url-pattern being relative to the webapp.  I clearly need to un-confuse myself about servlet-mapping.
> 
> Thank you!
> 
> -Tod
> 
> On Sep 18, 2011, at 2:19 PM, André Warnier wrote:
> 
>> Hi.
>>
>> Change the <url-pattern> of your test application, to be exactly the same as the 
>> <url-pattern> of the production application.
>>
>> And invoke it as "http://yourhost.cpy.com/testvsb/", followed by the same "rest of URL" as 
>> what you use for the main application.
>>
>> Brief explanation : the <url-pattern> is *relative* to the "webapp name".  The "webapp 
>> name" is the name of your application's directory (in other words, the name of the first 
>> directory level under (tomcat_dir)/webapps/).
>>
>> .. Except one special case : the "default application" lives under the path 
>> (tomcat_dir)/webapps/ROOT/ (in capitals), but its "webapp name" is "/".
>>
>> If the above does not work, then show us how the directory structure under 
>> (tomcat_dir)/webapps/ looks like, and which URL you use to access the production application.
>>
>>
>>
>> Tod Olson wrote:
>>> I would like to run two versions of the same servlet (same servlet-class, but with different WAR filename, servlet-name and url-pattern) under a single instance of Tomcat 6.0.33.  Basically, the aim  is to run both test and production versions of the servlet under the same instance.  Better to run them under separate instances, but getting a suitable second instance is proving difficult.  I thought that the same servlet-class would be fine as long as the servlet-name and url-pattern were different, but does not seem to be enough.
>>>
>>> The problem I encounter is that while the production version is deployed by Tomcat just fine, the test version is not loaded. The test version is unbundled in web apps directory and there is a deployment message in the catalina log, but when I point a web browser to the servlet, the result is just HTTP 404 error: "The requested resource (/testvsb/) is not available."  
>>>
>>> I've been unable to find any kind of useful debugging clues in the catalina logs, like a servlet deployment or invocation error, but my knowledge of Tomcat is meagre.
>>>
>>> The web.xml files for the two servlets are included below, in case they are of interest. The init-param sections are the same because I'm still testing out the two-servlets-in-one-tomcat concept on my laptop.
>>>
>>> Any ideas or advice on how to proceed would be appreciated.
>>>
>>> -Tod
>>>
>>>
>>> Tod Olson <to...@uchicago.edu>
>>> Systems Librarian     
>>> University of Chicago Library
>>>
>>>
>>> browse.war
>>> browse/WEB-INF/web.xml
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>>>
>>>   <servlet>
>>>     <servlet-name>Browse</servlet-name>
>>>  	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
>>>  	<init-param>
>>>    	<param-name>vsiUrl</param-name>
>>>    	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
>>>    	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
>>>    	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
>>>   	</init-param>
>>>     <init-param>
>>>       <param-name>libraryName</param-name>
>>>       <param-value>The University of Chicago Library</param-value>
>>>     </init-param>
>>>     <init-param>
>>>       <param-name>libraryShortName</param-name>
>>>       <param-value>UChicago</param-value>
>>>     </init-param>
>>>     <init-param>
>>>       <param-name>catalogBaseUrl</param-name>
>>>       <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
>>>     </init-param>
>>>
>>>   </servlet>
>>>
>>>  <servlet-mapping>
>>>    <servlet-name>Browse</servlet-name>
>>>    <url-pattern>/browse/*</url-pattern>
>>>  </servlet-mapping>
>>>
>>>  <session-config>
>>>    <session-timeout>
>>>            30
>>>        </session-timeout>
>>>  </session-config>
>>>  <welcome-file-list>
>>>    <welcome-file>
>>>            browse
>>>        </welcome-file>
>>>  </welcome-file-list>
>>> <error-page>
>>>  	<exception-type>
>>>  		java.lang.Exception
>>>  	</exception-type>
>>>  	<location>
>>>  		/jsp/error.jsp
>>>  	</location>
>>>  </error-page>
>>> </web-app>
>>>
>>>
>>> testvsb.war:
>>> testvsb/WEB-INF/web.xml
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>>>
>>>   <servlet>
>>>     <servlet-name>TestVSB</servlet-name>
>>>  	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
>>>  	<init-param>
>>>    	<param-name>vsiUrl</param-name>
>>>    	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
>>>    	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
>>>    	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
>>>   	</init-param>
>>>     <init-param>
>>>       <param-name>libraryName</param-name>
>>>       <param-value>The University of Chicago Library</param-value>
>>>     </init-param>
>>>     <init-param>
>>>       <param-name>libraryShortName</param-name>
>>>       <param-value>UChicago</param-value>
>>>     </init-param>
>>>     <init-param>
>>>       <param-name>catalogBaseUrl</param-name>
>>>       <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
>>>     </init-param>
>>>
>>>   </servlet>
>>>
>>>  <servlet-mapping>
>>>    <servlet-name>TestVSB</servlet-name>
>>>    <url-pattern>/testvsb/*</url-pattern>
>>>  </servlet-mapping>
>>>
>>>  <session-config>
>>>    <session-timeout>
>>>            30
>>>        </session-timeout>
>>>  </session-config>
>>>  <welcome-file-list>
>>>    <welcome-file>
>>>            browse
>>>        </welcome-file>
>>>  </welcome-file-list>
>>> <error-page>
>>>  	<exception-type>
>>>  		java.lang.Exception
>>>  	</exception-type>
>>>  	<location>
>>>  		/jsp/error.jsp
>>>  	</location>
>>>  </error-page>
>>> </web-app>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running two versions of servlet in same tomcat instance

Posted by Tod Olson <to...@uchicago.edu>.
Aha, that fixes it.

Thanks for that explanation, I had completely missed that about the url-pattern being relative to the webapp.  I clearly need to un-confuse myself about servlet-mapping.

Thank you!

-Tod

On Sep 18, 2011, at 2:19 PM, André Warnier wrote:

> Hi.
> 
> Change the <url-pattern> of your test application, to be exactly the same as the 
> <url-pattern> of the production application.
> 
> And invoke it as "http://yourhost.cpy.com/testvsb/", followed by the same "rest of URL" as 
> what you use for the main application.
> 
> Brief explanation : the <url-pattern> is *relative* to the "webapp name".  The "webapp 
> name" is the name of your application's directory (in other words, the name of the first 
> directory level under (tomcat_dir)/webapps/).
> 
> .. Except one special case : the "default application" lives under the path 
> (tomcat_dir)/webapps/ROOT/ (in capitals), but its "webapp name" is "/".
> 
> If the above does not work, then show us how the directory structure under 
> (tomcat_dir)/webapps/ looks like, and which URL you use to access the production application.
> 
> 
> 
> Tod Olson wrote:
>> I would like to run two versions of the same servlet (same servlet-class, but with different WAR filename, servlet-name and url-pattern) under a single instance of Tomcat 6.0.33.  Basically, the aim  is to run both test and production versions of the servlet under the same instance.  Better to run them under separate instances, but getting a suitable second instance is proving difficult.  I thought that the same servlet-class would be fine as long as the servlet-name and url-pattern were different, but does not seem to be enough.
>> 
>> The problem I encounter is that while the production version is deployed by Tomcat just fine, the test version is not loaded. The test version is unbundled in web apps directory and there is a deployment message in the catalina log, but when I point a web browser to the servlet, the result is just HTTP 404 error: "The requested resource (/testvsb/) is not available."  
>> 
>> I've been unable to find any kind of useful debugging clues in the catalina logs, like a servlet deployment or invocation error, but my knowledge of Tomcat is meagre.
>> 
>> The web.xml files for the two servlets are included below, in case they are of interest. The init-param sections are the same because I'm still testing out the two-servlets-in-one-tomcat concept on my laptop.
>> 
>> Any ideas or advice on how to proceed would be appreciated.
>> 
>> -Tod
>> 
>> 
>> Tod Olson <to...@uchicago.edu>
>> Systems Librarian     
>> University of Chicago Library
>> 
>> 
>> browse.war
>> browse/WEB-INF/web.xml
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>> 
>>   <servlet>
>>     <servlet-name>Browse</servlet-name>
>>  	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
>>  	<init-param>
>>    	<param-name>vsiUrl</param-name>
>>    	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
>>    	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
>>    	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
>>   	</init-param>
>>     <init-param>
>>       <param-name>libraryName</param-name>
>>       <param-value>The University of Chicago Library</param-value>
>>     </init-param>
>>     <init-param>
>>       <param-name>libraryShortName</param-name>
>>       <param-value>UChicago</param-value>
>>     </init-param>
>>     <init-param>
>>       <param-name>catalogBaseUrl</param-name>
>>       <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
>>     </init-param>
>> 
>>   </servlet>
>> 
>>  <servlet-mapping>
>>    <servlet-name>Browse</servlet-name>
>>    <url-pattern>/browse/*</url-pattern>
>>  </servlet-mapping>
>> 
>>  <session-config>
>>    <session-timeout>
>>            30
>>        </session-timeout>
>>  </session-config>
>>  <welcome-file-list>
>>    <welcome-file>
>>            browse
>>        </welcome-file>
>>  </welcome-file-list>
>> <error-page>
>>  	<exception-type>
>>  		java.lang.Exception
>>  	</exception-type>
>>  	<location>
>>  		/jsp/error.jsp
>>  	</location>
>>  </error-page>
>> </web-app>
>> 
>> 
>> testvsb.war:
>> testvsb/WEB-INF/web.xml
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>> 
>>   <servlet>
>>     <servlet-name>TestVSB</servlet-name>
>>  	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
>>  	<init-param>
>>    	<param-name>vsiUrl</param-name>
>>    	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
>>    	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
>>    	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
>>   	</init-param>
>>     <init-param>
>>       <param-name>libraryName</param-name>
>>       <param-value>The University of Chicago Library</param-value>
>>     </init-param>
>>     <init-param>
>>       <param-name>libraryShortName</param-name>
>>       <param-value>UChicago</param-value>
>>     </init-param>
>>     <init-param>
>>       <param-name>catalogBaseUrl</param-name>
>>       <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
>>     </init-param>
>> 
>>   </servlet>
>> 
>>  <servlet-mapping>
>>    <servlet-name>TestVSB</servlet-name>
>>    <url-pattern>/testvsb/*</url-pattern>
>>  </servlet-mapping>
>> 
>>  <session-config>
>>    <session-timeout>
>>            30
>>        </session-timeout>
>>  </session-config>
>>  <welcome-file-list>
>>    <welcome-file>
>>            browse
>>        </welcome-file>
>>  </welcome-file-list>
>> <error-page>
>>  	<exception-type>
>>  		java.lang.Exception
>>  	</exception-type>
>>  	<location>
>>  		/jsp/error.jsp
>>  	</location>
>>  </error-page>
>> </web-app>
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running two versions of servlet in same tomcat instance

Posted by André Warnier <aw...@ice-sa.com>.
Hi.

Change the <url-pattern> of your test application, to be exactly the same as the 
<url-pattern> of the production application.

And invoke it as "http://yourhost.cpy.com/testvsb/", followed by the same "rest of URL" as 
what you use for the main application.

Brief explanation : the <url-pattern> is *relative* to the "webapp name".  The "webapp 
name" is the name of your application's directory (in other words, the name of the first 
directory level under (tomcat_dir)/webapps/).

.. Except one special case : the "default application" lives under the path 
(tomcat_dir)/webapps/ROOT/ (in capitals), but its "webapp name" is "/".

If the above does not work, then show us how the directory structure under 
(tomcat_dir)/webapps/ looks like, and which URL you use to access the production application.



Tod Olson wrote:
> I would like to run two versions of the same servlet (same servlet-class, but with different WAR filename, servlet-name and url-pattern) under a single instance of Tomcat 6.0.33.  Basically, the aim  is to run both test and production versions of the servlet under the same instance.  Better to run them under separate instances, but getting a suitable second instance is proving difficult.  I thought that the same servlet-class would be fine as long as the servlet-name and url-pattern were different, but does not seem to be enough.
> 
> The problem I encounter is that while the production version is deployed by Tomcat just fine, the test version is not loaded. The test version is unbundled in web apps directory and there is a deployment message in the catalina log, but when I point a web browser to the servlet, the result is just HTTP 404 error: "The requested resource (/testvsb/) is not available."  
> 
> I've been unable to find any kind of useful debugging clues in the catalina logs, like a servlet deployment or invocation error, but my knowledge of Tomcat is meagre.
> 
> The web.xml files for the two servlets are included below, in case they are of interest. The init-param sections are the same because I'm still testing out the two-servlets-in-one-tomcat concept on my laptop.
> 
> Any ideas or advice on how to proceed would be appreciated.
> 
> -Tod
> 
> 
> Tod Olson <to...@uchicago.edu>
> Systems Librarian     
> University of Chicago Library
> 
> 
> browse.war
> browse/WEB-INF/web.xml
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> 
>    <servlet>
>      <servlet-name>Browse</servlet-name>
>   	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
>   	<init-param>
>     	<param-name>vsiUrl</param-name>
>     	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
>     	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
>     	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
>    	</init-param>
>      <init-param>
>        <param-name>libraryName</param-name>
>        <param-value>The University of Chicago Library</param-value>
>      </init-param>
>      <init-param>
>        <param-name>libraryShortName</param-name>
>        <param-value>UChicago</param-value>
>      </init-param>
>      <init-param>
>        <param-name>catalogBaseUrl</param-name>
>        <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
>      </init-param>
>      
>    </servlet>
>     
>   <servlet-mapping>
>     <servlet-name>Browse</servlet-name>
>     <url-pattern>/browse/*</url-pattern>
>   </servlet-mapping>
>   
>   <session-config>
>     <session-timeout>
>             30
>         </session-timeout>
>   </session-config>
>   <welcome-file-list>
>     <welcome-file>
>             browse
>         </welcome-file>
>   </welcome-file-list>
>  <error-page>
>   	<exception-type>
>   		java.lang.Exception
>   	</exception-type>
>   	<location>
>   		/jsp/error.jsp
>   	</location>
>   </error-page>
> </web-app>
> 
> 
> testvsb.war:
> testvsb/WEB-INF/web.xml
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> 
>    <servlet>
>      <servlet-name>TestVSB</servlet-name>
>   	<servlet-class>edu.ncsu.lib.browse.Browse</servlet-class>
>   	<init-param>
>     	<param-name>vsiUrl</param-name>
>     	<param-value>http://localhost/~tod/virtualshelfindex/handler/</param-value>
>     	<!-- <param-value>http://your.url.here/virtualshelfindex/</param-value> -->
>     	<!-- <param-value>http://webdev.lib.ncsu.edu/virtualshelfindex/</param-value>  -->
>    	</init-param>
>      <init-param>
>        <param-name>libraryName</param-name>
>        <param-value>The University of Chicago Library</param-value>
>      </init-param>
>      <init-param>
>        <param-name>libraryShortName</param-name>
>        <param-value>UChicago</param-value>
>      </init-param>
>      <init-param>
>        <param-name>catalogBaseUrl</param-name>
>        <param-value>http://notus.lib.uchicago.edu/staging/</param-value>
>      </init-param>
>      
>    </servlet>
>     
>   <servlet-mapping>
>     <servlet-name>TestVSB</servlet-name>
>     <url-pattern>/testvsb/*</url-pattern>
>   </servlet-mapping>
>   
>   <session-config>
>     <session-timeout>
>             30
>         </session-timeout>
>   </session-config>
>   <welcome-file-list>
>     <welcome-file>
>             browse
>         </welcome-file>
>   </welcome-file-list>
>  <error-page>
>   	<exception-type>
>   		java.lang.Exception
>   	</exception-type>
>   	<location>
>   		/jsp/error.jsp
>   	</location>
>   </error-page>
> </web-app>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running two versions of servlet in same tomcat instance

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tod,

On 9/18/2011 1:37 PM, Tod Olson wrote:
> I would like to run two versions of the same servlet (same 
> servlet-class, but with different WAR filename, servlet-name and 
> url-pattern) under a single instance of Tomcat 6.0.33.

Your nomenclature is wrong. From what you are saying, you want to
deploy the same webapp twice in the same container.

> Basically, the aim is to run both test and production versions of
> the servlet under the same instance.

Uh, I would highly recommend against that for two obvious reasons:
security and performance. Having said that...

> Better to run them under separate instances, but getting a
> suitable second instance is proving difficult.

Get an EC2 instance. They're cheap.

> I thought that the same servlet-class would be fine as long as the 
> servlet-name and url-pattern were different, but does not seem to
> be enough.

Don't try to mess around with web.xml: do this through webapp deployment.

Glad to see you got it working with Andre's help.

I would caution you about using nested context paths (i.e. /foo for a
production servlet URL and /test/foo for test) because you will get
overlapping JSESSIONID cookie paths (one for '/' and one for '/test').
This can cause all kinds of confusion, even if you are the only one
doing it (presumably customers aren't using 'test' on a regular basis).

There's another reason to deploy production to, say, '/prod': it will
force you to ensure that all your links are prefixed and encoded
properly. If you have one URL that is not properly prefixed, then
users of '/test' will suddenly end up in the production environment
(possibly unauthenticated) and confusion will ensue.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk53nSQACgkQ9CaO5/Lv0PA5mwCgm4pEEK7LdPZZzFXLeO6/m33j
w9AAmwSwrNVUkPXAiftKAOvX7N4DQQHB
=Ng81
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org