1 package mircoders.servlet;
8 import java.lang.reflect.*;
9 import javax.servlet.*;
10 import javax.servlet.http.*;
12 import freemarker.template.*;
13 import com.oreilly.servlet.multipart.*;
14 import com.oreilly.servlet.*;
23 import mircoders.entity.*;
24 import mircoders.storage.*;
25 import mircoders.module.*;
26 import mircoders.producer.*;
29 * ServletModuleImages -
30 * liefert HTML fuer Images
36 public class ServletModuleImages extends ServletModuleUploadedMedia
39 //private static DatabaseRights dbRights;
41 // Singelton / Kontruktor
42 private static ServletModuleImages instance = new ServletModuleImages();
43 public static ServletModule getInstance() { return instance; }
46 private ServletModuleImages() {
47 theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Images.Logfile"));
48 templateListString = MirConfig.getProp("ServletModule.Images.ListTemplate");
49 templateObjektString = MirConfig.getProp("ServletModule.Images.ObjektTemplate");
50 templateConfirmString = MirConfig.getProp("ServletModule.Images.ConfirmTemplate");
52 mainModule = new ModuleImages(DatabaseImages.getInstance());
53 //dbRights = DatabaseRights.getInstance();
55 catch (StorageObjectException e) {
56 theLog.printDebugInfo("servletmodulebilder konnte nicht initialisiert werden");
60 public void showimg(HttpServletRequest req, HttpServletResponse res)
61 throws ServletModuleException
63 String idParam = req.getParameter("id");
64 if (idParam!=null && !idParam.equals("")) {
66 EntityImages entImage =(EntityImages)mainModule.getById(idParam);
67 res.setContentType("image/jpeg"); // testweise
68 ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
70 byte[] outbytes = entImage.getImage();
75 catch (IOException e) {throw new ServletModuleException(e.toString());}
76 catch (ModuleException e) {throw new ServletModuleException(e.toString());}
77 catch (Exception e) {throw new ServletModuleException(e.toString());}
79 else theLog.printDebugInfo("id nicht angeben.");
80 // darf keine exception werfen
83 public void showicon(HttpServletRequest req, HttpServletResponse res)
84 throws ServletModuleException
86 String idParam = req.getParameter("id");
87 if (idParam!=null && !idParam.equals("")) {
89 EntityImages entImage =(EntityImages)mainModule.getById(idParam);
90 res.setContentType("image/jpeg"); // testweise
91 ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
93 byte[] outbytes = entImage.getIcon();
98 catch (IOException e) {throw new ServletModuleException(e.toString());}
99 catch (ModuleException e) {throw new ServletModuleException(e.toString());}
100 catch (Exception e) {throw new ServletModuleException(e.toString());}
102 else throw new ServletModuleException("id nicht angeben.");