Re: Dynamic image generation servlet...
Nic Ferrier <[email protected]> Sat, 13 Nov 2004 16:42:14 +0000
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <[email protected]> |
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