detecting role-name in java bean

Posted on 2005-04-10
Last Modified: 2010-04-01

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.)

Question by:dkim18
    LVL 29

    Accepted Solution

    LVL 11

    Assisted Solution

    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.
    role - a String specifying the name of the role
    a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated

    Best luck,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    Digital marketing agencies have encountered both the opportunities and difficulties that emerge from working with a wide-ranging organizations.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now