detecting role-name in java bean

hi!

This is variation of my previous problem.
++++++
Create a servlet that reads request parameter from the user, creates a prime umber of the specified size, and forwards the request to a JSP page that displays the result. If no size if specified, display a 30-digit prime. Use MVC to display it. Only administrators should see primes of 40 digits or more. If ordinary users ask for primes of 40 or more digits, they should get 20-digit primes instead.

My question is how can I detect role-name in java bean? Another words, after users login, I want to detect whether administrator login or not.

(form-based authenticaiton was used.)

Thanks,
dkim18Asked:
Who is Participating?
 
sompol_kiatkamolchaiConnect With a Mentor Commented:
Dear dkim18,

Try this API.

Package javax.servlet.http
Interface HttpServletRequest

public boolean isUserInRole(java.lang.String role)

Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.
Parameters:
role - a String specifying the name of the role
Returns:
a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated

Best luck,

SOMPOL
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.