I have a simple servlet that detects if a user has logged in and the sends 
a JSON response. On the browser, after logging into the dev server, I get 
the JSON response. But on Android, I'm sending the cookie (from auth token) 
in the header of the GET request, I get a response saying the user is null. 
How do I send the request from Android to App engine.

Servlet Code snippet:

User user = (User) req.getAttribute("user");
String cookie = (String) req.getHeader("Cookie");
System.out.println("Cookie "+cookie);
System.out.println(user);
if(user == null){
System.out.println("user is null.. getting current user");
UserService userService = UserServiceFactory.getUserService();
user = userService.getCurrentUser();
System.out.println(user);
//resp.getWriter().println("Null User");
}
if(user != null){
MyUser users[] = new MyUser[5];
users[0] = new MyUser("[email protected]", "Sheldon Cooper", "");
users[1] = new MyUser("[email protected]", "Leonard Hofstader", "");
users[2] = new MyUser("[email protected]", "Rajesh Kuthrapali", "");
users[3] = new MyUser("[email protected]", "Penny Sunflower", "");
users[4] = new MyUser("[email protected]", "Howard", "");
resp.setContentType("application/json");
Gson gson = new Gson();
String s = gson.toJson(users);
resp.getWriter().print(s);
}


-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to