Andy Jefferson wrote:
> 
> Christian Mack wrote:
> >Andy Jefferson wrote:
> >>
> >> Simple one. How to access a particular image file via a servlet ...
> >>
> >> For example I have a servlet in
> >>
> >> /home/httpd/servlets/uk/co/demon/ajsoft/Invoice/
> >>
> >> and images in
> >>
> >> /home/httpd/servlets/uk/co/demon/ajsoft/Invoice/images/
> >Your image file has to live in the webserver directory, not in the servlet
> >directory.
> >
> >So use somthing like:
> >/usr/local/apache/htdocs/ajsoft/images/delete.gif
> >To store the gif, and use:
> ><IMG SRC="/ajsoft/images/delete.gif">
> >to give it back to the client.
> 
> Thanks. I was aware that I could put images in there, *but* a servlet should be
> able to be packaged on its own, and to pick images up from its own space. A
> mechanism *should* be available for doing this - either via Apache, or via
> Jserv. For example, if I had my servlet within a 'jar', I wouldn't want to have
> to copy the images into the web document root area.
> 
> TIA
> --
> Andy

Hi Andy

In this case, you have to provide a servlet (e.g. uk.co.demon.ajsoft.Images), which 
delivers images.
Then your HTML tag will be somthing like:
<IMG SRC="/servlets/uk.co.demon.ajsoft.Images?name=delete.gif">

But the problem with this is, that the Image class has to know, where to search for 
images. 
Servlets normally don't know their home directory.
The only way to specify this, is via an initialisation property.

Tschau
Christian



----------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to