This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat - access PDF reports directly

 
saami sameer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have got an application deployed on tomcat where user has to login and request for a report for particular month.If the pdf document is available in the 'reports' folder the link will be displayed to user.If the report is not present in the folder then it will be generated and linked will be displayed.
My problem is that if someone knows the path and name of the report he should not be able to access the pdf document by typing the URL directly on browser without logging into the application.
I am using my own authentication method cannot use BASIC authentication method.

Please let me know how this problem can be resolved

Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put the servlets in a directory that isn't accessible to the web.
This can be a directory under the WEB-INF directory or one outside your application's directory structure altogether.

Then write a servlet that reads from that directory and streams the file to the browser. In that servlet, you can add any checks that need to perform before streaming the file.

We have an example application in our codebarn that streams files (images) from under WEB-INF. That might be a good starting point for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic