Testing Extract Servlet Meta data | Community
Skip to main content
New Participant
May 1, 2022
Solved

Testing Extract Servlet Meta data

  • May 1, 2022
  • 1 reply
  • 827 views

SlingHttpServletResponse.getOutStream is coming as null while running the test case

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by narendragandhi

Hi,

 

getOutputStream is used for writing the binary content. If I understand your usecase correctly you are trying to read from the servlet response. In this case you can do something like -

 

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(response.getOutput());
BufferedImage image = ImageIO.read(byteArrayInputStream);

and then you can read metadata from the image object. 

1 reply

narendragandhi
narendragandhiAccepted solution
New Participant
May 4, 2022

Hi,

 

getOutputStream is used for writing the binary content. If I understand your usecase correctly you are trying to read from the servlet response. In this case you can do something like -

 

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(response.getOutput());
BufferedImage image = ImageIO.read(byteArrayInputStream);

and then you can read metadata from the image object.