Http-status 401 Diese Anfrage erfordert eine HTTP-Authentifizierung (). in tomcat 6

Entwickelt ich eine web-Anwendung
Http-status 401 Diese Anfrage erfordert eine HTTP-Authentifizierung (). in tomcat 6

wenn ich die Anwendung im tomcat 6 fragt er nach Benutzername und Passwort
aber nach 3 attempsts es zeigt
Http-status 401 Diese Anfrage erfordert eine HTTP-Authentifizierung (). in tomcat 6
die web.xml Dokument ist

<?xml version="1.0" encoding="UTF-8"?>
<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">
  <display-name>LoginRemote</display-name>
  <welcome-file-list>

    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>

    <description></description>
    <display-name>remoteSample</display-name>
    <servlet-name>remoteSample</servlet-name>
    <servlet-class>com.src.remoteSample</servlet-class>
  </servlet>

  <servlet-mapping>

    <servlet-name>remoteSample</servlet-name>
    <url-pattern>/remoteSample</url-pattern>
  </servlet-mapping>
  <security-constraint>
      <web-resource-collection>
        <web-resource-name>Secure</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
      </web-resource-collection>
     <auth-constraint>
            <role-name>*</role-name>
        </auth-constraint>


    </security-constraint>
<login-config>
  <auth-method>BASIC</auth-method>
  <realm-name>Authentication required</realm-name>
</login-config>
<security-role>
      <role-name>*</role-name>
   </security-role>
</web-app>

möchte ich, um die remote-Benutzer den Benutzernamen und Passwort, was soll ich tun für Sie?
dies ist mein servlet-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
    }

}

sollte ich etwas ändern in meinem server tomcat-server.xml und web.xml?

  • waren Sie in der Lage, dieses Problem zu beheben?
  • Nein, Sie sollten die erforderliche Authentifizierung an den client. Poste keine Bilder von text hier. Den text posten.
InformationsquelleAutor ambrosia1993 | 2015-02-06
Schreibe einen Kommentar