From f63fcae531e50564b084547c5f99463d9141d9d8 Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 24 Nov 2010 00:32:13 +0100 Subject: [PATCH] fix image type --- .../controller/CaptchaController.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java b/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java index 05af4e1b..0831c57e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java @@ -45,23 +45,20 @@ public class CaptchaController public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { - - byte[] captchaChallengeAsJpeg; - // the output stream to render the captcha image as jpeg into - final ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream(); - - // get the session id that will identify the generated captcha. - //the same id must be used to validate the response, the session id is a good candidate! - final String captchaId = request.getSession().getId(); - - // call the ImageCaptchaService getChallenge method - final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale()); - // flush it in the response response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); - response.setContentType("image/jpeg"); + response.setContentType("image/png"); + + // get the session id that will identify the generated captcha. + //the same id must be used to validate the response, the session id is a good candidate! + final String captchaId = request.getSession().getId(); + + // call the ImageCaptchaService getChallenge method + final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale()); + + // flush it in the response final ServletOutputStream responseOutputStream = response.getOutputStream(); ImageIO.write(challenge, "png", responseOutputStream); responseOutputStream.flush();