@ Override public void init ( ServletConfig config ) throws ServletException { m_cache = new HashMap < String , Templates > ( ) ; m_creds = new HashMap < String , UsernamePasswordCredentials > ( ) ; m_cManager = new PoolingClientConnectionManager ( ) ; m_cManager . getSchemeRegistry ( ) . register ( new Scheme ( "https" , 443 , SSLSocketFactory . getSocketFactory ( ) ) ) ; m_cManager . getSchemeRegistry ( ) . register ( new Scheme ( "https-tomcat" , 8443 , SSLSocketFactory . getSocketFactory ( ) ) ) ; m_cManager . getSchemeRegistry ( ) . register ( new Scheme ( "http" , 80 , PlainSocketFactory . getSocketFactory ( ) ) ) ; m_cManager . getSchemeRegistry ( ) . register ( new Scheme ( "http-tomcat" , 8080 , PlainSocketFactory . getSocketFactory ( ) ) ) ; Enumeration < ? > enm = config . getInitParameterNames ( ) ; while ( enm . hasMoreElements ( ) ) { String name = ( String ) enm . nextElement ( ) ; if ( name . startsWith ( CRED_PARAM_START ) ) { String value = config . getInitParameter ( name ) ; if ( value . indexOf ( ":" ) == - 1 ) { throw new ServletException ( "Malformed credentials for " + name + " -- expected ':' user/pass delimiter" ) ; } String [ ] parts = value . split ( ":" ) ; String user = parts [ 0 ] ; StringBuffer pass = new StringBuffer ( ) ; for ( int i = 1 ; i < parts . length ; i ++ ) { if ( i > 1 ) { pass . append ( ' ' ) ; } pass . append ( parts [ i ] ) ; } m_creds . put ( name . substring ( CRED_PARAM_START . length ( ) ) , new UsernamePasswordCredentials ( user , pass . toString ( ) ) ) ; } } }
Initialize the servlet by setting up the stylesheet cache the http connection manager and configuring credentials for the http client .