The moose likes Tomcat and the fly likes Apache with Tomcat Authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Apache with Tomcat Authentication" Watch "Apache with Tomcat Authentication" New topic

Apache with Tomcat Authentication

p gro

Joined: Apr 16, 2013
Posts: 1
HI i have an jee application which runs on a tomcat 7. It uses Spring Security for authentication. The JSF Application should deliver Images in the webpages.

I think it would be nice if apache would deliver these image files.

i have a main directory for medias. Every user has a subdir (his username) with his images.

so when the user requests "" he should receive /srv/media/username/image.jpg

is there any possibility how apache could access the username on tomcat (maybe with the sessionid from the header). something like mod_auth_mysql is not a solution because there is no db with users, tomcat receives them from another server

any ideas?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

I think it highly likely that you will be called upon to justify your use of "p gro" as a display name as opposed to something that looks more like a real person's name.


Normally, I wouldn't recommend using Apache to serve up images for a Tomcat application these days. It has long since not been true that Apache can serve images significantly faster than Tomcat. However, if I'm reading correctly, you are looking to have the images come from user directories, not from a central application image directory.

Regardless, this is still something that Tomcat can probably do better than Apache, since Tomcat knows the user's identity and Apache does not. What I would do for the case mentioned above is to create a standard image servlet that opens an image file and copies it out to the HttpResponse output stream in the usual way, except that the logic that locates the image file that will be opened and read should synthesize the file path using the webapp username.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Apache with Tomcat Authentication
It's not a secret anymore!