This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 60078
    
  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: 60078
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing a zip file through a JSP page.
 
Similar Threads
Accessing a file in the middle of creating it.
Accessing a file in the middle of creating it.
cookie and login
Preventing direct access to a redirected page
Application to serve files.