From: Marc P. <ma...@an...> - 2003-08-07 09:36:17
|
Hey, While supporting that guy with the #macro problem who mailed the team address, he's sent me a JSP file he is using to run WM! This is really quite simple but is quite amusing / useful as a migration tool or a way to get employers who want you to use JSP to let you use WM ;-) Here's his JSP - the way he is locating the template is unnecessarily obscure because he has put them into the app doc root: <%@ page import='org.webmacro.*,org.webmacro.servlet.WebContext,java.util.*' %><% WebMacro webMacro = null; Context context = null; Template template = null; try{ webMacro = new WM(); context = new Context(webMacro.getBroker()); String path = pageContext.getServletContext().getRealPath("") + java.io.File.separator + "MacroTestMain.html"; template = webMacro.getTemplate(path); } catch (Exception e){ e.printStackTrace(); } String htmlPath = pageContext.getServletContext().getRealPath(""); context.put("htmlPath",htmlPath); try{ out.print(template.evaluate(context)); } catch (Exception e) { e.printStackTrace(); } %> Anyway, this is quite interesting and may have some useful possibilities for WM, if shifted to an included JSP file so that you don't have to have this code in every JSP. Maybe someone who has real experience of JSP could write a page on this on the Wiki, and we could announce it in the next press release "A migration / co-existence path for JSP users". Marc -- Marc Palmer Contract Java Consultant/Developer w a n g j a m m e r s java and web software design experts with an ethical outlook http://www.wangjammers.org |