Package com.saya.servlet

Source Code of com.saya.servlet.TestServlet

package com.saya.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.saya.utils.Constant;

@SuppressWarnings("serial")
public class TestServlet extends HttpServlet {
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    String token = req.getParameter(Constant.TOKEN);

    Key k = KeyFactory.stringToKey(token);
    try {
      System.out.println(k.getId());
      Entity e = ds.get(k);
      resp.getWriter().print(e.getProperty("LoginDate"));
    } catch (EntityNotFoundException e) {
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of com.saya.servlet.TestServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.