Dear all im beginner to j2ee i have assignment to do in j2ee but im stuck in some broblems please help me this is the scenario
there are 3 roles in the application user ,admin and manger when the any user login to the system the have to supply username and password this is login.jsp, when clicks login button of login jsp it call a servlet calld relayservlet the relayserlet call DAO class, the DAO class contain all the database connection information and,the DAO connects D.B
Q1)How im check the user role from D.B
Q2)if the user is Admin, how im redirect the admin user to admin.jsp
Maintain a table like user_details(username,password,role). First check for valid user and then depending on the role use forward() method from servlet.
Java Programmer | SCJP 1.5 | SCWCD 1.4
Joined: Dec 30, 2007
Soumyajit Hazra wrote:Maintain a table like user_details(username,password,role). First check for valid user and then depending on the role use forward() method from servlet.
thank you for immediate response but could you please tell me how im view specific jsp page to specific user
ex to admin admin.jsp
please explain using coding
Joined: Jun 26, 2007
Step 1. Check for user authentication. Username/password combination is valid or not
Step 2. If valid check role
Step 3. If role==admin then forward to admin.jsp (if role==General forward to general.jsp)
My advice is for code you first go through Head First Servlet Jsp and try yourself. Check the servlet doc too, that will help.
And you might find the built-in security mechanism provided by the container (Servlet compliant) very much useful rather than implementing your own logic to Authenticate/Authorize users. Some samples on how to do it with Tomcat can be found here.