GoogleCloudPlatform / gradle-appengine-templates

Freemarker based templates that build with the gradle-appengine-plugin
438 stars 205 forks source link

Unable to Change Server Response #65

Closed troy21688 closed 8 years ago

troy21688 commented 8 years ago

I am ultimately trying to change the server response that I receive, which I understand is declared in the doPost() method. I have successfully set up a server interaction in this example, however I changed the server response per the code below:

public class MyServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    resp.setContentType("text/plain");
    resp.getWriter().println("Please use the form to POST to this url");
     }

@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    String name = req.getParameter("name");
    resp.setContentType("text/plain");
    if(name == null) {
        resp.getWriter().println("Please enter a name");
    }
    resp.getWriter().println("A test to change text" + name);
    }
}`

Can someone explain how I change the response I receive? I tried to simply change the text in this example, yet I would also like to find out how to receive an int or boolean as well.

patflynn commented 8 years ago

@troy21688 Sorry Troy but you are asking these questions in the wrong forum. Stack Overflow is the right place to get help with this.

patflynn commented 8 years ago

http://stackoverflow.com/questions/tagged/google-app-engine