Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

different role stored in mySQL can access different jsp

 
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



 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd would like to know this too please. Thanks!
 
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.
 
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.

 
You can thank my dental hygienist for my untimely aliveness. So tiny:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!