Check your application log. On Wednesday, November 28, 2012 4:21:54 PM UTC+1, bo wrote: > > Hi, > I just tried my first java servlet with google app engine. It works fine > at localhost (Eclipse: Run As > Web Application), but it dosen't work at > the Google App Engine (500 Server Error). > > The error message is not really meaningful. > > Error: Server ErrorThe server encountered an error and could not complete >> your request. >> >> If the problem persists, please >> report<http://code.google.com/appengine/community.html> your >> problem and mention this error message and the query that caused it. >> > How can I proceed to find the problem? > > package de.bvl.myhighscoreserver; > > import java.io.IOException; > > import java.util.List; > > import javax.servlet.http.*; > > > 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.FetchOptions; > import com.google.appengine.api.datastore.Key; > import com.google.appengine.api.datastore.KeyFactory; > import com.google.appengine.api.datastore.Query; > > > @SuppressWarnings("serial") > public class MyHighscoreServerServlet extends HttpServlet { > public void doGet(HttpServletRequest req, HttpServletResponse resp) > throws IOException { > String game = req.getParameter("game"); > String name = req.getParameter("name"); > String pointsStr = req.getParameter("points"); > String maxStr = req.getParameter("max"); > int max = 10; > if(maxStr!= null){ > max = Integer.parseInt(maxStr); > } > int points = 0; > if(pointsStr != null){ > points = Integer.parseInt(pointsStr); > } > if(points>0 && name!=null){ > addHighscore(game,name,points); > } > returnHighscores(resp,game,max); > } > private void returnHighscores(HttpServletResponse resp, String game, int > max) throws IOException { > // TODO Auto-generated method stub > DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); > Key gameKey = KeyFactory.createKey("game", game); > Query query = new Query("highscore", gameKey); > query.addSort("points", Query.SortDirection.DESCENDING); > List<Entity> highscores = > datastore.prepare(query).asList(FetchOptions.Builder.withLimit(max)); > for(Entity e : highscores){ > resp.getWriter().println(e.getProperty("name")+","+ > e.getProperty("points")); > } > } > private void addHighscore(String game, String name, int points){ > DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); > Key gameKey = KeyFactory.createKey("game", game); > Entity highscore = new Entity("highscore",gameKey); > highscore.setProperty("name", name); > highscore.setProperty("points", points); > datastore.put(highscore); > } > } > > THX in advance > Bo >
-- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/XdlQ9wWCSaAJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
