title: Http status 401 This request requires HTTP authentication (). in tomcat 6
body: <p>I have developed a web application 
  <img src="https://i.stack.imgur.com/kOsO5.png" alt="enter image description here"></p>
  
  <p>if i run the application in tomcat 6 it asks for username and password
  but after 3 attempsts it shows
  <img src="https://i.stack.imgur.com/dcuyi.png" alt="enter image description here">
  the web.xml document is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;LoginRemote&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
  
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
    &lt;servlet&gt;
  
      &lt;description&gt;&lt;/description&gt;
      &lt;display-name&gt;remoteSample&lt;/display-name&gt;
      &lt;servlet-name&gt;remoteSample&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.src.remoteSample&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
  
      &lt;servlet-name&gt;remoteSample&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/remoteSample&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;security-constraint&gt;
        &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;Secure&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
          &lt;http-method&gt;GET&lt;/http-method&gt;
          &lt;http-method&gt;POST&lt;/http-method&gt;
        &lt;/web-resource-collection&gt;
       &lt;auth-constraint&gt;
              &lt;role-name&gt;*&lt;/role-name&gt;
          &lt;/auth-constraint&gt;
  
  
      &lt;/security-constraint&gt;
  &lt;login-config&gt;
    &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
    &lt;realm-name&gt;Authentication required&lt;/realm-name&gt;
  &lt;/login-config&gt;
  &lt;security-role&gt;
        &lt;role-name&gt;*&lt;/role-name&gt;
     &lt;/security-role&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>i want  to get the remote user's user name and password what should i do for it?
  this is my servlet code</p>
  
  <pre><code>package com.src;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.Enumeration;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.tomcat.util.buf.Base64;
  
  public class remoteSample extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      /**
       * @see HttpServlet#HttpServlet()
       */
      public remoteSample() {
          super();
          // TODO Auto-generated constructor stub
      }
  
      /**
       * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
  
          response.setContentType("text/html;charset=UTF-8");
          System.out.println("login info:"+request.getRemoteUser());
          System.out.println("Authentication type:"+request.getAuthType());
  
      }
  
      /**
       * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
      }
  
  }
  </code></pre>
  
  <p>should i change something in my server's tomcat-server.xml and web.xml?</p>