Hi,
the problem with relative URL's when using the forward-method of a
request-dispatcher is that the URL's have to be relative to the server-root and
not to the destination page's actual location
e.g. under weapps you have a images-, a JSP and the WEB-INF-directory where your
servlet resides. Now when your servlet forwards to a JSP-page via a
request-dispatcher an the JSP-page contains an image you have to use the URL:
../images/<image-used-in-the-page>
Georg
p niemandt schrieb:
> Thanks Jeff, Steve: Giving me a lot of ideas: Sadly I'm still running
> full speed into mud ...
>
> I have changed the image directory to reside under my WEB-INF folder, do
> I need to configure this in one of the xml files as well? ie.
> application web.xml, or server.xml or something?
>
> I have written a filter that does authentication: It serves the
> index.shtml file, but for some reason I have to specify it as
> WEB-INF\index.shtml to make it work ...
>
> snip ---
>
> if (!validated) {
> // Create the RequestDispatcher
> Globals.utility.Log(className,
> "doFilter:",
> "Forwarding to " + getHtmlResult, 5);
> RequestDispatcher rd = config.getServletContext().
> getRequestDispatcher( getHtmlResult );
> rd.forward( req, res );
> return ;
> }
>
> --- snip
>
> where getHtmlResult is a string I read from a xml file. To make it work
> I need to specify WEB-INF\index.shtml in my xml file.
>
> This then serves the html, but none of my stylesheets or images are
> displayed ...
>
> snip ---
>
> <link rel="stylesheet" type="text/css" href="style.css">
> <img src="images/logo.gif" alt="Home" width="142" height="60" border="0"
> hspace="0" vspace="0">
>
> --- snip
>
> On Mon, 2002-11-18 at 15:58, Steve Beech wrote:
> > Jeff's right. You're web app is in the folder /servlet so your images should
> > be in /servlet/images - of course I'm assuming you've got images on the
> > index.shtml page and these are the ones you can't see.
> > You only need the one web.xml file (in the WEB-INF folder for your web-app)
> > - a second under images is not required.
> >
> > STeve
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: 18 November 2002 15:33
> > To: Tomcat Users List
> > Subject: Re: Tomcat 4 StandAlone Web Server, Static HTML and Images
> >
> >
> > Looks like you're basically putting your images in its own web app. You
> > may need a WEB-INF directory and trivial web.xml file under the images
> > directory in order for Tomcat to like it as a web app (not sure though).
> > Then, I think your url for the image would be "/images/image.gif".
> >
> > Alternatively, you could move your images directory to be within your
> > servlet web app. Then, your url (from index.shtml) would be
> > "images/image.gif".
> >
> > HTH,
> > -Jeff
> >
> >
> >
> >
> >
> > p niemandt <[EMAIL PROTECTED]>
> > 11/18/02 09:35 AM
> > Please respond to "Tomcat Users List"
> >
> >
> > To: Tomcat Users List <[EMAIL PROTECTED]>
> > cc:
> > Subject: Tomcat 4 StandAlone Web Server, Static HTML and
> > Images
> >
> >
> > Hi Group: Please help ...
> >
> > I'm very new to servlets, though I do have a lot of programming
> > experience. My problem is that I can't seem to get images displayed
> > properly using Tomcat as the web server.
> >
> > I have a very simple layout ...
> >
> > webapps
> > /servlet
> > index.shtml
> > /WEB-INF -> My servlets and web.xml
> > /images
> > contains my images
> >
> > I manage to serve the index.shtml quite easily, my problem is that I
> > can't get the images displayed without specifying the whole url in the
> > form file:///dir/to/images/image.gif, and I think this is wrong.
> >
> > There is a lot of information regarding how to configure a web server to
> > display the images, and this I can do fine, but I would like to only run
> > Tomcat: My site is very small, and the latency in Tomcat would not
> > effect it. My question is in how to specify the url for the image in the
> > html,
> >
> > I have tried "image.gif", "/servlet/image.gif", "../image/image.gif",
> > "/servlet/../image/image.gif", etc, etc.
> >
> > Now I suspect I'm missing something very stupid, but sadly I have no
> > idea what. I do not want to code the image display, as far as I know,
> > Tomcat should be able to handle such a simple html site.
> >
> > My servlets work well, database connectivity and all, and the site works
> > well if I use apache as well, but how to do this without Apache is
> > currently beyond me.
> >
> > Any information or just hints in the correct direction would be greatly
> > appreciated.
> --
> p niemandt <[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>