tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yansheng Lin" <yansheng....@silvacom.com>
Subject RE: Newbie problem with JSP contexts & virtual hosts
Date Wed, 14 Apr 2004 22:00:25 GMT
Hi, that looks ok to me.  You can specify as many servlets as you want to
map/handle various type of patterns.  But I don't quite understand what you
mean by "having a new instance of JspServlet with each host is a overhead".
Because that's probably something you want anyways.  

-Yan

-----Original Message-----
From: James Bucanek [mailto:subscriber@gloaming.com] 
Sent: April 13, 2004 00:07
To: Tomcat Users List
Subject: Re: Newbie problem with JSP contexts & virtual hosts


While I didn't get any suggestions or feedback on my original question, I
believe I've found a solution.  Now I just need to run it by the group to
see if it's "Kosher."

James Bucanek wrote on Sunday, April 11, 2004:
>  <!-- Virtual host: www.hotelmidnight.net -->
>  <!-- (jlb 11-April-2004) Added virtual host -->
>  <Host name="www.hotelmidnight.net" debug="0"
appBase="/Users/darkthirty/Sites"
>        unpackWARs="false" autoDeploy="true">
>
>    <!-- Context for the top-level web application -->
>    <Context path="" docBase="." debug="99" reloadable="true"/>
>    
>  </Host>

<clip>

>    <web-app>
>        <display-name>darkthirty</display-name>
>        <description>darkthirty.net artwork application</description>
>    
>        <!-- Global parameters for this web application -->
>        <context-param>
>            <param-name>test</param-name>
>            <param-value>Some Value</param-value>
>        </context-param>
>    </web-app>

The basic problem with this arrangement is that my JSP pages ran in the
context of the 'jsp' <servlet> that's defined in
${CATALINA_HOME}/conf/web.xml for the default <Host>, not the Context that I
defined in my web-app that I want to run in my virtual <Host>.

So, it occurred to me that I could create may own instance of the JSP engine
as my <Servlet>.  Now that I have a <Servlet> to reference, I can then map
all of the *.jsp files in my virtual host to that:

    <web-app>
        <display-name>darkthirty</display-name>
        <description>darkthirty.net artwork application</description>
    
        <!-- Global parameters available to all web applications -->
        <context-param>
            <param-name>test</param-name>
            <param-value>Some Value</param-value>
        </context-param>
    
        <servlet>
            <servlet-name>jsp2</servlet-name>
 
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
            <init-param>
                <param-name>logVerbosityLevel</param-name>
                <param-value>INFORMATION</param-value>
            </init-param>
        </servlet>
    
        <!-- The mapping for the JSP servlet -->
        <servlet-mapping>
            <servlet-name>jsp2</servlet-name>
            <url-pattern>*.jsp</url-pattern>
        </servlet-mapping>
    
    </web-app>

This seems to work just great.  The Manager sees my application (by name),
and all of the context parameters appear in my JSP pages.

As far as I can tell, there doesn't seem to be anything really "bad" about
this solution.  Except that I end up with a new instance of the JspServlet
for each virtual host, which is probably a tolerable amount of overhead.

My question is this: Is this the "right" way to accomplish this?

______________________________________________________
James Bucanek       <mailto:privatereply@gloaming.com>

---------------------------------------------------------------------
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


Mime
View raw message