• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I use getRemoteUser()

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic