- rs.getWriter().write("beginning output...");
- try { Template.wrap(Template.parse(path, scope), scope).out(rs.getWriter()); }
- catch (Exception e) { e.printStackTrace(); System.out.println("e = "+e); }
- rs.getWriter().write("...output ends.");
+ try {
+ while (src != null) {
+ try {
+ StringWriter w = new StringWriter();
+ Template t = Template.parse(cx.getRealPath(src), scope);
+ Template.wrap(t, scope).out(w);
+ rs.getWriter().write(w.toString());
+ src = null;
+ } catch (Template.RedirectSignal r) {
+ src = r.getTarget();
+ }
+ }
+ } catch (Template.Signal s) {
+ } catch (JSElement.Exn e) {
+ PrintWriter w = new PrintWriter(rs.getWriter());
+ w.print("\n"+src+": ");
+ w.println(e.getMessage());
+ System.out.println(e);
+ } catch (Exception e) {
+ System.out.println("Unexpected Exception:");
+ e.printStackTrace();
+ }