|
|
| Role based login ..Need the concepts.. |
Expert:Anandh
Role based login how can i do that..
Constraint: i should have only one jsp page for all the user or usergroup... but depending upon the role the functions should change dynamically...
Example... Admin can delete option available but Employee delete option should not be visible... both should share one jsp page...
want to know different ways of implementing the above requriement....
Hoping for different concepts ... :-)
With Regards, K.M.Anandh
|
| Answers |
Hi friend,
This code help to solve your problem :
Some points remember "login.jsp"
1)Code have two file "login.jsp" and "welcome.jsp". 2)In "login.jsp" if select "Admin" it display "Delete" button with success message" and if select "Employee" it not display "Delete".
<html> <head> </head> <body> <form name="loginform" method="post" action="welcome.jsp"> <table> <tr> <tr> <td>Login Name</td> <td> <select name="type"> <option value="Admin">Admin</option> <option value="Employee">Employee</option> </select> </td> </tr> <tr> <td>Login Name</td> <td><input type="text" name="userName" value=""></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value=""></td> </tr> <tr> <td></td> <td><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form>
</body> </html>
"welcome.jsp"
<html> <head> </head> <body> <table> <%
if((request.getParameter("type")!=null) && request.getParameter("userName")!="" && (request.getParameter("userName")!=null) && (request.getParameter("password")!=null)) { if(request.getParameter("type").equals("Admin") ) { %> <tr> <td><b>Welcome <%=request.getParameter("userName")%></b></td></tr> <tr><td><input type="button" value="Delete"></td></tr> <% } if(request.getParameter("type").equals("Employee")) { %> <tr> <td><b>Welcome <%=request.getParameter("userName")%></b></td></tr> <% } } else { response.sendRedirect("login.jsp"); } %> </body> </html>
If you have any more problem then give in details.
Read for more information :
http://www.roseindia.net/
Thanks
|
Thank You .. i too have done the same way only... but the Login Type as Hidden value and i am checking tht and then redirecting them ... fine..
With Regards, K.M.Anandh
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|