Re: [Simpleweb-Support] is there a simple template velocity howto ???
Brought to you by:
niallg
From: Niall G. <ni...@em...> - 2004-06-21 18:54:49
|
Hi > was reading through the template section ... but is > totally lost. can't get template to work. Yes, the documentation needs to be updated. > below is what i come up with... is it totally wrong? Not totally wrong, heres what is needed. import simple.http.serve.*; import simple.http.*; import simple.template.BasicService; public class VelocityService extends BasicService { public VelocityService(Context context){ this.context = context; } public void process(Request req, Response resp) throws Exception { OutputStream out = resp.getOutputStream(); String target = req.getURI(); Document doc = system.resolve(target); // can be test.vm or whatever doc.("book", "Simpleweb Guide"); doc.write(out); out.close(); } } // get every thing working public static void main(String list[]) throws Exception { Context context = new FileContext(); Container container = new VelocityContainer(); TemplateEngine engine = new TemplateEngine(context, container); Connection connection = ConnectionFactory.getConnection(engine); conneciton.connect(new ServerSocket(8080)); } To see this as a working implementation see http://mambaweb.sf.net. The source is in the mamba.jar JAR archive. Regards Niall -- _______________________________________________ Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free! http://www.net2phone.com/cgi-bin/link.cgi?143 |