From tomcat-user-return-97288-apmail-jakarta-tomcat-user-archive=jakarta.apache.org@jakarta.apache.org Fri Apr 02 17:19:23 2004 Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 53311 invoked from network); 2 Apr 2004 17:19:23 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Apr 2004 17:19:23 -0000 Received: (qmail 9487 invoked by uid 500); 2 Apr 2004 17:18:53 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 9474 invoked by uid 500); 2 Apr 2004 17:18:53 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 9460 invoked from network); 2 Apr 2004 17:18:53 -0000 Received: from unknown (HELO web60609.mail.yahoo.com) (216.109.119.83) by daedalus.apache.org with SMTP; 2 Apr 2004 17:18:53 -0000 Message-ID: <20040402171854.78815.qmail@web60609.mail.yahoo.com> Received: from [24.13.42.178] by web60609.mail.yahoo.com via HTTP; Fri, 02 Apr 2004 09:18:54 PST Date: Fri, 2 Apr 2004 09:18:54 -0800 (PST) From: Lisa Simaki Subject: Virtual Hosts Kill My JSPs To: tomcat-user@jakarta.apache.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi, Thought I'd try again.... :) We are using Tomcat v5.0.19 as a stand-alone server, with the Coyote HTTP 1.1 Connector, on Windows 2000. We have Tomcat configured with two virtual hosts (i.e., two elements). The virtual hosting is working great except for a problem with identically named JSPs across hosts: NUTSHELL -------- In a nutshell, when Tomcat translates a JSP into a servlet, it is *NOT* taking into account which the JSP belongs to. It translates the JSP into a servlet and dumps the resulting Java source code in the same directory, regardless of what the JSP came from. This causes a big problem if the different hosts have a JSP that happens to be the same name, like, say, index.jsp. Since the generated Java code (index_jsp.java) is dumped into the same directory, regardless of which the JSP originated from, Tomcat will serve the index.jsp that got translated first. So, both hosts end up sharing the same index.jsp. MORE SPECIFICS (More Details) -------------- In my server.xml I have two 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" attributes of the 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 separate directory to store compiled JSPs. As I mentioned, Tomcat is not differentiating between hosts when it writes the Java source code (from the translated JSP) to this directory. It's simply 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 identically named JSPs from different hosts do not over-write each other. 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: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org