FileDocCategorySizeDatePackage
MacroView.javaAPI DocExample1715Thu Apr 05 20:30:32 BST 2001None

MacroView

public class MacroView extends HttpServlet

Fields Summary
WebMacro
wm
Constructors Summary
Methods Summary
public voiddestroy()

    super.destroy();
    if (wm != null) wm.destroy();
  
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

    FastWriter out = new FastWriter(res.getOutputStream(),
                                    res.getCharacterEncoding());

    // The template name comes as extra path info
    //   /servlet/MacroView/templ.wm
    // or as servlet path via a *.wm rule
    //   /templ.wm
    String template = req.getPathInfo();
    if (template == null) {
      template = req.getServletPath();
      template = template.substring(1);  // cut off leading "/"
    }

    // If template is still null, we have a problem
    if (template == null) {
      throw new ServletException(
        "No template specified as extra path info or servlet path");
    }

    try {
      Template tmpl = wm.getTemplate(template);
      WebContext context = wm.getWebContext(req, res); 
      tmpl.write(out, context);
    }
    catch (WebMacroException e) {
      throw new ServletException(e);
    }
    finally {
      out.flush();
    }
  
public voidinit()

    try {
      wm = new WM();
    }
    catch (InitException e) {
      throw new ServletException(e);
    }