| | |
| | | import java.awt.Toolkit; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.URLDecoder; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import javax.servlet.ServletException; |
| | |
| | | String uriStr = request.getRequestURI(); |
| | | String relname = uriStr.substring(request.getContextPath().length()); |
| | | |
| | | /* |
| | | File urifile = new File(uriStr); |
| | | uriStr = uriStr.substring(request.getContextPath().length()); |
| | | File dir = new File(request.getServletContext().getRealPath("/")); |
| | | File imgfile = new File(dir, uriStr); |
| | | |
| | | // --- Logausgabe Start |
| | | File logurifile = new File(uriStr); |
| | | String loguriStr = uriStr.substring(request.getContextPath().length()); |
| | | File logdir = new File(request.getServletContext().getRealPath("/")); |
| | | File logimgfile = new File(logdir, loguriStr); |
| | | StringBuffer buf = new StringBuffer(); |
| | | buf.append("contextPath: "); |
| | | buf.append(request.getContextPath()); |
| | |
| | | buf.append(request.getServletContext().getRealPath("/")); |
| | | buf.append("\n"); |
| | | buf.append("urifile: "); |
| | | buf.append(urifile.getAbsolutePath()); |
| | | buf.append(logurifile.getAbsolutePath()); |
| | | buf.append("\n"); |
| | | buf.append("imgfile: "); |
| | | buf.append(imgfile.getAbsolutePath()); |
| | | buf.append(logimgfile.getAbsolutePath()); |
| | | logger.fine(buf.toString()); |
| | | */ |
| | | |
| | | // --- Logausgabe Ende |
| | | |
| | | if(uriStr.contains(TN) && (uriStr.endsWith(JPG) || uriStr.endsWith(JPEG) || uriStr.endsWith(PNG))) { |
| | | /* |
| | | TODO: hier mit Hilfe der Klasse Bild eine Miniaturansicht erzeugen |
| | | und in die Antwort schreiben |
| | | */ |
| | | File dir = new File(request.getServletContext().getRealPath("/")); |
| | | relname = relname.replace(TN, ""); |
| | | File imgfile = new File(dir, relname); |
| | | File imgfile = new File(dir, URLDecoder.decode(relname, "utf-8")); |
| | | Image image = Toolkit.getDefaultToolkit().getImage(imgfile.getAbsolutePath()); |
| | | MediaTracker mediaTracker = new MediaTracker(new Container()); |
| | | mediaTracker.addImage(image, 0); |
| | |
| | | } catch (InterruptedException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | |
| | | } else { |
| | | super.doGet(request, response); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |