You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Susan G. Conger" <su...@bfcassociates.com> on 2009/06/17 15:56:29 UTC

Serving images from classes directory

This may be a bit weird, however there is a reason for it.  I need to be
able to serve images from the classes directory of my web app.  The web app
is created using another companies program and all of the code is in the
classes directory.  I want to add an images directory and put all of my
custom images in that directory and then using them in my html/jsp pages.  I
also need to be able to insert/execute javascript code that is in the
classes directory or another directory below the classes directory.  Anyone
have any idea how to do this?

 

Thanks,

Susan

 

 


BFC Associates, Inc. 

  

"Helping Save You Money on Warehouse Operations"


Susan Conger

Chapel Hill, NC

630-562-0375 x106

	    

Main Office:

245 W. Roosevelt Rd. #8-51

West Chicago, IL 60185

630.562.0375

630.562.0618 (fax)

 

 


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
So there isn't any easy way to do this without using java?  I was just
wanted to use a different url and have them served up correctly.  Can you
give me/point me to an example of what you are talking about below?

Thanks,
Susan

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Wednesday, June 17, 2009 11:33 AM
To: Tomcat Users List
Subject: RE: Serving images from classes directory

> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: Serving images from classes directory
> 
> I need to be able to serve images from the classes directory 
> of my web app.

Try using ClassLoader.getResourceAsStream() to read the image, then write it
to the response output stream.  You'll need to set the content-type header
appropriately, of course.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.

 


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




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


RE: Serving images from classes directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: Serving images from classes directory
> 
> I need to be able to serve images from the classes directory 
> of my web app.

Try using ClassLoader.getResourceAsStream() to read the image, then write it to the response output stream.  You'll need to set the content-type header appropriately, of course.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

 


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


RE: Serving images from classes directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> If I want my stuff to play nice with their stuff then I have 
> to wedge my stuff into their stuff.

So what is "your stuff"?  Still haven't heard an explanation of why you think images have to be placed under WEB-INF/classes.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: Serving images from classes directory

Posted by Tsirkin Evgeny <ts...@gmail.com>.
What is your OS?
If this a *nix - then you have make sure that Web-INF is readable for the
world,
this is NOT good .On the  other hand you could just create a soft link to
whatever they
have there...
Evgeny

On Wed, Jun 17, 2009 at 9:20 PM, Susan G. Conger
<su...@bfcassociates.com>wrote:

> I started with the authors of the tool app and they said it was a tomcat
> limitation.  Basically can't be done.  So I figured I would try the list
> before I took their word for it.
>
> Yes, I use the tool to modify the template files.  But that is basically
> just editing html using the tool.  When the tool app builds my app it
> copies
> everything into the classes directory.  So that everything looks like one
> big Java class under the tool app.  So my thought is that my images and
> javascripts should go in here so I can have everything together and make
> maintenance easier.  I check everything the tool app builds into subversion
> so I can have some source control.
>
> Thanks,
> Susan
>
>
> -----Original Message-----
> From: Pid [mailto:p@pidster.com]
>  Sent: Wednesday, June 17, 2009 2:09 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
>
> Susan G. Conger wrote:
> > The template files are in the classes directory.  This is a web app that
> is
> > deploying it's own web app.  So it is rather convoluted.  The web app
> that
> > gets deployed is my web app while the web app doing the developing is the
> > third party tool.
>
>
> For reference then, we'll call the first one the 'tool app'.
>
> So are you actually editing the template files yourself, or are you
> using the tool app to edit the template files?
>
> Where in your app do the modified template files end up, and are they
> copied individually?
>
>
> The thought also occurs that the authors of the tool app might be the
> people you really want to be talking to about this.
>
> p
>
>
>
> > Thanks,
> > Susan
> >
> > -----Original Message-----
> > From: Pid [mailto:p@pidster.com]
> > Sent: Wednesday, June 17, 2009 1:29 PM
> > To: Tomcat Users List
> > Subject: Re: Serving images from classes directory
> >
> > Susan G. Conger wrote:
> >> Thanks Tim.  I don't have control during build because that is done by
> the
> >> third party tool.  I am not going to mention their name.  I was hoping
> > that
> >> this would be easy.  You know a servlet mapping in the web.xml file that
> >> would allow me to just map the directory/file type and I could just put
> > that
> >> in my html.  Since I can't use jsp everywhere I need the images.  Again
> I
> > am
> >> tied into their system and they have stuff in html files that they
> create.
> >> I edit the html template files they have to add my images and
> javascript.
> >> I use their environment to create/edit/build the web application.
> > Underneath
> >> I have tied in netBeans the best I can so I can debug their stuff.  But
> > that
> >> has issues too.
> >
> > If you can edit the template files, can't you include images in the same
> > place as the templates?
> >
> > p
> >
> >
> >
> >> Thanks,
> >> Susan
> >>
> >> -----Original Message-----
> >> From: Tim Funk [mailto:funkman@apache.org]
> >> Sent: Wednesday, June 17, 2009 1:07 PM
> >> To: Tomcat Users List
> >> Subject: Re: Serving images from classes directory
> >>
> >> If the images are physical images in the classes directory - you have a
> >> few options.
> >>
> >> 1) At build time - move (or copy) the files from the classes directory
> >> to somewhere more sane that the default servlet can access
> >> 2) Write a filter the detects these images that live in the classes dir,
> >> and then forwards to the images. (You need to be careful with this one)
> >>
> >> For # 2 - it would look something like this:
> >> doFilter(...) {
> >>    String p = request.getServletPath();
> >>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
> >>      String np = request.getServletPath().replaceFirst(".+/", "");
> >>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
> >>             .forward(request, response);
> >>    } else {
> >>      chain.doFilter(...);
> >>    }
> >> }
> >>
> >>
> >> -Tim
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Serving images from classes directory

Posted by Pid <p...@pidster.com>.
Susan G. Conger wrote:
> Andre,
> 
> I actually was thinking about doing it that way.  But I was wondering about
> the overhead.  I wish I knew how they were serving up the .html files in the
> class package.

Pull apart the *generated* 'yourapp.war' file.
It's just a zip file, so you could rename it to 'yourapp.zip' and then
expand the zip.  Or use the 'jar' command.

Give us an idea of what's in there - the web.xml of that, rather than
the tool app will be more interesting.

p



> Thanks,
> Susan
> 
> -----Original Message-----
> From: Andre-John Mas [mailto:ajmas@sympatico.ca] 
> Sent: Thursday, June 18, 2009 8:39 AM
> To: Tomcat Users List
> Cc: p@pidster.com
> Subject: Re: Serving images from classes directory
> 
> 
> On 18-Jun-2009, at 08:26, Susan G. Conger wrote:
> 
>> --> What is 'it', precisely?
>> It is server images from the classes directory.
>>
>> I realize the correct place to put my scripts and graphics.  However  
>> the
>> tool app deploys the app it makes for me as a class under it's classes
>> directory.  So I want to put all of my custom scripts and graphics  
>> in that
>> class package that it creates.  I then want to be able to access my  
>> custom
>> content by editing the html and putting a url in that points to the  
>> custom
>> content inside the class that was created by the tool app.
> 
> The only way to serve images from the classes directory would be for you
> to write a servlet that reads the files and then serves them up. While  
> you
> can do this, don't be surprised by the performance overhead.
> 
> I would recommend trying to find the least 'hackerish' approach to make
> things work.
> 
> For example if it is a question of project management, then you could  
> either
> split things into separate webapps, or find a folder naming structure  
> that
> is maintainable, and enforced.
> 
> One other approach I have seen is to split the project into  
> 'functional areas'
> that get merged at build time. There is a common project, which has  
> the shared
> API and the sub projects have the specific elements for their  
> functional area.
> 
> Andre
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: Serving images from classes directory

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

