Error in POST request (Java EE)

53 views Asked by At

I work with Vkontakte callback api and I write bot in Java using tomcat.

In callback api doc exist sample on php:

$data = json_decode(file_get_contents('php://input'));

So data reply in POST format.

In my server POST request exist, but request is empty

This is my Java code:

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
    resp.setContentType("text/html;charset=utf-8");

    PrintWriter pw = resp.getWriter();
    String type = (String) req.getParameterMap().toString();

    if (type != null) {
        switch (type) {
        case "confirmation":
            pw.print(confirm_token);
            break;
        default:
            pw.print(req.getParameterMap().size());
            break;
        }
    } else {
        pw.print("error");
    }

}

Please help me.

0

There are 0 answers