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 can anyone tell me how to make a authentication with jsp & servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "can anyone tell me how to make a authentication with jsp & servlet" Watch "can anyone tell me how to make a authentication with jsp & servlet" New topic
Author

can anyone tell me how to make a authentication with jsp & servlet

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
can anyone tell me how to make a authentication with jsp & servlet ?
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
this is my index.jsp


this is my servlet


it is working properly.
no problem.

1)if someone enter wrong password or username it is redirected to the index.jsp.
I need to add something if he enter incorrect password to the jsp
how to do this?

2) i need to add this to session tracking tooooo?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42359
    
  64
You don't need to do anything with sessions in your code. The "How do I implement security for my web application ?" section in the ServletsFaq should get you started.


Ping & DNS - my free Android networking tools app
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I mean if user login first time and didn't logout.
then next time he try to come this site he don't need to provide username or password.
how to impliment this feature?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Cookies.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Personally I feel this should be handled in a filter, not a servlet--at least the checking for login status--not the login itself.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
can you give me exmple for cokkies how to set cokkies to this ?
why do you think that is handle in filter?
when you are talking about filter i feel it shuold better handle in listner?is it?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Samanthi perera wrote:can you give me exmple for cokkies how to set cokkies to this ?

Search the web--there are hundreds of examples.
why do you think that is handle in filter?

Because you need to check for login on a specific set of pages, and filters are good at that.
when you are talking about filter i feel it shuold better handle in listner?is it?

Depends on what specific aspect of the problem you're talking about. But no, I wouldn't use a listener for any of this, because the checking for logged in status and logging in are triggered by hitting a URL (handled by filters) and hitting the login URL (handled by servlets).
 
Consider Paul's rocket mass heater.
 
subject: can anyone tell me how to make a authentication with jsp & servlet