Question

I was trying to interate User Service to my App to restrict access. The app worked fine while in eclipse but once I deployed it to app engine it does not redirect to Google Login page as expected but comes with Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds. This is a section of the servlet used:

import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class MyLogin  extends HttpServlet {

    private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    UserService userService = UserServiceFactory.getUserService();

    String thisURL = "/home.html";

    resp.setContentType("text/html");
    if (req.getUserPrincipal() != null) {
        resp.getWriter().println("<p>Hello, " +
                                 req.getUserPrincipal().getName() +
                                 "!  You can <a href=\"" +
                                 userService.createLogoutURL(thisURL) +
                                 "\">sign out</a>.</p>");
    } else {
        resp.getWriter().println("<p>Please <a href=\"" +
                                 userService.createLoginURL(thisURL) +
                                 "\">sign in</a>.</p>");
    }
}
}
Was it helpful?

Solution

I was able to solve this problem by moving the files I intend to protect out of the root directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top