Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

different role stored in mySQL can access different jsp

 
Melvin Reynold
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, i dont speak or write in english very well. I have a database named sales. And in sales, i have a table named User. In User, i have values named serial no., username, password and role. Role is given by choosing an option in a drop down list either Admin or User from a java server page. And it is stored in User table. What i want is if a username with an admin role log in, that username will enter a different jsp than the username with a User role. for example once user ABC with an Admin role log in, he will enter A.jsp but if user ABCD with User role log in, he will enter B.jsp. Thanks.


This is my controller and im using doGet




This is where i create the method checkUsername



This is my javascript



 
Drew Vent
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd would like to know this too please. Thanks!
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you returning "int iDataCount" for from "public int checkUsername(HttpServletRequest, HttpServletResponse)" ?

In my opinion, you should be returning a String or a final int. Check that returned value in the doGet method and set the value of strTargetPage accordingly.
 
Charbel Keyrouz
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best solution is to implement JAAS where you can assign for each page a security role and if a user is accessing a page outside his security he will be redirected to the login page automatically.
The configuration of the security roles is done in the web.xml.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic