The Code is as follows:
<% @ Page import = "java. SQL. *, javax. SQL. *, javax. naming. *, com. maxcard. util. *" %>
<Html>
<Head>
<Title> New Document </title>
</Head>
<Body>
<%
If (request. getHeader ("Authorization") = null ){
Response. setStatus (401 );
Response. setHeader ("WWW-authenticate", "Basic realm =" www.maxcard.com "");
} Else {
// Obtain the input information
String encoded = (request. getHeader ("Authorization "));
// Use Base64 for encoding conversion
String up = StringUtil. decodeBase64 (encoded );
String user = "";
String password = "";
If (up! = Null ){
// Retrieve the username and password
User = up. substring (0, up. indexOf (":"));
Password = up. substring (up. indexOf (":") + 1 );
}
If (user. equals ("david") & password. equals ("maxcard ")){
Out. print ("authentication successful ");
} Else {
Out. print ("authentication failed ");
}
}
%>
</Body>
</Html>
Related toolkit download: http://www.bcxy.com/java/dbutil.htm