You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Stewart, Robbie (Contractor)" <Ro...@dsto.defence.gov.au> on 2001/05/15 04:15:16 UTC

images within servlet context

Gidday all,
Probably asked hundreds of times but I couldn't see where on the archives,
anyway...
 
I have setup a situation following the basic 2.2/2.3 web-app guidelines
where site resources (images, templates, xml-content, etc) are located
outside servlet context but within web-app root. My servlet (a subclass of
VelocityServlet) handles requests OK returning dynamic content constructed
using those resources. My users (content providers) require the freedom to
create static html pages, drop them into sub-folders under the content tree
somewhere and for them to show up within the site. This works fine as well
except for when local image and other type resources are referenced. These
references are relative references and therefore assumed to be within the
servlet context.
 
I can't see how to serve them: can't override doGet/Post; can't access the
response output stream directly as a template is expected; not sure if the
servlet or the servlet container is supposed to handle this; do not want to
parse the html and convert relative references to absolute; cannot force
content providers to put all image and other type resources in a fixed,
known location;...
 
Using:
  * tomcat 4.xx
  * velocity 1.0.1
 
Help appreciated,
 

Robbe Stewart         Software Engineer 
Altasys Software        0414 643 461 

Contracted to:          
Department of Defence    <ma...@dsto.defence.gov.au>
mailto:Robbie.Stewart@dsto.defence.gov.au 
Salisbury SA, Australia

 

Re: images within servlet context

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
"Stewart, Robbie (Contractor)" wrote:
> 
> Gidday all,
> Probably asked hundreds of times but I couldn't see where on the archives,
> anyway...
> 
> I have setup a situation following the basic 2.2/2.3 web-app guidelines
> where site resources (images, templates, xml-content, etc) are located
> outside servlet context but within web-app root. My servlet (a subclass of
> VelocityServlet) handles requests OK returning dynamic content constructed
> using those resources. My users (content providers) require the freedom to
> create static html pages, drop them into sub-folders under the content tree
> somewhere and for them to show up within the site. This works fine as well
> except for when local image and other type resources are referenced. These
> references are relative references and therefore assumed to be within the
> servlet context.
> 
> I can't see how to serve them: can't override doGet/Post; can't access the
> response output stream directly as a template is expected; not sure if the
> servlet or the servlet container is supposed to handle this; do not want to
> parse the html and convert relative references to absolute; cannot force
> content providers to put all image and other type resources in a fixed,
> known location;...
> 

I had the same problem, and decided that I was uninterested in making
Tomcat pump image bits - Apache should be way better for that.

To that end, I would do things like put an images directory in my
webapp, make a link from 'htdocs' (or wherever your Apache root is...)
into the webapp location,  and make image references absolute.  Not
perfect, I know, but it got Tomcat out of the image moving business.

I also want to be able to separate static image (and other - flash, for
example) content to a completly separate server set, so there is another
aspect to consider.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."