You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeffrey Janner <Je...@PolyDyne.com> on 2011/09/13 19:21:55 UTC

How to return jpg from another disk location

Assume Tomcat 6/Java 6 and must be OS agnostic.

Our app currently is not distributable as a war file due to some decisions made long ago (properties files that need to be modified stored in WEB-INF, etc.).  I have found ways to work around most of the issues, mostly involving moving things from properties files or web.xml to the context.xml file.  However, there is one sticking point that is a problem.
We allow the end user to replace a JPG file with one of their own, so that it gets displayed on certain pages instead of the default one we provide (a logo file).  It currently resides in a sub-directory of the exploded war file.  Rather than have the customer replace the file after every upgrade, I thought it would be nice to somehow define a location where the file exists, and the app could go get it when requested (sort of like a sym-link).  I don't have a problem making the location a path to a directory that contains the file and then have it send from there if the file exists, like a sym-link to the directory.  And I am sure I can get the developers to change the code to reference the new location (It currently resides in a directory with a lot of other graphics).  Also, the app is backended by a DB that supports BLOBS, so that could possibly be another possiblility.

I am open to lots of suggestions and wonder if anyone has done this before.  Also interested in potential security issues.

As a windows example: http://somedomain.com/app/cust_graphics/logo.jpg will be delivered from C:/Program Files/mycompany/Customized information/logo.jpg.


__________________________________________________________________________

Confidentiality Notice:  This Transmission (including any attachments) may contain information that is privileged, confidential, and exempt from disclosure under applicable law.  If the reader of this message is not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.  

If you have received this transmission in error, please immediately reply to the sender or telephone (512) 343-9100 and delete this transmission from your system.

RE: How to return jpg from another disk location

Posted by Jeffrey Janner <Je...@PolyDyne.com>.
Thanks Chris.  That's a pretty good idea.  Normally, they just send us their logo from their website anyway.
I'll pass on to the boys to contemplate.
Jeff

> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Friday, September 16, 2011 4:03 PM
> To: Tomcat Users List
> Subject: Re: How to return jpg from another disk location
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Jeffrey,
> 
> On 9/13/2011 1:21 PM, Jeffrey Janner wrote:
> > Our app currently is not distributable as a war file due to some
> > decisions made long ago (properties files that need to be modified
> > stored in WEB-INF, etc.).
> >
> > [snip]
> >
> > However, there is one sticking point that is a problem. We allow
> > the end user to replace a JPG file with one of their own, so that
> > it gets displayed on certain pages instead of the default one we
> > provide (a logo file).  It currently resides in a sub-directory of
> > the exploded war file.  Rather than have the customer replace the
> > file after every upgrade, I thought it would be nice to somehow
> > define a location where the file exists, and the app could go get
> > it when requested (sort of like a sym-link).
> 
> How about setting the URL of the logo in one of those properties files
> you mentioned above, and then using that URL in your pages?
> 
> Then the client can even host the image anywhere they want.
> 
> Presumably, you have some kind of protection against clobbering client
> preferences: just use that same protection to avoid clobbering their
> logo URL.
> 
> - -chris
__________________________________________________________________________

Confidentiality Notice:  This Transmission (including any attachments) may contain information that is privileged, confidential, and exempt from disclosure under applicable law.  If the reader of this message is not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.  

If you have received this transmission in error, please immediately reply to the sender or telephone (512) 343-9100 and delete this transmission from your system.

Re: How to return jpg from another disk location

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeffrey,

On 9/13/2011 1:21 PM, Jeffrey Janner wrote:
> Our app currently is not distributable as a war file due to some 
> decisions made long ago (properties files that need to be modified 
> stored in WEB-INF, etc.).
> 
> [snip]
> 
> However, there is one sticking point that is a problem. We allow
> the end user to replace a JPG file with one of their own, so that
> it gets displayed on certain pages instead of the default one we
> provide (a logo file).  It currently resides in a sub-directory of
> the exploded war file.  Rather than have the customer replace the
> file after every upgrade, I thought it would be nice to somehow
> define a location where the file exists, and the app could go get
> it when requested (sort of like a sym-link).

How about setting the URL of the logo in one of those properties files
you mentioned above, and then using that URL in your pages?

Then the client can even host the image anywhere they want.

Presumably, you have some kind of protection against clobbering client
preferences: just use that same protection to avoid clobbering their
logo URL.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5zuW0ACgkQ9CaO5/Lv0PApDgCfU08u+dV5Onk6lYS/rb7jeOWF
GSgAniaeYNwk/Tem1KrBYCVEc4D9Wz2o
=Eqnh
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to return jpg from another disk location

Posted by Thad Humphries <th...@gmail.com>.
Ask your programmer to write a servlet that reads the image and writes it to
the output stream (ServletResponse.getOutputStream()). They should call
ServletResponse.setContentType("image/jpeg") before they write (or whatever
the MIME type is--image/png, image/gif, etc.).

I recommend they also check the value returned by
ServletResponse.getBufferSize() and read/write the image in chunks that
size. If getBufferSize() returns zero, I use 8K chunks.

On Tue, Sep 13, 2011 at 1:21 PM, Jeffrey Janner <Jeffrey.Janner@polydyne.com
> wrote:

> Assume Tomcat 6/Java 6 and must be OS agnostic.
>
> Our app currently is not distributable as a war file due to some decisions
> made long ago (properties files that need to be modified stored in WEB-INF,
> etc.).  I have found ways to work around most of the issues, mostly
> involving moving things from properties files or web.xml to the context.xml
> file.  However, there is one sticking point that is a problem.
> We allow the end user to replace a JPG file with one of their own, so that
> it gets displayed on certain pages instead of the default one we provide (a
> logo file).  It currently resides in a sub-directory of the exploded war
> file.  Rather than have the customer replace the file after every upgrade, I
> thought it would be nice to somehow define a location where the file exists,
> and the app could go get it when requested (sort of like a sym-link).  I
> don't have a problem making the location a path to a directory that contains
> the file and then have it send from there if the file exists, like a
> sym-link to the directory.  And I am sure I can get the developers to change
> the code to reference the new location (It currently resides in a directory
> with a lot of other graphics).  Also, the app is backended by a DB that
> supports BLOBS, so that could possibly be another possiblility.
>
> I am open to lots of suggestions and wonder if anyone has done this before.
>  Also interested in potential security issues.
>
> As a windows example: http://somedomain.com/app/cust_graphics/logo.jpgwill be delivered from C:/Program Files/mycompany/Customized
> information/logo.jpg.
>
>
> __________________________________________________________________________
>
> Confidentiality Notice:  This Transmission (including any attachments) may
> contain information that is privileged, confidential, and exempt from
> disclosure under applicable law.  If the reader of this message is not the
> intended recipient you are hereby notified that any dissemination,
> distribution, or copying of this communication is strictly prohibited.
>
> If you have received this transmission in error, please immediately reply
> to the sender or telephone (512) 343-9100 and delete this transmission
> from your system.
>



-- 
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v, 121-24)