@Override
    protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
            throws IOException {
        byte[] serializedRequestEnvelope = IOUtils.toByteArray(request.getInputStream());
        try {
            final RequestEnvelope deserializedRequestEnvelope = serializer.deserialize(IOUtils.toString(
                    serializedRequestEnvelope, ServletConstants.CHARACTER_ENCODING), RequestEnvelope.class);

            // Verify the authenticity of the request by executing configured verifiers.
            for (SkillServletVerifier verifier : verifiers) {
                verifier.verify(request, serializedRequestEnvelope, deserializedRequestEnvelope);
            }

            ResponseEnvelope skillResponse = skill.invoke(deserializedRequestEnvelope);
            // Generate JSON and send back the response
            response.setContentType("application/json");
            response.setStatus(HttpServletResponse.SC_OK);
            if (skillResponse != null) {
                byte[] serializedResponse = serializer.serialize(skillResponse).getBytes(StandardCharsets.UTF_8);
                try (final OutputStream out = response.getOutputStream()) {
                    response.setContentLength(serializedResponse.length);
                    out.write(serializedResponse);
                }
            }
        } catch (SecurityException ex) {
            int statusCode = HttpServletResponse.SC_BAD_REQUEST;
            log.error("Incoming request failed verification {}", statusCode, ex);
            response.sendError(statusCode, ex.getMessage());
        } catch (AskSdkException ex) {
            int statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
            log.error("Exception occurred in doPost, returning status code {}", statusCode, ex);
            response.sendError(statusCode, ex.getMessage());
        }
    }
@ Override protected void doPost ( final HttpServletRequest request , final HttpServletResponse response ) throws IOException { byte [ ] serializedRequestEnvelope = IOUtils . toByteArray ( request . getInputStream ( ) ) ; try { final RequestEnvelope deserializedRequestEnvelope = serializer . deserialize ( IOUtils . toString ( serializedRequestEnvelope , ServletConstants . CHARACTER_ENCODING ) , RequestEnvelope . class ) ; for ( SkillServletVerifier verifier : verifiers ) { verifier . verify ( request , serializedRequestEnvelope , deserializedRequestEnvelope ) ; } ResponseEnvelope skillResponse = skill . invoke ( deserializedRequestEnvelope ) ; response . setContentType ( "application/json" ) ; response . setStatus ( HttpServletResponse . SC_OK ) ; if ( skillResponse != null ) { byte [ ] serializedResponse = serializer . serialize ( skillResponse ) . getBytes ( StandardCharsets . UTF_8 ) ; try ( final OutputStream out = response . getOutputStream ( ) ) { response . setContentLength ( serializedResponse . length ) ; out . write ( serializedResponse ) ; } } } catch ( SecurityException ex ) { int statusCode = HttpServletResponse . SC_BAD_REQUEST ; log . error ( "Incoming request failed verification {}" , statusCode , ex ) ; response . sendError ( statusCode , ex . getMessage ( ) ) ; } catch ( AskSdkException ex ) { int statusCode = HttpServletResponse . SC_INTERNAL_SERVER_ERROR ; log . error ( "Exception occurred in doPost, returning status code {}" , statusCode , ex ) ; response . sendError ( statusCode , ex . getMessage ( ) ) ; } }
Handles a POST request. Based on the request parameters, invokes the right method on the
{@code Skill}.

@param request  the object that contains the request the client has made of the servlet
@param response object that contains the response the servlet sends to the client
@throws IOException if an input or output error is detected when the servlet handles the request