<logic:present role="ADMIN">
    html for administrator
</logic:present>

<logic:notPresent role="ADMIN">
    non admin links
</logic:notPresent>

----- Original Message -----
From: "Matt Raible" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 19, 2001 12:06 PM
Subject: Tag Libraries for Checking Role?


> I want to show/hide links in a page based on the role that an
authenticated
> user is in.  Is it possible to write the following with a TagLib?
>
> <%@page contentType="text/html"%>
> <%@page import="java.security.Principal" %>
> <html>
> <head><title>JSP Page</title></head>
> <body>
>
> <%
>   Principal principal = request.getUserPrincipal();
>   if( principal == null ) {
> %>
> There is no user principal (null)<p>
> <%
>   } else {
> %>
> User Principal is: <%= principal.getName() %>
> <%
>   }
> %>
> <P>Auth type is: <%= request.getAuthType() %>
> <P>Request is secure: <%= request.isSecure() %>
> <P>User is in role1: <%= request.isUserInRole("role1") %>
> <P>User is in role2: <%= request.isUserInRole("role2") %>
> <P>User is in Employee: <%= request.isUserInRole("Employee") %>
> </body>
> </html>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to