Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 87773 invoked from network); 28 Oct 2006 12:46:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Oct 2006 12:46:58 -0000 Received: (qmail 2101 invoked by uid 500); 28 Oct 2006 12:46:54 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 2087 invoked by uid 500); 28 Oct 2006 12:46:54 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 2075 invoked by uid 99); 28 Oct 2006 12:46:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Oct 2006 05:46:54 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [216.148.227.152] (HELO rwcrmhc12.comcast.net) (216.148.227.152) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Oct 2006 05:46:41 -0700 Received: from [192.168.1.47] (c-69-143-26-154.hsd1.va.comcast.net[69.143.26.154]) by comcast.net (rwcrmhc12) with ESMTP id <20061028124619m12000cjaee>; Sat, 28 Oct 2006 12:46:20 +0000 Message-ID: <4543518F.1060001@christopherschultz.net> Date: Sat, 28 Oct 2006 08:48:15 -0400 From: Christopher Schultz User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: CSS not being used when a Servlet is involved References: <7032844.post@talk.nabble.com> <45424853.7070606@cornell.edu> <7035535.post@talk.nabble.com> <7037029.post@talk.nabble.com> <7047719.post@talk.nabble.com> In-Reply-To: <7047719.post@talk.nabble.com> X-Enigmail-Version: 0.94.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig6C16292A2D030FAF37560159" X-Virus-Checked: Checked by ClamAV on apache.org --------------enig6C16292A2D030FAF37560159 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Robbert, > Hm, alright. Should all else fail, is it possible to let a Servlet hand= le > the CSS? You don't really want to do this. > I have four JSP pages (index, profile, statistics and gallery) that mus= t > invoke the StatistiekServlet. The page is simply a normal, static HTML = page > that calls the Servlet. Then the Servlet catches certain HTTP Headers a= nd > query strings and does stuff depending on the values. When the Servlet'= s > finished, the JSP continues spitting out HTML code. > And if I do that, it says "Resource not available: /StatistiekServlet" = for > whatever reason. Since you mentioned that you aren't very familiar with servlets, I'll go ahead and say the following. Sorry if it sounds patronizing. You have your process turned upside down, here. You are using a JSP as the target of the URL, then invoking a servlet from there to do your dirty work, and then going back. This is the wrong way to do things. What you really want to do is map "/index" to your StatistiekServlet, do whatever you need to do, and then do a "forward" (using the RequestDispatcher) to your JSP in order to generate the outgoing content.= I'm guessing that you have this separate servlet for several reasons: 1. You have shared code to execute. 2. Someone (correctly) told you that JSPs with tons of logic and Java code are ... icky? 3. You weren't sure how to re-use your servlet code and not have to inspect the URL to figure out to which JSP you should forward afterward. If you want to use shared code in a JSP (#1), you can simply put it in a utility class/method that takes the appropriate methods. You don't have to use the servlet mechanism and actually use a servlet to do this stuff.= The easiest way I can think of to "invert" your process (i.e. start with the servlet, /then/ forward to the JSP based upon the URL being used) is to use an application framework that helps you by mapping URLs to code and then lets you define forwards for that URL mapping. Struts is such a framework. You can set up mappings like this: Note that the code invoked is the same every time; only the "success" page changes. Your "servlet" code will have to turn into an "Action" (no big deal) and have a bit of code at the end to tell Struts to use the "success" forward (also not a big deal). But, if you really want to have a nicely separated MVC application, Struts can help tremendously. It looks like you have tried to take some of these steps yourself, but have gotten confused somewhere along the way -- ending up with your JSPs invoking your servlet, which feels /very/ weird to me. -chris --------------enig6C16292A2D030FAF37560159 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFQ1GP9CaO5/Lv0PARAuVtAKCh+Pw7nQw94CFqET7oFiyFpiLE9ACfeTEM Vb15q2J9HJ1znPUrXnjbJ84= =1HYP -----END PGP SIGNATURE----- --------------enig6C16292A2D030FAF37560159--