File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes different role stored in mySQL can access different jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "different role stored in mySQL can access different jsp " Watch "different role stored in mySQL can access different jsp " New topic

different role stored in mySQL can access different jsp

Melvin Reynold

Joined: Jun 12, 2009
Posts: 15
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

Joined: Jul 01, 2009
Posts: 1
I'd would like to know this too please. Thanks!
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
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.

Experience and talent are independent of age
Charbel Keyrouz
Ranch Hand

Joined: Jun 10, 2005
Posts: 46
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.

I agree. Here's the link:
subject: different role stored in mySQL can access different jsp
It's not a secret anymore!