(0002701)
|
sam
|
01-30-08 19:12
|
|
server/198d, server/1961
Example usage:
---- WEB-INF/resin-web.xml --------------------------------------
<web-app xmlns="http://caucho.com/ns/resin"> [^]
<filter filter-name='ssi' filter-class='com.caucho.servlets.ssi.SSIFilter'>
<init>
<factory resin:type="qa.MySSIFactory"/>
</init>
</filter>
<filter-mapping url-pattern='*.php' filter-name='ssi'/>
</web-app>
---- WEB-INF/classes/qa/MySSIFactory.java --------------------------
package qa;
import com.caucho.servlets.ssi.SSIFactory;
import com.caucho.vfs.Path;
import com.caucho.servlets.ssi.Statement;
import java.util.HashMap;
public class MySSIFactory
extends SSIFactory
{
public Statement createStatement(String cmd,
HashMap<String,String> attr,
Path path)
{
if ("foo".equals(cmd))
return new FooStatement(attr);
else
return super.createStatement(cmd, attr, path);
}
}
---- WEB-INF/classes/qa/FooStatement.java -------------------------------
package qa;
import com.caucho.servlets.ssi.Statement;
import com.caucho.vfs.WriteStream;
import java.io.IOException;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class FooStatement
extends Statement
{
private String _a;
public FooStatement(HashMap<String, String> attr)
{
_a = attr.get("a");
}
public void apply(WriteStream out,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
out.print("foo(" + _a + ")");
}
}
---- test.php ----------------------------------
<h1>A little test</h1>
<!--#foo a="hello" -->
<h1>End of test</h1> |
|