This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Authentication Dialog Box 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 "Authentication Dialog Box" Watch "Authentication Dialog Box" New topic

Authentication Dialog Box

Avinash venna

Joined: Jun 10, 2010
Posts: 17
Hi all,

Actually in my application i take a zip file which contains some files and upload it to a server. After uploading i am giving a link to download that file. When a user clicks that link a servlet will execute and a dialog box will appear with options ( open , save and cancel ).

My current requirement is when ever user clicks that link he should be prompted with a dialog box for authentication( he needs to enter username and password). If he enters correct credentials he can download or else it should go to error page...

Please some one guide me how to implement this.. I am new to this... Thanks in advance..

Avinash venna

Joined: Jun 10, 2010
Posts: 17
Some one look into this please...
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

When the user clicks that click, instead of servlet, let the HTML page get displayed, which asks for username and password, from there pass the control to the servlet, using action attribute.. Then, in the servlet, code which is for downloading the file, can be wriiten inside a if condition, that if condition, will check for the authentication method returning true or false.., By the By, how you need to authenticate? Is it against the data stored in database..

Regards, Prasad
SCJP 5 (93%)
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41123
Would servlet security for the download URL be sufficient?

Ping & DNS - my free Android networking tools app
I agree. Here's the link:
subject: Authentication Dialog Box
Similar Threads
Download file from Mysql database
"Unspecified error" when trying to save file
MVC - Downloading a file created on the fly
download file using h:commandLink or h:graphicImage
application that allows to download a file