1 4 5 9 10 package org.openlaszlo.servlets.responders; 11 12 import java.io.*; 13 import javax.servlet.http.HttpServletRequest ; 14 import javax.servlet.http.HttpServletResponse ; 15 import javax.servlet.ServletOutputStream ; 16 import org.openlaszlo.compiler.Compiler; 17 import org.openlaszlo.compiler.CompilationEnvironment; 18 import org.openlaszlo.media.MimeType; 19 import org.openlaszlo.sc.ScriptCompiler; 20 import org.openlaszlo.utils.FileUtils; 21 import org.apache.log4j.Logger; 22 23 public final class ResponderEVAL extends Responder 24 { 25 private static Logger mLogger = Logger.getLogger(ResponderEVAL.class); 26 27 protected void respondImpl(HttpServletRequest req, HttpServletResponse res) 28 throws IOException 29 { 30 ServletOutputStream out = res.getOutputStream(); 31 32 String script = req.getParameter("lz_script"); 33 boolean logmsg = false; 34 35 String seqnum = req.getParameter("lzrdbseq"); 36 37 String lz_log = req.getParameter("lz_log"); 38 39 if ((lz_log != null) && lz_log.equals("true")) { 40 logmsg = true; 41 } 42 43 if (logmsg) { 44 mLogger.info("CLIENT_LOG " + script); 46 byte[] action = new byte[0]; 47 int swfversion = 5; 48 ScriptCompiler.writeScriptToStream(action, out, swfversion); 49 out.flush(); 50 FileUtils.close(out); 51 } else { 52 mLogger.info("doEval for " + script+", seqnum="+seqnum); 53 try { 54 res.setContentType(MimeType.SWF); 55 Compiler compiler = new Compiler (); 56 String swfversion = req.getParameter("lzr"); 57 if (swfversion == null) { 60 swfversion = "swf5"; 61 } 62 compiler.compileAndWriteToSWF(script, seqnum, out, swfversion); 63 } catch (Exception e) { 64 mLogger.info("LZServlet got error compiling/writing SWF!" + e); 65 StringWriter err = new StringWriter(); 66 e.printStackTrace(new PrintWriter(err)); 67 mLogger.info(err.toString()); 68 } 69 } 70 } 71 72 public int getMimeType() 73 { 74 return MIME_TYPE_SWF; 75 } 76 } 77 | Popular Tags |