Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I use getRemoteUser()

Shuaib Gill
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this code right now:
import javax.servlet.*;
import javax.servlet.http.*;
public class AuthorizationSnoop extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException
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("user name: " + req.getRemoteUser());
out.println("authorization type: " + req.getAuthType());
}// 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic