1 4 5 9 10 package org.openlaszlo.servlets.responders; 11 12 import java.io.*; 13 import java.util.Properties ; 14 import javax.servlet.ServletConfig ; 15 import javax.servlet.ServletException ; 16 import javax.servlet.ServletOutputStream ; 17 import javax.servlet.http.HttpSession ; 18 import javax.servlet.http.HttpServletRequest ; 19 import javax.servlet.http.HttpServletResponse ; 20 import org.openlaszlo.utils.FileUtils; 21 import org.openlaszlo.utils.StringUtils; 22 import org.apache.log4j.Logger; 23 24 public final class ResponderXML extends ResponderCompile 25 { 26 private static Logger mLogger = Logger.getLogger(ResponderXML.class); 27 28 33 protected long getLastModified(String fileName, HttpServletRequest req) 34 { 35 return new File(fileName).lastModified(); 38 } 39 40 43 protected void respondImpl(String fileName, HttpServletRequest req, 44 HttpServletResponse res) 45 throws IOException 46 { 47 mLogger.info("Responding with XML for " + fileName); 48 if (fileName.endsWith(".lzo")) { 49 fileName = StringUtils.setCharAt(fileName, fileName.length() - 1, 'x'); 50 } 51 52 ServletOutputStream out = res.getOutputStream(); 53 try { 54 res.setContentType ("text/xml"); 55 out.print(FileUtils.readFileString(new File(fileName))); 56 } finally { 57 FileUtils.close(out); 58 } 59 } 60 61 public int getMimeType() 62 { 63 return MIME_TYPE_XML; 64 } 65 } 66 | Popular Tags |