1 4 5 9 10 package org.openlaszlo.servlets.responders; 11 12 import java.io.*; 13 import java.net.URL ; 14 import java.util.Properties ; 15 import javax.servlet.RequestDispatcher ; 16 import javax.servlet.ServletConfig ; 17 import javax.servlet.ServletException ; 18 import javax.servlet.ServletOutputStream ; 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 import org.openlaszlo.utils.LZHttpUtils; 22 import org.openlaszlo.utils.StringUtils; 23 import org.apache.log4j.Logger; 24 25 public final class ResponderFILTER extends ResponderCompile 26 { 27 private static Logger mLogger = Logger.getLogger(ResponderFILTER.class); 28 29 34 protected long getLastModified(String fileName, HttpServletRequest req) 35 { 36 return new File(fileName).lastModified(); 39 } 40 41 44 protected void respondImpl(String fileName, HttpServletRequest req, 45 HttpServletResponse res) 46 throws IOException 47 { 48 mLogger.info("Responding with FILTER for " + fileName); 49 if (fileName.endsWith(".lzo")) { 50 fileName = StringUtils.setCharAt(fileName, fileName.length() - 1, 'x'); 51 } 52 53 try { 54 URL url = LZHttpUtils.getRequestURL(req); 58 req.setAttribute ("LZF_URL", url.toString()); 59 req.setAttribute ("LZF_FILENAME", fileName); 60 req.setAttribute ("LZF_COMPMGR", mCompMgr); 61 String FILTER = req.getParameter("filter"); 62 mLogger.debug("FILTER is " + FILTER); 63 RequestDispatcher dispatcher = mContext.getRequestDispatcher(FILTER); 64 if (dispatcher==null) { 65 res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 66 "Bad or undefined filter: " + FILTER); 67 mLogger.debug("Bad or undefined filter: " + FILTER); 68 return; 69 } 70 dispatcher.forward(req, res); 71 72 } catch (IOException e) { 73 e.printStackTrace(); 79 } catch (Exception e) { 80 respondWithException(res, e); 81 } 82 } 83 84 public int getMimeType() 85 { 86 return MIME_TYPE_HTML; 87 } 88 89 } 90 | Popular Tags |