my dog learned polymorphism*
The moose likes Servlets and the fly likes PDF Files and web server location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "PDF Files and web server location" Watch "PDF Files and web server location" New topic
Author

PDF Files and web server location

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
I am working on a site that allows members to enter data and based on this data a pdf file is generated for them. This file is then stored into their personal directory and when they navigate to their home page a list of pdf files they have created are displayed as hyperlinks.

I do not want anyone just to be able to type in the url to access the pdf file. I want the files only accessible to the member who created it.

I thought about having a servlet that accepted a pdf flie ID and a member id. When a user clicks on a link to view on the pdf I can access the database and make sure that the memberID requesting the file is the same member that created it. The only problem is that I am not sure how to then return the pdf to the user.

Another option is to put them behind WEB-INF and I think this will suffice. However, what would the hyperlink url be so they can access it as I thought the user would not be able to directly access the files behind WEB-INF

Thank you
david
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
There are several options you have for protecting data. One is to implement container managed security to protect certain directories...another is to protect certain directories with filters. Either way...once the user has logged in you can associate their username with the pdf file that they have submitted and then let them view it.

The pdf file could either be stored in a database or on the filesystem.

As far as WEB-INF - nothing behind WEB-INF is directly accessible. Typically you put JSP pages in a directory under the web-app context directory that you can display to the user and any servlets, handler classes, or beans that you use would sit behind the WEB-INF file in the classes directory.

Your question is quite broad so you might first want to figure out how you are going to have users login then figure out how they can access their PDF files.
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
I thought about having a servlet that accepted a pdf flie ID and a member id. When a user clicks on a link to view on the pdf I can access the database and make sure that the memberID requesting the file is the same member that created it. The only problem is that I am not sure how to then return the pdf to the user.
You're on the right track. You are basically using a filter to verify the member first. Now you just need to send the appropriate pdf back.
By the way, those of you who have a copy of Head First Servlet & JSP will probably recognize this, as the original format came from that book. Wonderful book, by the way!


“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: PDF Files and web server location
 
Similar Threads
Where to place non java files in a WAR archive?
Permission control: File Upload and Download - Want to improve performance
Accessing jsp's directly
can't access tomcat-docs webapp
storage of files in website