Susan,

On 6/18/2009 10:57 AM, Susan G. Conger wrote:
> I actually was thinking about doing it that way.  But I was wondering about
> the overhead.  I wish I knew how they were serving up the .html files in the
> class package.

Just follow the code: you have everything you need to know right there
in your HTML files and your web.xml. What is the URL you use to retrieve
an HTML file from the server? What does the mapping in web.xml say will
handle that URL?

You only have two mappings: /servlet/* (calls invoker, which will
translate the URL into a package + class that will be invoked... note
that this is considered insecure and rarely used by competent webapp
designers these days) and /servletToJsp (God only knows what that one does).

If the URL doesn't match either of those patterns, then it's being
served by the DefaultServlet, which just served static pages and won't
allow you to serve content from META-INF/* or WEB-INF/*. So, either you
have a crazy URL to access those files (and can probably use another
crazy URL to access /your/ files), or you are confused about which
web.xml file applies to your webapp, or you're just totally lying.

I suspect the first or second possibilities are most likely.

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

iEYEARECAAYFAko78ZUACgkQ9CaO5/Lv0PBDTwCgi3FwWpSalKXoQ2NPOlKMAlUU
QL4AoKyokJkc1V2M4J2L+B5L6mCUFJNI
=uHIx
-----END PGP SIGNATURE-----

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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
Andre,

I actually was thinking about doing it that way.  But I was wondering about
the overhead.  I wish I knew how they were serving up the .html files in the
class package.

Thanks,
Susan

-----Original Message-----
From: Andre-John Mas [mailto:ajmas@sympatico.ca] 
Sent: Thursday, June 18, 2009 8:39 AM
To: Tomcat Users List
Cc: p@pidster.com
Subject: Re: Serving images from classes directory


On 18-Jun-2009, at 08:26, Susan G. Conger wrote:

> --> What is 'it', precisely?
> It is server images from the classes directory.
>
> I realize the correct place to put my scripts and graphics.  However  
> the
> tool app deploys the app it makes for me as a class under it's classes
> directory.  So I want to put all of my custom scripts and graphics  
> in that
> class package that it creates.  I then want to be able to access my  
> custom
> content by editing the html and putting a url in that points to the  
> custom
> content inside the class that was created by the tool app.

The only way to serve images from the classes directory would be for you
to write a servlet that reads the files and then serves them up. While  
you
can do this, don't be surprised by the performance overhead.

I would recommend trying to find the least 'hackerish' approach to make
things work.

For example if it is a question of project management, then you could  
either
split things into separate webapps, or find a folder naming structure  
that
is maintainable, and enforced.

One other approach I have seen is to split the project into  
'functional areas'
that get merged at build time. There is a common project, which has  
the shared
API and the sub projects have the specific elements for their  
functional area.

Andre


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




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


RE: Serving images from classes directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Andre-John Mas [mailto:ajmas@sympatico.ca]
> Subject: Re: Serving images from classes directory
> 
> The only way to serve images from the classes directory would be for
> you to write a servlet that reads the files and then serves them up.
> While you can do this, don't be surprised by the performance overhead.

Why would there be any more overhead with that approach than with letting the DefaultServlet do it from some location other than WEB-INF/classes?

If the previously suggested internal forwarding mechanism doesn't work (haven't tried it), then extending Tomcat's DefaultServlet would provide a relatively easy means of delivering the content.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: Serving images from classes directory

Posted by Andre-John Mas <aj...@sympatico.ca>.
On 18-Jun-2009, at 08:26, Susan G. Conger wrote:

> --> What is 'it', precisely?
> It is server images from the classes directory.
>
> I realize the correct place to put my scripts and graphics.  However  
> the
> tool app deploys the app it makes for me as a class under it's classes
> directory.  So I want to put all of my custom scripts and graphics  
> in that
> class package that it creates.  I then want to be able to access my  
> custom
> content by editing the html and putting a url in that points to the  
> custom
> content inside the class that was created by the tool app.

The only way to serve images from the classes directory would be for you
to write a servlet that reads the files and then serves them up. While  
you
can do this, don't be surprised by the performance overhead.

I would recommend trying to find the least 'hackerish' approach to make
things work.

For example if it is a question of project management, then you could  
either
split things into separate webapps, or find a folder naming structure  
that
is maintainable, and enforced.

One other approach I have seen is to split the project into  
'functional areas'
that get merged at build time. There is a common project, which has  
the shared
API and the sub projects have the specific elements for their  
functional area.

Andre


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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
The tool app is the third party development tool that is used to generate my
web application.

-----Original Message-----
From: Pid [mailto:p@pidster.com] 
Sent: Thursday, June 18, 2009 8:47 AM
To: Tomcat Users List
Subject: Re: Serving images from classes directory

Susan G. Conger wrote:
> --> What is 'it', precisely?
> It is server images from the classes directory.
> 
> I realize the correct place to put my scripts and graphics.  However the
> tool app deploys the app it makes for me as a class under it's classes
> directory.  So I want to put all of my custom scripts and graphics in that
> class package that it creates.  I then want to be able to access my custom
> content by editing the html and putting a url in that points to the custom
> content inside the class that was created by the tool app.
> 
> I have no control over what gets copied and where it is copied from.  The
> developer of the tool app doesn't have any scripts or customizations for
> this scenario.  In the end I may end up putting my custom content where I
> don't want it, in doing so I know that I will be causing myself a
> maintenance nightmare for the next couple of year.  Everytime I deploy an
> application it will take extra time/steps.  This is what I am trying to
> avoid by serving the custom content from the images directory.

>> So that everything looks like one big Java class under the tool app.
> 
> That doesn't make a great deal of sense.  You're saying that there's a
> file called (something like) BigBunchOfTemplates.class in WEB-INF/classes
?

I'd like to help, but I'm a little confused by what you're describing.

What, exactly, is generated by the tool app?  Is it a .war file?
If so, have you expanded it and examined the results to see what's in it?

p


>> So my thought is that my images and javascripts should go in here so I
can
> have everything together and make
>> maintenance easier.  I check everything the tool app builds into
> subversion
>> so I can have some source control.  
> 
> Let's see if my understanding is accurate first.
> 

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




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


Re: Serving images from classes directory

Posted by André Warnier <aw...@ice-sa.com>.
Susan G. Conger wrote:
> All that is controlled by the tool app (Not written by me).  That is why I
> have to play nice. :-) Here is my web.xml for the tool app.
> 
> <?xml version="1.0" encoding="ISO-8859-1" ?> 
>   <!DOCTYPE web-app (View Source for full doctype...)> 
> - <web-app>
etc..

While not being in any way the expert here, the more I see and hear 
about this webapp, (or is it "webapp embedded in another webapp and 
using an Invoker to serve other stuff"), the more I'm getting uneasy and 
thinking this is a very big mess.

Let me suggest an unconventional drastic solution :

Put an Apache httpd in front of this Tomcat.
Unzip your war file, and put the content somewhere under the httpd 
document root.
Have httpd serve anything that is static, wherever it ends up being 
under /WEB-INF under this httpd document root.
(Apache httpd does not have the scruples about /WEB-INF/ that Tomcat has).
Delete everything that it /not/ static (*.jsp,*.class,*.jar,..) from 
this Apache httpd structure (so you don't serve it raw by mistake).
Now connect httpd with Tomcat using a connector like mod_proxy_ajp or 
mod_jk, and forward all the real dynamic calls to Tomcat.
Tomcat will by default not serve anything under /WEB-INF/.
But that's fine : whatever static you need there, would already have 
been served by httpd.

Unless this webapp within a webapp really generates static content 
on-the-fly, all of the above can be done with a simple shell script.




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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
All that is controlled by the tool app (Not written by me).  That is why I
have to play nice. :-) Here is my web.xml for the tool app.

<?xml version="1.0" encoding="ISO-8859-1" ?> 
  <!DOCTYPE web-app (View Source for full doctype...)> 
- <web-app>
  <display-name>tool_app application</display-name> 
  <description>toolapp</description> 
- <!--  Define servlet-mapped and path-mapped example filters 
  --> 
- <!--  Define servlets that are included in the example application 
  --> 
- <servlet>
  <servlet-name>servletToJsp</servlet-name> 
  <servlet-class>servletToJsp</servlet-class> 
  </servlet>
- <servlet>
  <servlet-name>invoker</servlet-name> 
  <servlet-class>org.apache.catalina.servlets.InvokerServlet</servlet-class>

- <init-param>
  <param-name>debug</param-name> 
  <param-value>3</param-value> 
  </init-param>
  <load-on-startup>2</load-on-startup> 
  </servlet>
- <servlet-mapping>
  <servlet-name>invoker</servlet-name> 
  <url-pattern>/servlet/*</url-pattern> 
  </servlet-mapping>
- <servlet-mapping>
  <servlet-name>servletToJsp</servlet-name> 
  <url-pattern>/servletToJsp</url-pattern> 
  </servlet-mapping>
  </web-app>

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Thursday, June 18, 2009 10:49 AM
To: Tomcat Users List
Subject: RE: Serving images from classes directory

> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> Sorry, it is a treated as a package with .xml, .html, .class files, and
> .java files.  So it is serving up the .html files that are in there
> just fine.

You're saying that you already have some mechanism of delivering .html files
from WEB-INF/classes?  How does that work?

> Maybe the images directory needs to be
> added to the classpath?

A classloader's classpath is used to access .class files and other resources
*via a classloader*; a classloader can not deliver .html files to an HTTP
client, so how are you doing it?  Do you already have a servlet that reads
.html from WEB-INF/classes and writes the output to the response output
stream?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.


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




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


Re: Serving images from classes directory

Posted by Pid <p...@pidster.com>.
Caldarale, Charles R wrote:
>> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
>> Subject: RE: Serving images from classes directory
>>
>> Sorry, it is a treated as a package with .xml, .html, .class files, and
>> .java files.  So it is serving up the .html files that are in there
>> just fine.

Which is what I was trying to establish.

> You're saying that you already have some mechanism of delivering .html files from WEB-INF/classes?  How does that work?

Which is what I was going to ask next.

p


>> Maybe the images directory needs to be
>> added to the classpath?
> 
> A classloader's classpath is used to access .class files and other resources *via a classloader*; a classloader can not deliver .html files to an HTTP client, so how are you doing it?  Do you already have a servlet that reads .html from WEB-INF/classes and writes the output to the response output stream?
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


RE: Serving images from classes directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> Sorry, it is a treated as a package with .xml, .html, .class files, and
> .java files.  So it is serving up the .html files that are in there
> just fine.

You're saying that you already have some mechanism of delivering .html files from WEB-INF/classes?  How does that work?

> Maybe the images directory needs to be
> added to the classpath?

A classloader's classpath is used to access .class files and other resources *via a classloader*; a classloader can not deliver .html files to an HTTP client, so how are you doing it?  Do you already have a servlet that reads .html from WEB-INF/classes and writes the output to the response output stream?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
Sorry, it is a treated as a package with .xml, .html, .class files, and
.java files.  So it is serving up the .html files that are in there just
fine.  So I put an images directory under there and tried to serve up my
images and tomcat can't find them.  Maybe the images directory needs to be
added to the classpath?

Thanks,
Susan

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Thursday, June 18, 2009 8:32 AM
To: Tomcat Users List; susanc@bfcassociates.com; p@pidster.com
Subject: RE: Serving images from classes directory

> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> So I want to put all of my custom scripts and graphics in
> that class package that it creates.  I then want to be able
> to access my custom content by editing the html and putting
> a url in that points to the custom content inside the class
> that was created by the tool app.

I'll bite: how do you expect to put something other than Java code inside a
class file?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.


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




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


RE: Serving images from classes directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> So I want to put all of my custom scripts and graphics in
> that class package that it creates.  I then want to be able
> to access my custom content by editing the html and putting
> a url in that points to the custom content inside the class
> that was created by the tool app.

I'll bite: how do you expect to put something other than Java code inside a class file?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: Serving images from classes directory

Posted by Pid <p...@pidster.com>.
Susan G. Conger wrote:
> --> What is 'it', precisely?
> It is server images from the classes directory.
> 
> I realize the correct place to put my scripts and graphics.  However the
> tool app deploys the app it makes for me as a class under it's classes
> directory.  So I want to put all of my custom scripts and graphics in that
> class package that it creates.  I then want to be able to access my custom
> content by editing the html and putting a url in that points to the custom
> content inside the class that was created by the tool app.
> 
> I have no control over what gets copied and where it is copied from.  The
> developer of the tool app doesn't have any scripts or customizations for
> this scenario.  In the end I may end up putting my custom content where I
> don't want it, in doing so I know that I will be causing myself a
> maintenance nightmare for the next couple of year.  Everytime I deploy an
> application it will take extra time/steps.  This is what I am trying to
> avoid by serving the custom content from the images directory.

>> So that everything looks like one big Java class under the tool app.
> 
> That doesn't make a great deal of sense.  You're saying that there's a
> file called (something like) BigBunchOfTemplates.class in WEB-INF/classes ?

I'd like to help, but I'm a little confused by what you're describing.

What, exactly, is generated by the tool app?  Is it a .war file?
If so, have you expanded it and examined the results to see what's in it?

p


>> So my thought is that my images and javascripts should go in here so I can
> have everything together and make
>> maintenance easier.  I check everything the tool app builds into
> subversion
>> so I can have some source control.  
> 
> Let's see if my understanding is accurate first.
> 

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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
--> What is 'it', precisely?
It is server images from the classes directory.

I realize the correct place to put my scripts and graphics.  However the
tool app deploys the app it makes for me as a class under it's classes
directory.  So I want to put all of my custom scripts and graphics in that
class package that it creates.  I then want to be able to access my custom
content by editing the html and putting a url in that points to the custom
content inside the class that was created by the tool app.

I have no control over what gets copied and where it is copied from.  The
developer of the tool app doesn't have any scripts or customizations for
this scenario.  In the end I may end up putting my custom content where I
don't want it, in doing so I know that I will be causing myself a
maintenance nightmare for the next couple of year.  Everytime I deploy an
application it will take extra time/steps.  This is what I am trying to
avoid by serving the custom content from the images directory.

Thanks,
Susan

-----Original Message-----
From: Pid [mailto:p@pidster.com] 
Sent: Wednesday, June 17, 2009 2:58 PM
To: Tomcat Users List
Subject: Re: Serving images from classes directory

Susan G. Conger wrote:
> I started with the authors of the tool app and they said it was a tomcat
> limitation.  Basically can't be done.  

What is 'it', precisely?

If they control the tool app then why can't they specify a location to
place scripts, stylesheets and images, so that they output in a
predictable place in your webapp?


> So I figured I would try the list before I took their word for it.

You're not meant to _directly_ access anything in WEB-INF/.  It's
protected, and deliberately so, as it has stuff you don't want users to
access.

You *can* put stuff in there and write some code to access it and
deliver it on request, but there's not a lot of point in doing so if you
can just put the data in question somewhere more accessible.

Typically, your webapp would look like (something) this:

 appname/index.html

 appname/thing.jsp

 appname/images/logo.gif

 appname/styles/layout.css

 appname/scripts/common.js

 appname/WEB-INF/web.xml

 appname/WEB-INF/classes/com/my/app/AppServlet.class

 appname/WEB-INF/lib/commons-logging.jar


Anything you put under /classes isn't going to be available directly to
the user if the server is a properly functioning Servlet container.

Doesn't stop you putting things elsewhere though.



> Yes, I use the tool to modify the template files.  But that is basically
> just editing html using the tool.  When the tool app builds my app it
copies
> everything into the classes directory.  

Which classes directory?  The one in the tool-app, or the one in your
generated webapp?

If it copies 'everything' why can't it copy images somewhere into the
generated app too?


> So that everything looks like one big Java class under the tool app.

That doesn't make a great deal of sense.  You're saying that there's a
file called (something like) BigBunchOfTemplates.class in WEB-INF/classes ?


> So my thought is that my images and javascripts should go in here so I can
have everything together and make
> maintenance easier.  I check everything the tool app builds into
subversion
> so I can have some source control.  

Let's see if my understanding is accurate first.

p



> Thanks,
> Susan
> 
> 
> -----Original Message-----
> From: Pid [mailto:p@pidster.com] 
> Sent: Wednesday, June 17, 2009 2:09 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> Susan G. Conger wrote:
>> The template files are in the classes directory.  This is a web app that
> is
>> deploying it's own web app.  So it is rather convoluted.  The web app
that
>> gets deployed is my web app while the web app doing the developing is the
>> third party tool.
> 
> 
> For reference then, we'll call the first one the 'tool app'.
> 
> So are you actually editing the template files yourself, or are you
> using the tool app to edit the template files?
> 
> Where in your app do the modified template files end up, and are they
> copied individually?
> 
> 
> The thought also occurs that the authors of the tool app might be the
> people you really want to be talking to about this.
> 
> p
> 
> 
> 
>> Thanks,
>> Susan
>>
>> -----Original Message-----
>> From: Pid [mailto:p@pidster.com] 
>> Sent: Wednesday, June 17, 2009 1:29 PM
>> To: Tomcat Users List
>> Subject: Re: Serving images from classes directory
>>
>> Susan G. Conger wrote:
>>> Thanks Tim.  I don't have control during build because that is done by
> the
>>> third party tool.  I am not going to mention their name.  I was hoping
>> that
>>> this would be easy.  You know a servlet mapping in the web.xml file that
>>> would allow me to just map the directory/file type and I could just put
>> that
>>> in my html.  Since I can't use jsp everywhere I need the images.  Again
I
>> am
>>> tied into their system and they have stuff in html files that they
> create.
>>> I edit the html template files they have to add my images and
javascript.
>>> I use their environment to create/edit/build the web application.
>> Underneath
>>> I have tied in netBeans the best I can so I can debug their stuff.  But
>> that
>>> has issues too.  
>> If you can edit the template files, can't you include images in the same
>> place as the templates?
>>
>> p
>>
>>
>>
>>> Thanks,
>>> Susan
>>>
>>> -----Original Message-----
>>> From: Tim Funk [mailto:funkman@apache.org] 
>>> Sent: Wednesday, June 17, 2009 1:07 PM
>>> To: Tomcat Users List
>>> Subject: Re: Serving images from classes directory
>>>
>>> If the images are physical images in the classes directory - you have a 
>>> few options.
>>>
>>> 1) At build time - move (or copy) the files from the classes directory 
>>> to somewhere more sane that the default servlet can access
>>> 2) Write a filter the detects these images that live in the classes dir,

>>> and then forwards to the images. (You need to be careful with this one)
>>>
>>> For # 2 - it would look something like this:
>>> doFilter(...) {
>>>    String p = request.getServletPath();
>>>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>>>      String np = request.getServletPath().replaceFirst(".+/", "");
>>>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>>>             .forward(request, response);
>>>    } else {
>>>      chain.doFilter(...);
>>>    }
>>> }
>>>
>>>
>>> -Tim
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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




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


Re: Serving images from classes directory

Posted by Pid <p...@pidster.com>.
Susan G. Conger wrote:
> I started with the authors of the tool app and they said it was a tomcat
> limitation.  Basically can't be done.  

What is 'it', precisely?

If they control the tool app then why can't they specify a location to
place scripts, stylesheets and images, so that they output in a
predictable place in your webapp?


> So I figured I would try the list before I took their word for it.

You're not meant to _directly_ access anything in WEB-INF/.  It's
protected, and deliberately so, as it has stuff you don't want users to
access.

You *can* put stuff in there and write some code to access it and
deliver it on request, but there's not a lot of point in doing so if you
can just put the data in question somewhere more accessible.

Typically, your webapp would look like (something) this:

 appname/index.html

 appname/thing.jsp

 appname/images/logo.gif

 appname/styles/layout.css

 appname/scripts/common.js

 appname/WEB-INF/web.xml

 appname/WEB-INF/classes/com/my/app/AppServlet.class

 appname/WEB-INF/lib/commons-logging.jar


Anything you put under /classes isn't going to be available directly to
the user if the server is a properly functioning Servlet container.

Doesn't stop you putting things elsewhere though.



> Yes, I use the tool to modify the template files.  But that is basically
> just editing html using the tool.  When the tool app builds my app it copies
> everything into the classes directory.  

Which classes directory?  The one in the tool-app, or the one in your
generated webapp?

If it copies 'everything' why can't it copy images somewhere into the
generated app too?


> So that everything looks like one big Java class under the tool app.

That doesn't make a great deal of sense.  You're saying that there's a
file called (something like) BigBunchOfTemplates.class in WEB-INF/classes ?


> So my thought is that my images and javascripts should go in here so I can have everything together and make
> maintenance easier.  I check everything the tool app builds into subversion
> so I can have some source control.  

Let's see if my understanding is accurate first.

p



> Thanks,
> Susan
> 
> 
> -----Original Message-----
> From: Pid [mailto:p@pidster.com] 
> Sent: Wednesday, June 17, 2009 2:09 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> Susan G. Conger wrote:
>> The template files are in the classes directory.  This is a web app that
> is
>> deploying it's own web app.  So it is rather convoluted.  The web app that
>> gets deployed is my web app while the web app doing the developing is the
>> third party tool.
> 
> 
> For reference then, we'll call the first one the 'tool app'.
> 
> So are you actually editing the template files yourself, or are you
> using the tool app to edit the template files?
> 
> Where in your app do the modified template files end up, and are they
> copied individually?
> 
> 
> The thought also occurs that the authors of the tool app might be the
> people you really want to be talking to about this.
> 
> p
> 
> 
> 
>> Thanks,
>> Susan
>>
>> -----Original Message-----
>> From: Pid [mailto:p@pidster.com] 
>> Sent: Wednesday, June 17, 2009 1:29 PM
>> To: Tomcat Users List
>> Subject: Re: Serving images from classes directory
>>
>> Susan G. Conger wrote:
>>> Thanks Tim.  I don't have control during build because that is done by
> the
>>> third party tool.  I am not going to mention their name.  I was hoping
>> that
>>> this would be easy.  You know a servlet mapping in the web.xml file that
>>> would allow me to just map the directory/file type and I could just put
>> that
>>> in my html.  Since I can't use jsp everywhere I need the images.  Again I
>> am
>>> tied into their system and they have stuff in html files that they
> create.
>>> I edit the html template files they have to add my images and javascript.
>>> I use their environment to create/edit/build the web application.
>> Underneath
>>> I have tied in netBeans the best I can so I can debug their stuff.  But
>> that
>>> has issues too.  
>> If you can edit the template files, can't you include images in the same
>> place as the templates?
>>
>> p
>>
>>
>>
>>> Thanks,
>>> Susan
>>>
>>> -----Original Message-----
>>> From: Tim Funk [mailto:funkman@apache.org] 
>>> Sent: Wednesday, June 17, 2009 1:07 PM
>>> To: Tomcat Users List
>>> Subject: Re: Serving images from classes directory
>>>
>>> If the images are physical images in the classes directory - you have a 
>>> few options.
>>>
>>> 1) At build time - move (or copy) the files from the classes directory 
>>> to somewhere more sane that the default servlet can access
>>> 2) Write a filter the detects these images that live in the classes dir, 
>>> and then forwards to the images. (You need to be careful with this one)
>>>
>>> For # 2 - it would look something like this:
>>> doFilter(...) {
>>>    String p = request.getServletPath();
>>>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>>>      String np = request.getServletPath().replaceFirst(".+/", "");
>>>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>>>             .forward(request, response);
>>>    } else {
>>>      chain.doFilter(...);
>>>    }
>>> }
>>>
>>>
>>> -Tim
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
I started with the authors of the tool app and they said it was a tomcat
limitation.  Basically can't be done.  So I figured I would try the list
before I took their word for it.  

Yes, I use the tool to modify the template files.  But that is basically
just editing html using the tool.  When the tool app builds my app it copies
everything into the classes directory.  So that everything looks like one
big Java class under the tool app.  So my thought is that my images and
javascripts should go in here so I can have everything together and make
maintenance easier.  I check everything the tool app builds into subversion
so I can have some source control.  

Thanks,
Susan


-----Original Message-----
From: Pid [mailto:p@pidster.com] 
Sent: Wednesday, June 17, 2009 2:09 PM
To: Tomcat Users List
Subject: Re: Serving images from classes directory

Susan G. Conger wrote:
> The template files are in the classes directory.  This is a web app that
is
> deploying it's own web app.  So it is rather convoluted.  The web app that
> gets deployed is my web app while the web app doing the developing is the
> third party tool.


For reference then, we'll call the first one the 'tool app'.

So are you actually editing the template files yourself, or are you
using the tool app to edit the template files?

Where in your app do the modified template files end up, and are they
copied individually?


The thought also occurs that the authors of the tool app might be the
people you really want to be talking to about this.

p



> Thanks,
> Susan
> 
> -----Original Message-----
> From: Pid [mailto:p@pidster.com] 
> Sent: Wednesday, June 17, 2009 1:29 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> Susan G. Conger wrote:
>> Thanks Tim.  I don't have control during build because that is done by
the
>> third party tool.  I am not going to mention their name.  I was hoping
> that
>> this would be easy.  You know a servlet mapping in the web.xml file that
>> would allow me to just map the directory/file type and I could just put
> that
>> in my html.  Since I can't use jsp everywhere I need the images.  Again I
> am
>> tied into their system and they have stuff in html files that they
create.
>> I edit the html template files they have to add my images and javascript.
>> I use their environment to create/edit/build the web application.
> Underneath
>> I have tied in netBeans the best I can so I can debug their stuff.  But
> that
>> has issues too.  
> 
> If you can edit the template files, can't you include images in the same
> place as the templates?
> 
> p
> 
> 
> 
>> Thanks,
>> Susan
>>
>> -----Original Message-----
>> From: Tim Funk [mailto:funkman@apache.org] 
>> Sent: Wednesday, June 17, 2009 1:07 PM
>> To: Tomcat Users List
>> Subject: Re: Serving images from classes directory
>>
>> If the images are physical images in the classes directory - you have a 
>> few options.
>>
>> 1) At build time - move (or copy) the files from the classes directory 
>> to somewhere more sane that the default servlet can access
>> 2) Write a filter the detects these images that live in the classes dir, 
>> and then forwards to the images. (You need to be careful with this one)
>>
>> For # 2 - it would look something like this:
>> doFilter(...) {
>>    String p = request.getServletPath();
>>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>>      String np = request.getServletPath().replaceFirst(".+/", "");
>>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>>             .forward(request, response);
>>    } else {
>>      chain.doFilter(...);
>>    }
>> }
>>
>>
>> -Tim
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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




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


Re: Serving images from classes directory

Posted by Pid <p...@pidster.com>.
Susan G. Conger wrote:
> The template files are in the classes directory.  This is a web app that is
> deploying it's own web app.  So it is rather convoluted.  The web app that
> gets deployed is my web app while the web app doing the developing is the
> third party tool.


For reference then, we'll call the first one the 'tool app'.

So are you actually editing the template files yourself, or are you
using the tool app to edit the template files?

Where in your app do the modified template files end up, and are they
copied individually?


The thought also occurs that the authors of the tool app might be the
people you really want to be talking to about this.

p



> Thanks,
> Susan
> 
> -----Original Message-----
> From: Pid [mailto:p@pidster.com] 
> Sent: Wednesday, June 17, 2009 1:29 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> Susan G. Conger wrote:
>> Thanks Tim.  I don't have control during build because that is done by the
>> third party tool.  I am not going to mention their name.  I was hoping
> that
>> this would be easy.  You know a servlet mapping in the web.xml file that
>> would allow me to just map the directory/file type and I could just put
> that
>> in my html.  Since I can't use jsp everywhere I need the images.  Again I
> am
>> tied into their system and they have stuff in html files that they create.
>> I edit the html template files they have to add my images and javascript.
>> I use their environment to create/edit/build the web application.
> Underneath
>> I have tied in netBeans the best I can so I can debug their stuff.  But
> that
>> has issues too.  
> 
> If you can edit the template files, can't you include images in the same
> place as the templates?
> 
> p
> 
> 
> 
>> Thanks,
>> Susan
>>
>> -----Original Message-----
>> From: Tim Funk [mailto:funkman@apache.org] 
>> Sent: Wednesday, June 17, 2009 1:07 PM
>> To: Tomcat Users List
>> Subject: Re: Serving images from classes directory
>>
>> If the images are physical images in the classes directory - you have a 
>> few options.
>>
>> 1) At build time - move (or copy) the files from the classes directory 
>> to somewhere more sane that the default servlet can access
>> 2) Write a filter the detects these images that live in the classes dir, 
>> and then forwards to the images. (You need to be careful with this one)
>>
>> For # 2 - it would look something like this:
>> doFilter(...) {
>>    String p = request.getServletPath();
>>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>>      String np = request.getServletPath().replaceFirst(".+/", "");
>>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>>             .forward(request, response);
>>    } else {
>>      chain.doFilter(...);
>>    }
>> }
>>
>>
>> -Tim
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: Serving images from classes directory

Posted by David kerber <dc...@verizon.net>.
Susan G. Conger wrote:
> The template files are in the classes directory.  This is a web app that is
> deploying it's own web app.  So it is rather convoluted.  The web app that
> gets deployed is my web app while the web app doing the developing is the
> third party tool.
>
> Thanks,
> Susan
>   

Self-modifying code; cool!!

D



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


RE: Serving images from classes directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> This is a web app that is deploying it's own web app.

Isn't that illegal in some states/countries?

> The web app that gets deployed is my web app while the web 
> app doing the developing is the third party tool.

When are the images used?  When the 3rd-party tool deploys your webapp, or when your webapp is actually running?

Is there any way of configuring the 3rd-party tool to store specific files in specific locations in the deployed webapp?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
The template files are in the classes directory.  This is a web app that is
deploying it's own web app.  So it is rather convoluted.  The web app that
gets deployed is my web app while the web app doing the developing is the
third party tool.

Thanks,
Susan

-----Original Message-----
From: Pid [mailto:p@pidster.com] 
Sent: Wednesday, June 17, 2009 1:29 PM
To: Tomcat Users List
Subject: Re: Serving images from classes directory

Susan G. Conger wrote:
> Thanks Tim.  I don't have control during build because that is done by the
> third party tool.  I am not going to mention their name.  I was hoping
that
> this would be easy.  You know a servlet mapping in the web.xml file that
> would allow me to just map the directory/file type and I could just put
that
> in my html.  Since I can't use jsp everywhere I need the images.  Again I
am
> tied into their system and they have stuff in html files that they create.
> I edit the html template files they have to add my images and javascript.
> I use their environment to create/edit/build the web application.
Underneath
> I have tied in netBeans the best I can so I can debug their stuff.  But
that
> has issues too.  

If you can edit the template files, can't you include images in the same
place as the templates?

p



> Thanks,
> Susan
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@apache.org] 
> Sent: Wednesday, June 17, 2009 1:07 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> If the images are physical images in the classes directory - you have a 
> few options.
> 
> 1) At build time - move (or copy) the files from the classes directory 
> to somewhere more sane that the default servlet can access
> 2) Write a filter the detects these images that live in the classes dir, 
> and then forwards to the images. (You need to be careful with this one)
> 
> For # 2 - it would look something like this:
> doFilter(...) {
>    String p = request.getServletPath();
>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>      String np = request.getServletPath().replaceFirst(".+/", "");
>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>             .forward(request, response);
>    } else {
>      chain.doFilter(...);
>    }
> }
> 
> 
> -Tim
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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




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


Re: Serving images from classes directory

Posted by Pid <p...@pidster.com>.
Susan G. Conger wrote:
> Thanks Tim.  I don't have control during build because that is done by the
> third party tool.  I am not going to mention their name.  I was hoping that
> this would be easy.  You know a servlet mapping in the web.xml file that
> would allow me to just map the directory/file type and I could just put that
> in my html.  Since I can't use jsp everywhere I need the images.  Again I am
> tied into their system and they have stuff in html files that they create.
> I edit the html template files they have to add my images and javascript.
> I use their environment to create/edit/build the web application. Underneath
> I have tied in netBeans the best I can so I can debug their stuff.  But that
> has issues too.  

If you can edit the template files, can't you include images in the same
place as the templates?

p



> Thanks,
> Susan
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@apache.org] 
> Sent: Wednesday, June 17, 2009 1:07 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> If the images are physical images in the classes directory - you have a 
> few options.
> 
> 1) At build time - move (or copy) the files from the classes directory 
> to somewhere more sane that the default servlet can access
> 2) Write a filter the detects these images that live in the classes dir, 
> and then forwards to the images. (You need to be careful with this one)
> 
> For # 2 - it would look something like this:
> doFilter(...) {
>    String p = request.getServletPath();
>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>      String np = request.getServletPath().replaceFirst(".+/", "");
>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>             .forward(request, response);
>    } else {
>      chain.doFilter(...);
>    }
> }
> 
> 
> -Tim
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: Serving images from classes directory

Posted by Tim Funk <fu...@apache.org>.
The filter (below) can be made smarter to perform smarter checks - so 
"regular images" could be excluded.

-Tim

Susan G. Conger wrote:
> Thanks Tim.  I don't have control during build because that is done by the
> third party tool.  I am not going to mention their name.  I was hoping that
> this would be easy.  You know a servlet mapping in the web.xml file that
> would allow me to just map the directory/file type and I could just put that
> in my html.  Since I can't use jsp everywhere I need the images.  Again I am
> tied into their system and they have stuff in html files that they create.
> I edit the html template files they have to add my images and javascript.
> I use their environment to create/edit/build the web application. Underneath
> I have tied in netBeans the best I can so I can debug their stuff.  But that
> has issues too.  
> 
> Thanks,
> Susan
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@apache.org] 
> Sent: Wednesday, June 17, 2009 1:07 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> If the images are physical images in the classes directory - you have a 
> few options.
> 
> 1) At build time - move (or copy) the files from the classes directory 
> to somewhere more sane that the default servlet can access
> 2) Write a filter the detects these images that live in the classes dir, 
> and then forwards to the images. (You need to be careful with this one)
> 
> For # 2 - it would look something like this:
> doFilter(...) {
>    String p = request.getServletPath();
>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>      String np = request.getServletPath().replaceFirst(".+/", "");
>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>             .forward(request, response);
>    } else {
>      chain.doFilter(...);
>    }
> }
> 
> 
> -Tim
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

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


Re: Serving images from classes directory

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

Susan,

On 6/18/2009 8:13 AM, Susan G. Conger wrote:
> This is a windows box so I can't just
> put links in the other area.

mklink.exe? Why does nobody think that NTFS supports links?

> I actually have to move or copy the pieces.
> Having multiple copies of the same objects is not a fix because they have to
> be kept up to date.

rsync?

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

iEYEARECAAYFAko78hsACgkQ9CaO5/Lv0PArNACfTFGqvGA0cXiuSFMrrcuDkhVb
KmsAnjSC4B9D4o3CYj00NuQfXCjnMVjN
=Wt3v
-----END PGP SIGNATURE-----

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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
That is the rub.  I don't control this process.  The tool app is the one
that builds/deploys my application.  It is its own web application that
actually generates my application and deploys it.  So I have to play nice
with the tool app in order to have everything work correctly.

Thanks,
Susan

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Thursday, June 18, 2009 8:30 AM
To: Tomcat Users List
Subject: RE: Serving images from classes directory

> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> But from a maintenance/source control stand point it sure
> would make things a lot easier if I didn't have to pick
> and choose what directories to move when deploying on the
> users machines.

That would be the function of a deployment script, written in ant or
whatever strikes your fancy; it's not something you'd have to do manually.
Once the script is written, you can use it for each deployment, and files
will be in the proper locations, eliminating the complexity and risk you're
facing now.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.



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




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


RE: Serving images from classes directory

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Susan G. Conger [mailto:susanc@bfcassociates.com]
> Subject: RE: Serving images from classes directory
> 
> But from a maintenance/source control stand point it sure
> would make things a lot easier if I didn't have to pick
> and choose what directories to move when deploying on the
> users machines.

That would be the function of a deployment script, written in ant or whatever strikes your fancy; it's not something you'd have to do manually.  Once the script is written, you can use it for each deployment, and files will be in the proper locations, eliminating the complexity and risk you're facing now.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.



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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
Andre,

Thanks.  I know serving images from the classes directory is not the best
way to do stuff.  But from a maintenance/source control stand point it sure
would make things a lot easier if I didn't have to pick and choose what
directories to move when deploying on the users machines.  Because the tool
app deploys the web apps that it builds as classes under it's own classes
directory, I have to move all of my custom scripts and graphics to another
location in order to use them.  As I said it would make my life much easier
if everything was in one spot.  That way I could package everything easier
and maintain with subversion easier.  This is a windows box so I can't just
put links in the other area.  I actually have to move or copy the pieces.
Having multiple copies of the same objects is not a fix because they have to
be kept up to date.

I knew when I posted the first request that it was strange.  But sometimes
we have to take that square peg and hammer it into the round whole.  So if
anyone has any ideas (I will take a look at your rewriting url stuff.
Thanks!) how this can be done then I am all ears.  If you just want to slam
me for doing something different then don't bother.  

Thanks,
Susan    

-----Original Message-----
From: André Warnier [mailto:aw@ice-sa.com] 
Sent: Wednesday, June 17, 2009 4:34 PM
To: Tomcat Users List
Subject: Re: Serving images from classes directory

Susan,
have a look at this :
http://tuckey.org/urlrewrite/

This is a "servlet filter", which kind of "wraps" your webapp, 
intercepting all calls before they reach your webapp.
On the way, it allows you to modify the request URL (for instance), to 
for example to redirect the call to some simple servlet which would just 
return said image.
Or maybe - my knowledge is too limited to really tell - arrange for 
these calls to be served by Tomcat's default webapp, which serves static 
items.

Note that I am not in all this taking a stance on whether what you want 
to do is fundamentally a good idea, which from the previous expert 
testimonies here, it seems it is not.

Also, the reason that said experts object so strenuously to what you 
want to do, is not that they just personally don't like it for some 
reason of elegance or so.  Their main objection probably has to do with 
the security of your website.  Mixing code (which you do not want to 
disclose to just about anyone) with static objects (which you want to 
disclose of course) is probably the best way to introduce huge holes in 
whatever security scheme your site would otherwise have.
So the experts are telling you "don't do that", because in their expert 
and considerate opinion, they don't feel that they should help you do by 
yourself something that will definitely put your site at risk.


Susan G. Conger wrote:
> Thanks Tim.  I don't have control during build because that is done by the
> third party tool.  I am not going to mention their name.  I was hoping
that
> this would be easy.  You know a servlet mapping in the web.xml file that
> would allow me to just map the directory/file type and I could just put
that
> in my html.  Since I can't use jsp everywhere I need the images.  Again I
am
> tied into their system and they have stuff in html files that they create.
> I edit the html template files they have to add my images and javascript.
> I use their environment to create/edit/build the web application.
Underneath
> I have tied in netBeans the best I can so I can debug their stuff.  But
that
> has issues too.  
> 
> Thanks,
> Susan
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@apache.org] 
> Sent: Wednesday, June 17, 2009 1:07 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> If the images are physical images in the classes directory - you have a 
> few options.
> 
> 1) At build time - move (or copy) the files from the classes directory 
> to somewhere more sane that the default servlet can access
> 2) Write a filter the detects these images that live in the classes dir, 
> and then forwards to the images. (You need to be careful with this one)
> 
> For # 2 - it would look something like this:
> doFilter(...) {
>    String p = request.getServletPath();
>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>      String np = request.getServletPath().replaceFirst(".+/", "");
>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>             .forward(request, response);
>    } else {
>      chain.doFilter(...);
>    }
> }
> 
> 
> -Tim
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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




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


Re: Serving images from classes directory

Posted by André Warnier <aw...@ice-sa.com>.
Susan,
have a look at this :
http://tuckey.org/urlrewrite/

This is a "servlet filter", which kind of "wraps" your webapp, 
intercepting all calls before they reach your webapp.
On the way, it allows you to modify the request URL (for instance), to 
for example to redirect the call to some simple servlet which would just 
return said image.
Or maybe - my knowledge is too limited to really tell - arrange for 
these calls to be served by Tomcat's default webapp, which serves static 
items.

Note that I am not in all this taking a stance on whether what you want 
to do is fundamentally a good idea, which from the previous expert 
testimonies here, it seems it is not.

Also, the reason that said experts object so strenuously to what you 
want to do, is not that they just personally don't like it for some 
reason of elegance or so.  Their main objection probably has to do with 
the security of your website.  Mixing code (which you do not want to 
disclose to just about anyone) with static objects (which you want to 
disclose of course) is probably the best way to introduce huge holes in 
whatever security scheme your site would otherwise have.
So the experts are telling you "don't do that", because in their expert 
and considerate opinion, they don't feel that they should help you do by 
yourself something that will definitely put your site at risk.


Susan G. Conger wrote:
> Thanks Tim.  I don't have control during build because that is done by the
> third party tool.  I am not going to mention their name.  I was hoping that
> this would be easy.  You know a servlet mapping in the web.xml file that
> would allow me to just map the directory/file type and I could just put that
> in my html.  Since I can't use jsp everywhere I need the images.  Again I am
> tied into their system and they have stuff in html files that they create.
> I edit the html template files they have to add my images and javascript.
> I use their environment to create/edit/build the web application. Underneath
> I have tied in netBeans the best I can so I can debug their stuff.  But that
> has issues too.  
> 
> Thanks,
> Susan
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@apache.org] 
> Sent: Wednesday, June 17, 2009 1:07 PM
> To: Tomcat Users List
> Subject: Re: Serving images from classes directory
> 
> If the images are physical images in the classes directory - you have a 
> few options.
> 
> 1) At build time - move (or copy) the files from the classes directory 
> to somewhere more sane that the default servlet can access
> 2) Write a filter the detects these images that live in the classes dir, 
> and then forwards to the images. (You need to be careful with this one)
> 
> For # 2 - it would look something like this:
> doFilter(...) {
>    String p = request.getServletPath();
>    if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
>      String np = request.getServletPath().replaceFirst(".+/", "");
>      request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
>             .forward(request, response);
>    } else {
>      chain.doFilter(...);
>    }
> }
> 
> 
> -Tim
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
Thanks Tim.  I don't have control during build because that is done by the
third party tool.  I am not going to mention their name.  I was hoping that
this would be easy.  You know a servlet mapping in the web.xml file that
would allow me to just map the directory/file type and I could just put that
in my html.  Since I can't use jsp everywhere I need the images.  Again I am
tied into their system and they have stuff in html files that they create.
I edit the html template files they have to add my images and javascript.
I use their environment to create/edit/build the web application. Underneath
I have tied in netBeans the best I can so I can debug their stuff.  But that
has issues too.  

Thanks,
Susan

-----Original Message-----
From: Tim Funk [mailto:funkman@apache.org] 
Sent: Wednesday, June 17, 2009 1:07 PM
To: Tomcat Users List
Subject: Re: Serving images from classes directory

If the images are physical images in the classes directory - you have a 
few options.

1) At build time - move (or copy) the files from the classes directory 
to somewhere more sane that the default servlet can access
2) Write a filter the detects these images that live in the classes dir, 
and then forwards to the images. (You need to be careful with this one)

For # 2 - it would look something like this:
doFilter(...) {
   String p = request.getServletPath();
   if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
     String np = request.getServletPath().replaceFirst(".+/", "");
     request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
            .forward(request, response);
   } else {
     chain.doFilter(...);
   }
}


-Tim


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




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


Re: Serving images from classes directory

Posted by Tim Funk <fu...@apache.org>.
If the images are physical images in the classes directory - you have a 
few options.

1) At build time - move (or copy) the files from the classes directory 
to somewhere more sane that the default servlet can access
2) Write a filter the detects these images that live in the classes dir, 
and then forwards to the images. (You need to be careful with this one)

For # 2 - it would look something like this:
doFilter(...) {
   String p = request.getServletPath();
   if (p.matches("/magic_prefix/[\\w]+\\.gif$")) {
     String np = request.getServletPath().replaceFirst(".+/", "");
     request.getRequestDispatcher("/WEB-INF/class/more/cowbell/" + np)
            .forward(request, response);
   } else {
     chain.doFilter(...);
   }
}


-Tim


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


Re: Serving images from classes directory

Posted by Hassan Schroeder <ha...@gmail.com>.
On Wed, Jun 17, 2009 at 9:24 AM, Susan G. Conger
<su...@bfcassociates.com>wrote:

> As I said.  It is not a web app that I have created.  It is generated by a
> third party development environment.  If I want my stuff to play nice with
> their stuff then I have to wedge my stuff into their stuff.  Which is
> located under the classes directory.  I don't make the rules I just try to
> bend them to solve my problems.  I can't change the development
> environment.
> I have to figure out how to get around it.  Do you have any idea on how I
> can accomplish this.


Sure, have your own servlet deliver the images and javascript.


>  I know it is weird but it is what it is.
>

It still sounds like utter nonsense. Can you give us any idea of
what this "third party development environment" is so I can be
sure to stay far away from it?  :-)

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
As I said.  It is not a web app that I have created.  It is generated by a
third party development environment.  If I want my stuff to play nice with
their stuff then I have to wedge my stuff into their stuff.  Which is
located under the classes directory.  I don't make the rules I just try to
bend them to solve my problems.  I can't change the development environment.
I have to figure out how to get around it.  Do you have any idea on how I
can accomplish this.  I know it is weird but it is what it is.

Thanks,
Susan

-----Original Message-----
From: Hassan Schroeder [mailto:hassan.schroeder@gmail.com] 
Sent: Wednesday, June 17, 2009 12:10 PM
To: Tomcat Users List; susanc@bfcassociates.com
Subject: Re: Serving images from classes directory

On Wed, Jun 17, 2009 at 9:04 AM, Susan G. Conger
<su...@bfcassociates.com>wrote:

> The web app is made by another company that screen scrapes/translates a
> mainframe app and then makes a web app out of it.  They store this in
their
> classes directory.  So in order to keep everything together and make
> maintenance and deployment easier, I would like to have all of the
> generated
> code and custom code in one location.  That way I don't have to pull
things
> from everywhere when I deploy to the web app to our customers.


That makes no sense at all.

A web app is a web app, and the "classes" directory is only one part
of it.  Pretty much any normal web app includes exposed content like
images, stylesheets, javascript.

Are you saying you deploy *only* a classes directory to customers?
Again, that makes no sense.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com



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


Re: Serving images from classes directory

Posted by Hassan Schroeder <ha...@gmail.com>.
On Wed, Jun 17, 2009 at 9:04 AM, Susan G. Conger
<su...@bfcassociates.com>wrote:

> The web app is made by another company that screen scrapes/translates a
> mainframe app and then makes a web app out of it.  They store this in their
> classes directory.  So in order to keep everything together and make
> maintenance and deployment easier, I would like to have all of the
> generated
> code and custom code in one location.  That way I don't have to pull things
> from everywhere when I deploy to the web app to our customers.


That makes no sense at all.

A web app is a web app, and the "classes" directory is only one part
of it.  Pretty much any normal web app includes exposed content like
images, stylesheets, javascript.

Are you saying you deploy *only* a classes directory to customers?
Again, that makes no sense.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

RE: Serving images from classes directory

Posted by "Susan G. Conger" <su...@bfcassociates.com>.
The web app is made by another company that screen scrapes/translates a
mainframe app and then makes a web app out of it.  They store this in their
classes directory.  So in order to keep everything together and make
maintenance and deployment easier, I would like to have all of the generated
code and custom code in one location.  That way I don't have to pull things
from everywhere when I deploy to the web app to our customers.  I wish it
didn't work this way and if I was developing from scratch I wouldn't do it
this way.  However sometime we have to find work arounds caused by the
environment that others choose.  Basically I am stuck so I am trying to make
the best of it.

Thanks,
Susan

-----Original Message-----
From: Hassan Schroeder [mailto:hassan.schroeder@gmail.com] 
Sent: Wednesday, June 17, 2009 11:56 AM
To: Tomcat Users List; susanc@bfcassociates.com
Subject: Re: Serving images from classes directory

On Wed, Jun 17, 2009 at 6:56 AM, Susan G. Conger
<su...@bfcassociates.com> wrote:
>
> This may be a bit weird, however there is a reason for it.  I need to
> be able to serve images from the classes directory of my web app.

I have to ask -- why? It seems a pointless complication...

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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




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


Re: Serving images from classes directory

Posted by Hassan Schroeder <ha...@gmail.com>.
On Wed, Jun 17, 2009 at 6:56 AM, Susan G. Conger
<su...@bfcassociates.com> wrote:
>
> This may be a bit weird, however there is a reason for it.  I need to
> be able to serve images from the classes directory of my web app.

I have to ask -- why? It seems a pointless complication...

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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