Sorry,
I should have shown the <Host> elements:
<Host name="xxx.test2.com" debug="0"
appBase="C:\TestWebSites\test2"
unpackWARs="true" deployOnStartup='true'
autoDeploy="false">
<Context path="/" docBase="/" debug="0"
reloadable="false" />
</Host>
<Host name="xxx.test1.com" debug="0"
appBase="C:\TestWebSites\test1"
unpackWARs="true" deployOnStartup='true'
autoDeploy="false">
<Context path="/" docBase="/" debug="0"
reloadable="false" />
</Host>
----- Original Message -----
From: "Lisa Simaki" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 01, 2004 11:14 PM
Subject: Virtual Hosting Fails w/JSPs
> Hi,
>
> I'm very new with Tomcat (4 days) so I'm sorry if this
> might be a simple question. I've tracked down this
> problem to a certain point but now I'm at a loss. I
> guess my explanation got a bit long but I think it's
> clear....hope so.
>
> We are using Tomcat v5.0.19 as a stand-alone server,
> using the Coyote HTTP 1.1 Connector, on Windows 2000.
>
> In a nutshell, Tomcat is placing compiled JSPs (by
> that, I mean Java source code translated from JSPs and
> the resulting class files) in the same directory,
> regardless of what <Host> and/or <Context> those JSPs
> come from. This causes a big problem if different
> Hosts and/or Contexts specify a JSP that happens to be
> the same name, like, say, index.jsp. In this case, the
> wrong JSP is often served.
>
> Here is how we came on this problem....
>
>
> In my server.xml I have two <Host> elements
> configured. The "name" attribute of the first Host
> element is "xxx.test1.com" and the "name" attribute on
> the second Host is "xxx.text2.com". Of course, I also
> have the Windows "hosts" file set up so that both host
> names are associated with 127.0.0.1. In other words,
> the "hosts" file has entries for both xxx.test1.com
> and xxx.test2.com and they both point to 127.0.0.1.
>
> Both test1 and test2 have their own directories. In
> other words, both "appBase" attribute of the <Host>
> elements point to the directory appropriate to that
> host (xxx.test1.com or xxx.test2.com).
>
> I hope this is clear so far.
>
> With Tomcat running I can browse to either
> http://xxx.test1.com or http://xxx.test2.com and the
> correct page is served. Tomcat seems to be using
> virtual hosting just fine....except...
>
> If both test1 and test2 have a JSP with the same name
> (like, say, index.jsp), then there's confusion. The
> first index.jsp that gets compiled is the one that
> gets served for *BOTH* hosts. For example:
>
> Assume no JSPs are yet compiled.
> I go to http://xxx.test1.com/index.jsp, causing the
> test1's index.jsp to be compiled and rendered. That's
> expected. Now, go to http://xxx.test2.com/index.jsp
> -- the result is still test1's version of index.jsp!
>
> Now, if I modify test2's index.jsp and I go to
> http://xxx.test2.com/index.jsp I see what I expect --
> test2's JSP with the modification I just made. But now
> if I go to http://xxx.test1.com/index.jsp I also see
> test2's index.jsp, not test1's JSP!!!
>
> HERE'S WHY IT HAPPENS!
> ---------------------
> Now, I know, partially why this is happening. You know
> that Tomcat uses a temporary directory to store
> compiled JSPs. It turns out that it's putting *all*
> compiled JSPs into the same directory (WINNT/temp).
> Since both test1 and test2 have identically named
> "index.jsp" files, Tomcat does not distinguish them.
> In both cases it generates "index_jsp.java" as needed,
> overwriting the previous version. That is the crux of
> what's causing my grief.
>
> One would think Tomcat would build a directory
> structure reflective of the host name and contexts so
> that like named JSPs do not over-write each other like
> this.
>
> Can anyone offer any comments on this? Is anyone still
> reading at this point?
>
> Thanks,
>
> LS
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway
> http://promotions.yahoo.com/design_giveaway/
>
> ---------------------------------------------------------------
------
> To unsubscribe, e-mail:
[EMAIL PROTECTED]
> For additional commands, e-mail:
[EMAIL PROTECTED]
>
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]