1 29 30 package com.caucho.servlets.ssi; 31 32 import com.caucho.vfs.Path; 33 import com.caucho.vfs.WriteStream; 34 35 import javax.servlet.RequestDispatcher ; 36 import javax.servlet.ServletException ; 37 import javax.servlet.http.HttpServletRequest ; 38 import javax.servlet.http.HttpServletResponse ; 39 import java.io.IOException ; 40 import java.util.HashMap ; 41 42 45 public class IncludeStatement extends Statement{ 46 private final SSIExpr _virtual; 47 48 private IncludeStatement(SSIExpr virtual) 49 { 50 _virtual = virtual; 51 } 52 53 static Statement create(HashMap <String ,String > attr, Path path) 54 { 55 String virtual = attr.get("virtual"); 56 57 if (virtual == null) 58 return new ErrorStatement("['virtual' is a required attribute of #include]"); 59 60 return new IncludeStatement(ExprParser.parseString(virtual, path)); 61 } 62 63 70 public void apply(WriteStream out, 71 HttpServletRequest request, 72 HttpServletResponse response) 73 throws IOException , ServletException  74 { 75 out.flushBuffer(); 76 77 RequestDispatcher disp; 78 79 String path = _virtual.evalString(request, response); 80 81 disp = request.getRequestDispatcher(path); 82 83 disp.include(request, response); 84 } 85 } 86 | Popular Tags |