@RequestMapping(value = "/anschauen/{id}/qr", method = RequestMethod.GET)
 public void showQRCode(
     @PathVariable("id") String id, HttpServletRequest request, HttpServletResponse response)
     throws IOException {
   StringBuffer urlBuffer = request.getRequestURL();
   String url = urlBuffer.substring(0, urlBuffer.length() - "/qr".length());
   response.setContentType("image/png");
   OutputStream out = response.getOutputStream();
   QRCode.from(url).to(ImageType.PNG).writeTo(out);
   out.flush();
 }
 /**
  * Generate a QR Code and write it to a local file system as .jpg
  *
  * @param data
  * @return the name of the QR code generated.
  */
 public static boolean generateQRImage(String data) {
   String timePrint = String.valueOf(System.currentTimeMillis());
   ByteArrayOutputStream out = QRCode.from(data).to(ImageType.PNG).stream();
   generatedQR = "codes/" + timePrint + ".JPG";
   try {
     new File("codes").mkdir();
     File f = new File(generatedQR);
     f.createNewFile();
     try (FileOutputStream fout = new FileOutputStream(f)) {
       fout.write(out.toByteArray());
       fout.flush();
       fout.flush();
     }
     return true;
   } catch (FileNotFoundException e) {
     errorThrown += e.getMessage();
   } catch (IOException e) {
     errorThrown += e.getMessage();
   }
   return false;
 }