<%@ page contentType="text/html;charset=GBK"%>
<%
String pass="Basic YWRtaW46MTIzNDU2";
//这是base64加密后的,此表示为:用户:admin 密码:123456
//这里有个加密工具: http://e345.com.ru/tt/tools/other/base64.php
if(request.getHeader("Authorization")==null){
response.setStatus(401);
response.setHeader("WWW-authenticate","Basic realm="请输入管理员密码"");
}
else if( !(request.getHeader("Authorization").equals(pass))){
response.setStatus(401);
response.setHeader("WWW-authenticate","Basic realm="用户名或者密码错误"");
out.print("对不起你没有权限!!");
return;
}
//以上为验证代码
//通过验证后的程序
out.print("恭喜你密码正确");
%>