KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > NtlmHttpAuthExample


1 import java.io.*;
2 import javax.servlet.*;
3 import javax.servlet.http.*;
4
5 public class NtlmHttpAuthExample extends HttpServlet {
6
7     public void doGet( HttpServletRequest req,
8                 HttpServletResponse resp ) throws IOException, ServletException {
9         PrintWriter out = resp.getWriter();
10
11         resp.setContentType( "text/html" );
12         out.println( "<HTML><HEAD><TITLE>NTLM HTTP Authentication Example</TITLE></HEAD><BODY>" );
13         out.println( "<h2>NTLM HTTP Authentication Example</h2>" );
14
15         out.println( req.getRemoteUser() + " successfully logged in" );
16
17         out.println( "<h3>Please submit some form data using POST</h3>" );
18         out.println( "<form action=\"NtlmHttpAuthExample\" method=\"post\">" );
19         out.println( "<input type=\"text\" name=\"field1\" size=\"20\"/>" );
20         out.println( "<input type=\"submit\"/>" );
21         out.println( "</form>" );
22
23         out.println( "field1 = " + req.getParameter( "field1" ));
24
25         out.println( "</BODY></HTML>" );
26     }
27     public void doPost( HttpServletRequest req,
28                 HttpServletResponse resp ) throws IOException, ServletException {
29         doGet( req, resp );
30     }
31 }
32
33
Popular Tags