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.HttpUtils ; 18 import javax.servlet.http.HttpSession ; 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 import org.openlaszlo.compiler.Canvas; 22 import org.openlaszlo.utils.FileUtils; 23 import org.openlaszlo.utils.StringUtils; 24 import org.openlaszlo.utils.LZHttpUtils; 25 import org.apache.log4j.Logger; 26 27 public final class ResponderWINDOW extends ResponderCompile 28 { 29 private static Logger mLogger = Logger.getLogger(ResponderWINDOW.class); 30 31 36 protected long getLastModified(String fileName, HttpServletRequest req) 37 { 38 return new File(fileName).lastModified(); 41 } 42 43 46 protected void respondImpl(String fileName, HttpServletRequest req, 47 HttpServletResponse res) 48 throws IOException 49 { 50 mLogger.info("Responding with WINDOW for " + fileName); 51 if (fileName.endsWith(".lzo")) { 52 fileName = StringUtils.setCharAt(fileName, fileName.length() - 1, 'x'); 53 } 54 55 ServletOutputStream out = res.getOutputStream(); 56 try { 57 res.setContentType ("text/html"); 58 writeHeader(out, null); 59 String name = req.getParameter("NAME"); 60 if (name == null || name == "") 61 name = "LaszloWindow"; 62 String url = LZHttpUtils.getRequestURL(req).toString(); 63 writeScriptWindow(out, url, name, getCanvas(fileName, req)); 64 writeFooter(out); 65 } finally { 66 FileUtils.close(out); 67 } 68 } 69 70 76 protected void writeScriptWindow (ServletOutputStream out, String url, 77 String name, Canvas canvas) 78 throws IOException 79 { 80 int wd = canvas.getWidth(); 81 int ht = canvas.getHeight(); 82 83 out.println ("<script>"); 84 out.println (name + "= window.open('" + url + "', '" 85 + name + "', "); 86 out.print (" 'width=" + wd + ","); 87 out.print ("height=" + ht + ","); 88 out.print ("toolbar=no,location=no,directories=no,"); 89 out.print ("status=no,menubars=no,"); 90 out.println ("scrollbars=no,resizable=no')"); 91 out.println ("</script>"); 92 } 93 94 public int getMimeType() 95 { 96 return MIME_TYPE_HTML; 97 } 98 } 99 | Popular Tags |