title: request.getUserPrincipal().getName() causing error 500
body: <p>Following is my code which seems ok to me but it's giving error <strong><em>HTTP Status 500</em></strong> while running.</p>
  
  <pre><code>    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out=response.getWriter();
  
      String name=request.getParameter("name");
      String password=request.getParameter("pass");
      request.login(name, password);
  
      out.print("&lt;br/&gt;Get Authentication: "+request.getAuthType());
      out.print("&lt;br/&gt;Get Remote User: "+request.getRemoteUser());
      out.print("&lt;br/&gt;Get User Principal: "+request.getUserPrincipal().getName());
      out.print("&lt;br/&gt;Get Authentication: "+request.getAuthType());
  </code></pre>
  
  <p>Here is the complete Stack Trace-</p>
  
  <pre><code>Sep 24, 2014 12:05:40 AM org.apache.catalina.core.AprLifecycleListener init
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production  environments was not found on the java.library.path: C:\Program   Files\Java\jdk1.7.0_25\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.7.0_25/bin/../jre/bin/server;C:/Program   Files/Java/jdk1.7.0_25/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0_25/bin/../jre/lib/amd64;C:\Program Files\Dell\DW WLAN Card;;C:\Program  Files\Java\jdk1.7.0_25\bin;c:\Program Files\WIDCOMM\Bluetooth Software\;c:\Program  Files\WIDCOMM\Bluetooth Software\syswow64;;E:\Soft\Java soft\eclipse;;.
   Sep 24, 2014 12:05:40 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
   WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to   'org.eclipse.jst.jee.server:ResponseHandling' did not find a matching property.
   Sep 24, 2014 12:05:40 AM org.apache.coyote.AbstractProtocol init
   INFO: Initializing ProtocolHandler ["http-bio-8080"]
   Sep 24, 2014 12:05:40 AM org.apache.coyote.AbstractProtocol init
   INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
   Sep 24, 2014 12:05:40 AM org.apache.catalina.startup.Catalina load
   INFO: Initialization processed in 697 ms
   Sep 24, 2014 12:05:40 AM org.apache.catalina.core.StandardService startInternal
   INFO: Starting service Catalina
   Sep 24, 2014 12:05:40 AM org.apache.catalina.core.StandardEngine startInternal
   INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
   Sep 24, 2014 12:05:40 AM org.apache.coyote.AbstractProtocol start
   INFO: Starting ProtocolHandler ["http-bio-8080"]
   Sep 24, 2014 12:05:40 AM org.apache.coyote.AbstractProtocol start
   INFO: Starting ProtocolHandler ["ajp-bio-8009"]
   Sep 24, 2014 12:05:40 AM org.apache.catalina.startup.Catalina start
   INFO: Server startup in 388 ms
   Sep 24, 2014 12:05:46 AM org.apache.catalina.core.StandardWrapperValve invoke
   SEVERE: Servlet.service() for servlet [RequestHandlingOperation] in context with path     [/ResponseHandling] threw exception [Login failed] with root cause
   javax.servlet.ServletException: Login failed
   at org.apache.catalina.authenticator.AuthenticatorBase.doLogin(AuthenticatorBase.java:820)
   at org.apache.catalina.authenticator.AuthenticatorBase.login(AuthenticatorBase.java:800)
   at org.apache.catalina.connector.Request.login(Request.java:2612)
   at org.apache.catalina.connector.RequestFacade.login(RequestFacade.java:1064)
   at pack2.RequestHandlingOperation.doPost(RequestHandlingOperation.java:22)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:724)
  </code></pre>