Skip to Content

JSP Client

The CAS JSP tag library conforms to its TLD. The binary release can be downloaded from the downloads section.

Example:

Here's an example of using the CAS JSP Taglib.

<%-- This is a sample JSP page that uses the CAS tag library.  It assumes
   that the tag library from


      http://www.yale.edu/tp/cas/cas-taglib-1.00.tar.gz


   is installed into your web application.


   For the CAS 1.0 client (which works under JSP 1.1), this involves the
   following steps: 


      - addition of castools.tld to your application's WEB-INF directory
      - addition of castools.jar to your application's WEB-INF/lib directory
      - modification of your application's deployment descriptor (web.xml)
      to add an element like this:


	    
	      http://www.yale.edu/its/tp/castools/WEB-INF/castools.tld
	    


   To use the CAS 2.0 client, simply refer to the sample application
   ('webProxy') that comes with the CAS 2.0 distribution.


--%>


<%-- The following like imports the tag library into the current page
   and associates it with the prefix 'cas' --%>


<%@ taglib prefix="cas" uri="/WEB-INF/castools.tld" %>




<%-- The following tag (JSP action) authenticates the user via CAS and
   exposes the NetID of this user in the session-scoped variable
   named 'netid'.  If this session-scoped variable already exists,
   the tag assumes the user has authenticated previously, and it does
   not re-authenticate the user.
--%>


<cas:auth id="netid" scope="session"/>


<%--
   Now, scripting code may use the scripting variable named 'netid',
   and other code (such as a servlet sharing a session with this page)
   may refer to the session-scoped attribute named 'netid', as in


     myHttpServletRequest.getSession().getAttribute("netid")
--%>


<%--
   After authenticating the user, we might forward to a servlet
   in our application; this servlet can read the session-scoped
   parameter, as described earlier.  (It would not be secure
   to pass the NetID to the servlet as a request parameter; the servlet
   should use the session-scoped attribute exposed by the CAS
   tag.)
--%>


<jsp:forward page="/myServlet"/>