views:

42

answers:

1

public class MyServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { UserService userService = UserServiceFactory.getUserService();

    String thisURL = request.getRequestURI();
    if (request.getUserPrincipal() != null) {
        response.getWriter().println("<p>Hello, " +
                                     request.getUserPrincipal().getName() +
                                     "!  You can <a href=\"" +
                                     userService.createLogoutURL(thisURL) +
                                     "\">sign out</a>.</p>");
        System.out.println("<p>Hello, " +
                request.getUserPrincipal().getName() +
                "!  You can <a href=\"" +
                userService.createLogoutURL(thisURL) +
                "\">sign out</a>.</p>");
    } else {
        response.getWriter().println("<p>Please <a href=\"" +
                                     userService.createLoginURL(thisURL) +
                                     "\">sign in</a>.</p>");
    }
}

}

Where should i call this servlet from?

A: 

After configuring your servlet in the web.xml file, you call the URL you defined in the servlet mapping.

DouglasJose
But i am using gwt uibinder.
Vishakha Gupta