Re: [Simpleweb-Support] is there a simple template velocity howto ???
Brought to you by:
niallg
From: Saxon F. <ts...@ya...> - 2004-06-22 13:53:14
|
still not able to get it to work... when prepare is call by MyService, the container is null. thanks so much for all the help. ----------------- public class Main { public static void main(String[] args) throws Exception { LoaderEngine engine = new MapperEngine( new FileContext(), new VelocityContainer()); engine.link("*", "default"); engine.load("my", "MyService"); engine.link("/service/my*", "my"); ProtocolHandler handler = HandlerFactory.getInstance(engine); Connection connection = ConnectionFactory.getConnection(handler); connection.connect(new ServerSocket(8282)); } } ----------------- public class MyService extends ReflectionService { private Container container; public MyService(Context context){ super(context); } public void prepare(Container container) { if (container == null) { System.out.println("null prepare"); } else { System.out.println("setting container"); } this.container = container; } public void process(Request req, Response resp) throws Exception { OutputStream out = resp.getOutputStream(); Document doc = container.lookup("test.vm"); doc.put("book", "hello world"); doc.write(out); out.close(); } } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |