public String getUserPrincipal ( ) { // Create a hash table to hold the results in Map info = new TreeMap ( ) ; // Extract the request from the page context HttpServletRequest request = ( HttpServletRequest ) pageContext . getRequest ( ) ; // Get the principal from the request Principal principal = request . getUserPrincipal ( ) ; // Check if there is a principal if ( principal != null ) { info . put ( "principal name" , principal . getName ( ) ) ; } else { info . put ( "principal name" , "no principal" ) ; } // Convert the results to an HTML table return toHTMLTable ( "container security" , info ) ; }
Returns the user principal name .