In the Perl spirit that every easy problem should have a minimum of four equally valid solutions, he could also use the html BASE tag to set the relative URL for the rest of the document.
- Paul Copeland JOT Object Technologies http://www.jotobjects.com
Date: Sat, 13 Nov 2004 16:42:14 +0000 From: Nic Ferrier <[EMAIL PROTECTED]> Subject: Re: Dynamic image generation servlet...
Johan Hahn <[EMAIL PROTECTED]> writes:
Michael Burbidge wrote: [snip]
Note that the ImageServlet is registered to handle URI from the root context of the form "/image". I would think then that the URI in the the html snippet <img src='/image?name=imagename'> would get resolved by dispatching to my ImageServlet. But it doesn't work.
Try
<url-pattern>/image*</url-pattern>
It should work without explanaition.
I don't think that's the problem.
<url-patten>/image</url-pattern>
should match the url:
http://somehost/image?something=xxx
I think the poster may have got the context path mucked up. The request path he gave for calling his image directly was this:
http://localhost:8080/demo/image
which indicates that the webapp is mapped to /demo on localhost.
But he said he was putting the following in his HTML page:
<img src='/image?name=imagename'>
Well, that's never going to work because /image is not bound to anything.
Instead he should use:
<img src='/demo/image?name=imagename'/>
Or alternately use relative paths. If the HTML page is being served from, for example /demo/index.html then his HTML could be this:
<img src="image?name=imagename"/>
In a more advanced note: if relative paths are not possible then you can still make your HTML position portable by generating the link to the image in a servlet, eg:
out.println(request.getContextPath() + "/image?name=imagename");
-- Nic Ferrier http://www.tapsellferrier.co.uk
___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
------------------------------
End of SERVLET-INTEREST Digest - 12 Nov 2004 to 13 Nov 2004 (#2004-162) ***********************************************************************
___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
