how to store these two values(s1&s2) in data store of AppEngine?
I have a Servlet in my AppEngine Application (I am using Eclipse):
开发者_JAVA百科public class ServletCheckServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
PrintWriter pw=resp.getWriter();
String s1=req.getParameter("username");
String s2=req.getParameter("password");
}
}
My question is, how do I store these two values(s1&s2) in data store of AppEngine?
Entity user = new Entity("User"); // define the entity type
user.setProperty("username", s1); // add some properties
user.setProperty("password", s2);
DatastoreServiceFactory.getDatastoreService().put(user); //save it
Though i would recommend calling these variables something better than s1 & s2 And not saving the password as plain text in favor of users logging into user app. Moreover, GAE has nice User Api to play with.
精彩评论