• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I use getRemoteUser()  RSS feed

 
Shuaib Gill
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have this code right now:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class AuthorizationSnoop extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();

out.println("<html><head><title>Authorization snoop</title></head><body>");
out.println("<h1>This is a password protected resource</h1>");
out.println("<pre>");
out.println("user name: " + req.getRemoteUser());
out.println("authorization type: " + req.getAuthType());
out.println("</pre>");
out.println("</body></html>");
}// end doGet

}// end class
The output gives values of null for both getRemoteUser() and getAuthType() also. Which front end application could I use for this servlet? I would like to test a username and then see what getRemoteUser() would return. Should I use forms in HTML page? In that case I would have to pass parameters, but getRemoteUser() does not accept parameters.
How could I use getRemoteUser() and get a value other than null?
Thanks in advance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!