Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

Entity stream is closed in container response filter

$
0
0

I am trying to capture the request body string using entity stream in both request filter and response filter. But when I try to fetch request body string entity stream in the response filter, I get the entity stream closed exception. Is there a way where I can use the entity stream in the response filter. Basically, I want to get the request string in both request and response filter. Any help is appreciated

@Overridepublic void filter(ContainerRequestContext requestContext) {        InputStream entityStream = requestContext.getEntityStream();        byte[] entityBytes = entityStream.readAllBytes();        String requestBody = new String(entityBytes, StandardCharsets.UTF_8);}@Overridepublic void filter(ContainerRequestContext requestContext,ContainerResponseContext responseContext) {        InputStream entityStream = requestContext.getEntityStream(); //This throws entity close exception. I need request in response filter}

Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>