I think they set proxy.

解决方案 »

  1.   

    java servlet 例子;
    只要在Header 里加"WWW-Authenticate", "BASIC realm=basicauth servlet"这句就会弹出输入用户和密码的对话框。import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import sun.misc.*;   // for Base64Decoder methodpublic class basicauth extends HttpServlet{
     Hashtable users = new Hashtable(); // user:password list public void init(ServletConfig config) throws ServletException {
      super.init(config);
      users.put("billgates:imrich", "allowed"); // for testing purpose...
      } public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException{
      PrintWriter out = response.getWriter();
      String auth = request.getHeader("Authorization");   // user name: BASE64 encoded
      if(allowUser(auth)){
        out.println("ok youre in!");
        }
      else{
        response.setHeader("WWW-Authenticate", "BASIC realm=\"basicauth servlet\"");
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        response.sendError(response.SC_UNAUTHORIZED);  // HTTP 401
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        }
      } public void doPost(HttpServletRequest request, HttpServletResponse response) 
        throws ServletException, IOException{
      doGet(request, response);
      } protected boolean allowUser(String auth) throws IOException{
      if(auth == null){
        return false;
        }
      if(!auth.toUpperCase().startsWith("BASIC ")){
        return false;
        }
      String userPwdEncoded = auth.substring(6);  // removes 'BASIC '
      BASE64Decoder decoder = new BASE64Decoder();
      String userPwdDecoded = new String(decoder.decodeBuffer(userPwdEncoded));
      return "allowed".equals(users.get(userPwdDecoded))
      }
    }
      

  2.   

    I try following in html file, but the message box did not appear
    what's different with setHeader and the meta tag.<meta http-equiv="WWW-Authenticate" content="BASIC realm='basicauth servlet'">
      

  3.   

    简单方便的方法:
    如果你的机子安装了IIS,那么把XXX。HTM文件设一下密码(很简单的,傻瓜都会),接着就会有这种效果了!!
      

  4.   

    是不是IIS才会出现这种效果,tomcat就不行吧
      

  5.   

    那不是用JSSCRIPT做的,是在IIS中设置的,如果你不知道这些那你还是学学IIS吧
      

  6.   

    很简单在IIS设置,后台验证。