Question

Do not know why this (appended method from SomeActionBean.java) does not work on Google app engine? Localy everything runs perfect. Any idea where to look for solution?

 /**
 * @return Page to display, filled with correct data
 */
@DefaultHandler
public Resolution welcome() {
    Resolution fd = new ForwardResolution(VIEW);
    HttpServletRequest request = this.ctx.getRequest();
    if(request.getMethod() == "POST") { 
        String content = getRequestContent(request);
        updateData(content);
    }else if (request.getMethod() == "GET"){
        String ct = request.getContentType();
        if(("application/json").equals(ct))
            try {
                getNotesJson(); //fill returnJson global variable
                fd = new JSONResolution(returnJson);
                //TODO Spread to other entities
            } catch (JSONException e) {
                e.printStackTrace();
            }
    }
    return fd;
}
Was it helpful?

Solution

The String compares are wrong:

request.getMethod() == "POST"

Java Strings are not primitives thus they should be compared by equals method:

"POST".equals(request.getMethod())
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top