Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 3969 invoked from network); 9 Jul 2003 20:31:37 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 9 Jul 2003 20:31:37 -0000 Received: (qmail 3660 invoked by uid 97); 9 Jul 2003 20:34:08 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 3653 invoked from network); 9 Jul 2003 20:34:08 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 9 Jul 2003 20:34:08 -0000 Received: (qmail 2448 invoked by uid 500); 9 Jul 2003 20:31:19 -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 2421 invoked from network); 9 Jul 2003 20:31:18 -0000 Received: from unknown (HELO JTURNER) (207.86.123.243) by daedalus.apache.org with SMTP; 9 Jul 2003 20:31:18 -0000 Received: from JTURNER ([127.0.0.1]) by JTURNER with Microsoft SMTPSVC(5.0.2195.5329); Wed, 9 Jul 2003 16:31:22 -0400 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: setting up a root servlet / getting images to appear in Tomcat 4.1.24 References: <006901c3464f$110d2260$0401a8c0@laptop> <009701c34654$08bbabe0$0401a8c0@laptop> <009f01c34655$418beec0$0401a8c0@laptop> <00b301c34658$e466e200$0401a8c0@laptop> Message-ID: Content-Type: text/plain; charset=iso-8859-15; format=flowed From: John Turner Date: Wed, 09 Jul 2003 16:31:22 -0400 In-Reply-To: <00b301c34658$e466e200$0401a8c0@laptop> User-Agent: Opera7.03/Win32 M2 build 2670 X-OriginalArrivalTime: 09 Jul 2003 20:31:22.0858 (UTC) FILETIME=[0FDB74A0:01C34659] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N OK. I still don't get it, but I don't want to prolong the thread. Thanks for the info. John On Wed, 9 Jul 2003 16:30:08 -0400, Mark Biciunas wrote: > It became necessary only when we tried to create a servlet that is > accessed > without any path information (ie: www.mysite.com instead of > www.mysite.com/myservlet). Of course, if you have specified a static > html > page as the welcoming page to your site, you may never need to access a > servlet without a path. In our case, we have no static html, everything > is > generated on the fly with servlets, so we ran into the problem. > > Mark Biciunas > mark.biciunas@agorex.com > ----- Original Message ----- > From: "John Turner" > To: "Tomcat Users List" > Sent: Wednesday, July 09, 2003 4:18 PM > Subject: Re: setting up a root servlet / getting images to appear in > Tomcat > 4.1.24 > > >> >> I'm just trying to understand why it was necessary. >> >> Our apps have mixed content, and we did not have to configure things as >> you've described. >> >> John >> >> On Wed, 9 Jul 2003 16:04:06 -0400, Mark Biciunas > >> wrote: >> >> > As I understand it, the servlet will receive all requests other than >> > those >> > that have been re-routed through servlet-mappings. >> > >> > Just out of curiosity, do you see a problem with this approach? >> > >> > Mark Biciunas >> > Agorex Inc >> > (905) 274-6785 >> > mark.biciunas@agorex.com >> > ----- Original Message ----- >> > From: "John Turner" >> > To: "Tomcat Users List" >> > Sent: Wednesday, July 09, 2003 3:57 PM >> > Subject: Re: setting up a root servlet / getting images to appear in >> > Tomcat >> > 4.1.24 >> > >> > >> >> >> >> So you have a servlet that is intercepting all requests, other than >> >> image >> >> requests? >> >> >> >> John >> >> >> >> On Wed, 9 Jul 2003 15:55:21 -0400, Mark Biciunas >> > >> >> wrote: >> >> >> >> > Actually, the point of the article is to explain how NOT to deliver >> >> the >> >> > images via the servlet and to allow Tomcat to serve images normally >> - >> >> > something that doesn't happen if you are using a root context. >> >> > >> >> > It is only when you configure server.xml with a blank context path >> >> (ie: >> >> > ) that you run into >> >> this >> >> > problem. If you specify a path (ie: > >> > docBase="myservlet" debug="0"/> then the problem doesn't appear. >> >> > >> >> > Hope this helps, >> >> > >> >> > Mark Biciunas >> >> > mark.biciunas@agorex.com >> >> > ----- Original Message ----- >> >> > From: "John Turner" >> >> > To: "Tomcat Users List" >> >> > Sent: Wednesday, July 09, 2003 3:19 PM >> >> > Subject: Re: setting up a root servlet / getting images to appear >> in >> >> > Tomcat >> >> > 4.1.24 >> >> > >> >> > >> >> >> >> >> >> Just so I'm clear....you want to deliver the images via the >> servlet? >> >> >> I'm >> >> >> missing why you have to declare the MIME types of images at >> > all...Tomcat >> >> > is >> >> >> perfectly capable of serving them in a standard HTTP/1.1 manner >> >> without >> >> > any >> >> >> intervention from a servlet, and without any additional >> >> configuration. >> >> >> >> >> >> John >> >> >> >> >> >> On Wed, 9 Jul 2003 15:19:48 -0400, Mark Biciunas >> >> > >> >> >> wrote: >> >> >> >> >> >> > This email formally presents what I have learned over the past >> >> couple >> >> >> > days >> >> >> > about setting up a servlet to be accessed as root (ie: >> >> >> www.myservlet.com >> >> >> > instead of www.myservlet.com/somepath) without loosing access to >> >> >> images >> >> >> > and >> >> >> > other mime types. It is based primarily on advice received from >> >> Bill >> >> >> > Barker >> >> >> > and Stefan Radzom as well as the hints and suggestions of many >> > others. >> >> >> > As >> >> >> > you are looking at this solution, please bear in mind that I am > not >> > an >> >> >> > expert in Tomcat configuration and there is likely a lot of >> things >> >> I >> >> > have >> >> >> > missed. I welcome any additional advice / corrections people >> have >> >> to >> >> >> > offer. >> >> >> > >> >> >> > >> >> >> > Setting up a servlet to be accessed without a path (ie: >> >> >> > www.myservlet.com) >> >> >> > is fairly easy if you pay attention to a couple of extra steps. >> > First >> >> >> > this >> >> >> > is to deploy your application in the webapps directory as usual >> >> (ie: >> >> >> > webapps/myservlet). Next, update conf/servlet.xml so that you > have >> >> a >> >> >> > root >> >> >> > context that looks like: >> >> >> > >> >> >> > >> >> >> > >> >> >> > This will tell tomcat to serve ALL incoming requests to your >> >> servlet, >> >> >> > including requests for images, etc. If your servlet is not set >> up >> >> to >> >> >> > handle >> >> >> > mime types, then your images, etc. will seem to disappear. To > make >> >> >> sure >> >> >> > the >> >> >> > images, etc. are handled correctly, you need to map them out in >> >> your >> >> >> > WEB-INF/web.xml as follows: >> >> >> > >> >> >> > >> >> >> > myservlet >> >> >> > mypackage.MyServlet >> >> >> > >> >> >> > >> >> >> > >> >> >> > myservlet >> >> >> > / >> >> >> > >> >> >> > >> >> >> > >> >> >> > default >> >> >> > *.gif >> >> >> > >> >> >> > >> >> >> > >> >> >> > default >> >> >> > *.jpg >> >> >> > >> >> >> > >> >> >> > What is happining here in the first two sections is that you >> have >> >> >> > identified >> >> >> > the servlet class and mapping for your servlet. This is more or >> >> less >> >> > the >> >> >> > same as you would do for any servlet. If you do nothing more >> than >> >> >> this, >> >> >> > your servlet will (should) work, but you will not see any images >> > since >> >> >> > picture.gif would match to a url-pattern of "/" and get sent to >> >> your >> >> >> > servlet >> >> >> > for processing. >> >> >> > >> >> >> > In the second two sections, we are telling Tomcat that anything >> >> that >> >> >> > matches >> >> >> > a pattern of *.gif or *.jpg should be sent to the default >> servlet. >> >> >> Now >> >> >> > any >> >> >> > requests that match *.gif or *.jpg will be handled correctly. >> If >> >> you >> >> >> > need >> >> >> > to support more mime types, simply create more servlet mappings. >> >> >> > >> >> >> > Where did the default servlet come from? It is already >> configured >> >> in >> >> >> > conf/web.xml. Remember that conf/web.xml is automatically read >> > before >> >> >> > your >> >> >> > WEB-INF/web.xml so it can do it's thing without you having to >> >> worry >> >> >> > about >> >> >> > it at all. The trick is to use url-patterns to send requests >> back >> >> to >> >> > the >> >> >> > default servlet so that they don't end up in your servlet. >> >> >> > >> >> >> > The above solution will work great as long as you don't have to >> >> many >> >> > mime >> >> >> > types to deal with. If you need to handle lots of diferent >> types >> >> of >> >> >> > requests, then Bill Barker presented the following alternate >> >> solution >> >> >> > which >> >> >> > involves changing your servlet code to redirect requests: >> >> >> > >> >> >> > URL file = getServletContext().getResource(request.getPathInfo()) >> >> >> ; >> >> >> > if( file != null ) { // physical resource exists >> >> >> > RequestDispatcher rd = >> >> >> > getServletContext().getNamedDispatcher("default"); >> >> >> > rd.forward(request, response); >> >> >> > return; >> >> >> > } >> >> >> > // Your code here. >> >> >> > >> >> >> > I have not tried this solution so I do not know to much about >> it. >> >> It >> >> >> > seems >> >> >> > staightforward enough though, so I would expect it to work >> great. >> >> >> > >> >> >> > >> >> >> > Mark Biciunas >> >> >> > mark.biciunas@agorex.com >> >> >> > >> >> >> > >> >> >> >> -------------------------------------------------------------------- >> >> >> >> >> >> - >> >> >> > To unsubscribe, e-mail: tomcat-user- >> unsubscribe@jakarta.apache.org >> >> >> > For additional commands, e-mail: tomcat-user- >> >> help@jakarta.apache.org >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> Using M2, Opera's revolutionary e-mail client: >> >> http://www.opera.com/m2/ >> >> >> >> >> >>> --------------------------------------------------------------------- >> >> >> 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 >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Using M2, Opera's revolutionary e-mail client: >> http://www.opera.com/m2/ >> >> >> >> --------------------------------------------------------------------- >> >> 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 >> > >> > >> >> >> >> -- >> Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ >> >> --------------------------------------------------------------------- >> 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 > > -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org