File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Password Protect a File or Directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Password Protect a File or Directory" Watch "Password Protect a File or Directory" New topic
Author

Password Protect a File or Directory

Ketul Parikh
Greenhorn

Joined: Jul 17, 2009
Posts: 14
Hi All,

I need to make an application where in from a servlet a file is to be created and stored on local pc, which contains some important info..

Now What I want is that When I create a file it should be password protected so that when anybody tries to open it directly (i.e. by double clicking on the file) it would not be accessible without password..

Is it Possible??

If not, can I have such directory..
so as to implement "vault" like mechanism.


KETUL
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Ketul Parikh wrote:Hi All,

I need to make an application where in from a servlet a file is to be created and stored on local pc, which contains some important info..


Any ideas how you were going to do that with a Servlet? Servlets run on the server, they can't interact with the file system on the client.


Now What I want is that When I create a file it should be password protected so that when anybody tries to open it directly (i.e. by double clicking on the file) it would not be accessible without password..

Why would you allow download of a file the client (potentially) cannot open?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61773
    
  67

The best thing to do would to not allow download except for people that should see the file in the first place. Failing that, perhaps a password-protected PDF might work?

In any case, not really a Servlets question.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ketul Parikh
Greenhorn

Joined: Jul 17, 2009
Posts: 14
I am going to create that file on Server only, I want that no user of Server can access it without password..

No client side interaction or downloading is going to be done.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

As Bear mentioned a password protected PDF would probably work for you.

You can also password protect zip files.
Unfortunately, Java (last I checked) can't create password protected zip files so you would need to look for a third party library to do this.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61773
    
  67

Ketul Parikh wrote:No client side interaction or downloading is going to be done.

Then what did you mean by:
Ketul Parikh wrote:... a file is to be created and stored on local pc

?

Local PC == client
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Password Protect a File or Directory