Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 39199 invoked from network); 16 May 2003 09:38:33 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 16 May 2003 09:38:33 -0000 Received: (qmail 28384 invoked by uid 97); 16 May 2003 09:40:52 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 28377 invoked from network); 16 May 2003 09:40:52 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 16 May 2003 09:40:52 -0000 Received: (qmail 37787 invoked by uid 500); 16 May 2003 09:38:16 -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 37774 invoked from network); 16 May 2003 09:38:16 -0000 Received: from smarthost1.mail.uk.easynet.net (212.135.6.11) by daedalus.apache.org with SMTP; 16 May 2003 09:38:16 -0000 Received: from mail.datapro.co.uk ([212.74.18.17] helo=will.datapro.co.uk) by smarthost1.mail.uk.easynet.net with esmtp (Exim 4.10) id 19GbeC-000Mhu-00 for tomcat-user@jakarta.apache.org; Fri, 16 May 2003 10:37:04 +0100 Message-Id: <5.1.1.6.0.20030516102901.03ac8ec8@10.0.0.1> X-Sender: will@10.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1.1 Date: Fri, 16 May 2003 10:35:05 +0100 To: "Tomcat Users List" From: William Wragg Subject: RE: Forward to JSP from Servlet In-Reply-To: References: Mime-Version: 1.0 Content-Type: multipart/mixed; x-avg-checked=avg-ok-EFB6A3C; boundary="=======7E422979=======" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --=======7E422979======= Content-Type: text/plain; x-avg-checked=avg-ok-EFB6A3C; charset=us-ascii; format=flowed Content-Transfer-Encoding: 8bit Something you might try that is somewhere in between the two you suggested is to create a webapp called resources (or something similar) which contains all your images etc. Then hard code this webapp's path into the IMG tag. This way you could still rename your webapps without having to go through all the JSPs making changes. But the resources webapp will always have to be called the same thing. Regards, Wm. At 11:21 16/05/2003, you wrote: >Right you are. Thanks. > >What is the suggested alternative ? I would like to make everything relative >(to something). I have come up with 2 solutions. > >1. Hard code the name of my web app into the jsp pages. > ie > > not really a good idea in my opinion since as soon as you change the > name of the web app you have to go through all the JSPs and make changes. > >2. Get the servlet context within the JSP and prepend > that to the URL with the relative path based on the root for the web app. > ie "> > > Guaranteed to work all the time, but makes your JSPs harder to read. > > >Any other reccomendations ? > >BTW, I checked back on some of the code I wrote for Websphere just to make >sure I wasn't going crazy. I wasn't, it was written how I originally stated >(the resources were relative to the location of the JSP file). Am I right to >assume that this was a "feature" in the Websphere server, that does not >conform to the Java specs ? > > > > >-----Original Message----- >From: news [mailto:news@main.gmane.org]On Behalf Of Bill Barker >Sent: Thursday, May 15, 2003 8:36 PM >To: tomcat-user@jakarta.apache.org >Subject: Re: Forward to JSP from Servlet > > >Nope, the problem is that you are confusing the h*ll out of the browser. >The browser has no knowledge at all that you've done a forward, so it will >request relative links for things like stylesheets and images against the >URL that it sent. It doesn't know or care about the URL that you forwarded >to. > >You can stay with this design, but you'd have to make all of the references >to stylesheets and images absolute in your JSP page (e.g. src="/myapp/images/cool.jpg"> instead of ). > >"Daryl Handley" wrote in message >news:FNEJIOJHLIMDDBPLEEHBKEKDCAAA.darylhandley72@yahoo.com... > > Hi all, > > > > When I forward to a JSP from a servlet, my JSP page is unable to find the > > resources (stylesheets, images, ....)it needs to display the page >properly. > > The page comes up fine if I just type in the address of the JSP ... > > > > localhost/OnlineStore/jsp/index.jsp for example > > > > ... but if I forward to the page .... > > > > getsServletContext().getRequestDispatcher("/jsp/index.jsp").forward(req, > > res); > > > > ... it comes up with no stylesheets applied and none of my images are > > visible. > > > > I tried doing a res.sendRedirect and it worked fine (as I expected it >too). > > I don't really want to use sendRedirect unless I have to since it has it's > > own problems. > > > > I'm assuming this has something to do with the servlet that is compiled >from > > the jsp assuming the resources are going to be somewhere different, but >I'm > > not really sure. I'm fairly new to Tomcat, but I used to do these kinds of > > forwards all the time using Websphere with no problem. Maybe there is some > > setting somewhere that I need to adjust ? > > > > Tomcat is v4.1.24 > > > > > > TIA > > Daryl --=======7E422979======= Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-EFB6A3C Content-Disposition: inline --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.481 / Virus Database: 277 - Release Date: 13/05/2003 --=======7E422979======= Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org --=======7E422979=======--