wood burning stoves 2.0*
The moose likes JSP and the fly likes Accessing a zip file through a JSP page. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Accessing a zip file through a JSP page." Watch "Accessing a zip file through a JSP page." New topic
Author

Accessing a zip file through a JSP page.

Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
I have a zip file in my JSP application for clients to access (password-protected by tomcat).

I also have a JSP that will detect the last time user tries to access, how many times they have accessed, etc. before it redirects user to the zip file. But this is the ideal case.
There's no way to prevent user from accessing the zip file directly.

How do I make sure that the clients only will be able to access the zip file through the JSP page?

Thanks in advance for all the help.
Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
As an additional notes, I have Apache in front of Tomcat.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

JSP is an astoundingly poor technology choice for this.

What I would do is to place the zip file somewhere in the WEB-INF folder hierarchy. This will protect it from direct access.

Then I'd write a servlet that will serve up that zip file, setting appropriate headers, when it has been determined that the request is properly authenticated.

JSP is not very good at serving non-text files.
[ February 28, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
> JSP is an astoundingly poor technology choice for this.
Why is this?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

JSP assumes that it is serving text. Trying to use it to serve anything else is fraught with pitfalls.

More in this article if interested.
 
jQuery in Action, 2nd edition
 
subject: Accessing a zip file through a JSP page.
 
Similar Threads
Application to serve files.
Accessing a file in the middle of creating it.
cookie and login
Accessing a file in the middle of creating it.
Preventing direct access to a redirected page