tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Bucanek <subscri...@gloaming.com>
Subject Re: Newbie problem with JSP contexts & virtual hosts
Date Tue, 13 Apr 2004 06:07:11 GMT
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


Mime
View raw message