package clock;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
@SuppressWarnings(serial)
public class ClockServlet extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws IOException, ServletException {
SimpleDateFormat fmt = new SimpleDateFormat(-MM-dd
hh:mm:ss.SS);
fmt.setTimeZone(new SimpleTimeZone(0, ));
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
String loginUrl = userService.createLoginURL(/);
String logoutUrl = userService.createLogoutURL(/);
req.setAttribute(user, user);
req.setAttribute(loginUrl, loginUrl);
req.setAttribute(logoutUrl, logoutUrl);
req.setAttribute(currentTime, fmt.format(new Date()));
resp.setContentType(text/html);
RequestDispatcher jsp =
req.getRequestDispatcher(/WEB-INF/home.jsp);
jsp.forward(req, resp);
}
}
---
%@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
html
head
titleThe Time Is.../title
/head
body
c:choose
c:when test=${user != null}
p
Welcome, ${user.email}!
You can a href=${logoutUrl}sign out/a.
/p
/c:when
c:otherwise
p
Welcome!
a href=${loginUrl}Sign in or register/a to customize.
/p
/c:otherwise
/c:choose
pThe time is: ${currentTime}/p
/body
/html
-
Even though I am signed in to my Google Account in Chrome I am still seeing
Sign in or register not Welcome as I expected. When I click Sign in I am
forwarded to a page with one text field to enter an email and a check box
to sign in as administrator. There must be something wrong because I think
since I am logged into gmail it should display welcome?
Thanks in advance...
--
You received this message because you are subscribed to the Google Groups
Google App Engine group.
To unsubscribe from this group and stop receiving emails from it, send an email
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.