- public void showimg(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleException
- {
- String idParam = req.getParameter("id");
- if (idParam!=null && !idParam.equals("")) {
- try {
- EntityImages entImage =(EntityImages)mainModule.getById(idParam);
- ServletContext ctx =
- (ServletContext)MirConfig.getPropAsObject("ServletContext");
- String fName = entImage.getId()+"."
- +entImage.getMediaType().getValue("name");
- res.setContentType(ctx.getMimeType(fName));
- ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
-
- InputStream in = entImage.getImage();
- int read;
- byte[] buf = new byte[8 * 1024];
- while((read = in.read(buf)) != -1) {
- out.write(buf, 0, read);
- }
- in.close();
- out.close();
- }
-
- catch (IOException e) {throw new ServletModuleException(e.toString());}
- catch (ModuleException e) {throw new ServletModuleException(e.toString());}
- catch (Exception e) {throw new ServletModuleException(e.toString());}
- }
- else theLog.printDebugInfo("id nicht angeben.");
- // darf keine exception werfen
- }
-
- public void showicon(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleException
- {
- String idParam = req.getParameter("id");
- if (idParam!=null && !idParam.equals("")) {
- try {
- EntityImages entImage =(EntityImages)mainModule.getById(idParam);
- ServletContext ctx =
- (ServletContext)MirConfig.getPropAsObject("ServletContext");
- String fName = entImage.getId()+"."
- +entImage.getMediaType().getValue("name");
- res.setContentType(ctx.getMimeType(fName));
- ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
-
- InputStream in = entImage.getIcon();
- int read;
- byte[] buf = new byte[8 * 1024];
- while((read = in.read(buf)) != -1) {
- out.write(buf, 0, read);
- }
- in.close();
- //out.write(outbytes);
- out.close();
- }
-
- catch (IOException e) {throw new ServletModuleException(e.toString());}
- catch (ModuleException e) {throw new ServletModuleException(e.toString());}
- catch (Exception e) {throw new ServletModuleException(e.toString());}
- }
- else throw new ServletModuleException("id nicht angeben.");
- }