• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using Tomcat3.2.1 / 4.0.1 in Stand-alone

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm not sure why I'm getting the following behaviour, and I'm not sure what (if anything) the specification has to say about these things...

I have an application that works in 3.2.1. I wanted to code it so that if I had Apache fronting it, that with minimal (to no) code rewriting, I could serve my static images from the webserver document root, and everything else through Tomcat. The same app would also be able to serve everything through Tomcat.

So what I did was put all my images into "imagedir" and in my HTML I would put < img src="/imagedir/myImage.gif"> (note the /)

In tomcat 3.2.1, I'd make a folder under webapps called imagedir, and everything was cool.
|
|- webapps
| |
| |- imagedir
| |
| |- myApp

This same structure under Tomcat4.0.1 will not work. I get the little red box for all my images.

Because imagedir doesn't *really* belong under webapps, perhaps this was a 'feature' of 3.2.1 that has now been fixed in 4.0.1?

Anyone have an idea of how to do what I'm wanting? Where do I place my static content, such that my app can be run through Apache/Tomcat, or just Tomcat, with no rewrites to the src=" " tags?
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat 4.0 (and possibly 3.2.2 but I can remember have to check apache site) fixed several "features" that amounted to security holes.
The fix is simple put imageDir under myApps
|
|- webapps
| |
| |- myApp
| |
| | |- imagedir
Your current tag /imageDir/... Fits exactly this configuration so, you shouldn't have any page changes.

------------------
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, it doesn't.

<app> - the application directory under webapps
<img> - the image directory, wherever it is.

With the / in front of <img>, it will not find <img>/myimg.gif if <img> is inside <app>. This behaviour is both 3.2.1 and 4.0.1.
If <img> is <app>../ (one dir above the <app> ), then 3.2.1 can find the images, but 4.0.1 will not. (this is the 'feature' that was fixed).

If I leave the / off, then 3.2.1 will find <img>/myimg.gif if <img> inside <app>, as will 4.0.1
Neither will find <img>/myimg.gif if I have <img> at <app>../ (one above).

I guess my answer is 'leave off the /', because as I'm thinking about this... If I'm using Tomcat, it will treat <webapps> as the 'root', and append the Context automatically for me (/<app> ) and then try to find '/<img>/myimg.gif'. And if I'm using Apache-Tomcat... the webserver will see a request for '<img>/myimg.gif', and attempt to serve it from it's own root, (it doesn't need the / to interpret it as 'from the root', if we're already operating at that level, which we are.)

Sigh.. worried about nothing again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!