简体   繁体   中英

GAE handling simple http post request (java)

i'm trying to make out with web-apps on java using google app engine. i have an application that is sending http-post request.

  1. Create a servlet on GAE that handles the POST:

     public class ExampleAppServlet extends HttpServlet{ public void doPost(HttpServletRequest req, HttpServletResponse resp) { // get some data from POST InputStream input = req.getInputStream(); // do something with input // send back some reply resp.getWriter().write("Hello Example App").close(); } } 
  2. Map this servlet to URL in web.xml config file :

     <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> <servlet> <servlet-name>example_app_servlet</servlet-name> <servlet-class>com.package.ExampleAppServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>example_app_servlet</servlet-name> <url-pattern>/example_app</url-pattern> </servlet-mapping> </web-app> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM