Authentication servlet...please help me!!!

G

gbattine

Hi guys,
i need your help.
I'm developing my first jsf application but i've no much experience
with servlets and i'm trying to learn..
This is my question:
i've a login page in which a user try to authenticate its
data,inserting username and password.
I've a loginBean that makes authentication logic and sends user to menu
page of application,if data are correct...
i need to create a servlet that stores into a session username and
password of user.

This servlet has to do this:
redirects user to login page if session expires
check when user login if another user is navigating in the application
with same login data
protect the access to each page checking if there is a user in the
session.


I thinks it can be a common problem of web application,i hope someone
can give me a working example to study..if there are not working
example can someone help me with simple code to understand?I'm learning
java and jsf,but i've some difficulty with servlets,please help me....

Excuse my poor english....i hope you help me,THANKS
 
R

Robert Klemme

gbattine said:
Hi guys,
i need your help.
I'm developing my first jsf application but i've no much experience
with servlets and i'm trying to learn..
This is my question:
i've a login page in which a user try to authenticate its
data,inserting username and password.
I've a loginBean that makes authentication logic and sends user to menu
page of application,if data are correct...
i need to create a servlet that stores into a session username and
password of user.

This servlet has to do this:
redirects user to login page if session expires
check when user login if another user is navigating in the application
with same login data
protect the access to each page checking if there is a user in the
session.


I thinks it can be a common problem of web application,i hope someone
can give me a working example to study..if there are not working
example can someone help me with simple code to understand?I'm learning
java and jsf,but i've some difficulty with servlets,please help me....

Excuse my poor english....i hope you help me,THANKS

I'd do the redirection part with a Filter and not a servlet.

robert
 
M

Manish Pandit

I agree with Robert. Learn about filters - you can configure a filter
that can check for a presence of some sort of a token or a variable in
the session. If not present, do a response.sendRedirect to the login
page. If present, let the request through. Upon successful login you
can set that particular token/variable in the user's session. If you
want to leave out certain URLs to be 'insecure' or okay to be access
without signing up (like help pages..), you can configure the webapp to
not apply the filter to those URLs.

-cheers,
Manish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top