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 servlet jsp dao application 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 "servlet jsp dao application" Watch "servlet jsp dao application" New topic
Author

servlet jsp dao application

amila lakmal
Greenhorn

Joined: Dec 30, 2007
Posts: 7
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


please help me this is urgent
Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
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
amila lakmal
Greenhorn

Joined: Dec 30, 2007
Posts: 7
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
Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
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.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
Consider Paul's rocket mass heater.
 
subject: servlet jsp dao application
 
Similar Threads
Session Handling- How restrict to only one admin login
Tomcat 5.0 FORM authentication + servlet mapping problem
Stacktrace
basic authentication
Dynamic Menus