954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

user authentication and authorization



UserName:


Password:






General UserAdministrator

saswati_mishra
Newbie Poster
15 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Simple if statement with checking user selection will solve the problem

if(student)
{
    RequestDispatcher dispatcher = getServletContex().getRequestDispatcher("/student.jsp");
    dispatcher.forward(request, response);
}
else if(teacher)
{
    RequestDispatcher dispatcher = getServletContex().getRequestDispatcher("/teacher.jsp");
    dispatcher.forward(request, response);
}
else
{
    RequestDispatcher dispatcher = getServletContex().getRequestDispatcher("/admin.jsp");
    dispatcher.forward(request, response);
}

PS: Please use hash sign "#" to insert any code into your post. It will keep code format as from IDE and post would not be so long. Thanx

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

Hi,
You can opt one more solution. Try putting user roles in your user table in database. Now when user will log into your system, check their role and populate it into bean. This way, user bean will always be having their associated role. Put this bean in session scope.

Now after login functionality simply redirect user to a common url using the same code as peter said.

Use a filter to authenticate user to access particular resource like your jsp & servlets. Because you have user bean in session you can always check its role and corresponding url that can be accessed by that particular user..

let me see if your problem is solved or not.
have a nice time
regards
sam.n

sam.n
Newbie Poster
2 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

Hi

I tried this code but am not logging in successfully, when i key in the username and pwd am getting an error called The requested resource not found. Please help me to solve this, its very urgent.

Thanks in advance
Lissy.

lisy
Newbie Poster
4 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Which you tried and which code is not working?

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

Hi frnds..I wnt to creat a login page where the user can login to page only once.Wen they login successfully their authentication should be disabled..Tat is they cannot login in to the page again..Plz frnds help me to complete tis task..

Thanks in advance..

swetha749
Newbie Poster
1 post since Mar 2012
Reputation Points: 10
Solved Threads: 0
 

1. learn how to start a new thread
2. learn about sessions and storing information in them

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 

Post: Markdown Syntax: Formatting Help
You