public int doEndTag()

in taglib/src/org/apache/taglibs/bsf/expression.java [31:87]


    public int doEndTag() throws JspException {
        try {
            final BodyContent bodyOut = getBodyContent();

            JspWriter out = pageContext.getOut();
            if (bodyOut == null) return EVAL_PAGE;

            if (mgr == null) mgr = new BSFManager();
            final BSFEngine engine = mgr.loadScriptingEngine(language);

            try {
                register( mgr, "request"    , pageContext.getRequest());
                register( mgr, "response"   , pageContext.getResponse());
                register( mgr, "pageContext", pageContext);
                register( mgr, "application", pageContext.getServletContext());
                register( mgr, "out"        , out);
                register( mgr, "config"     , pageContext.getServletConfig());
                register( mgr, "page"       , pageContext.getPage());
                register( mgr, "exception"  , pageContext.getException());
                register( mgr, "session"    , pageContext.getSession());
            } 
            catch( Exception e ) {
                out.println(e.toString());
                e.printStackTrace();
            }

            Object result = null;
            try {
                result =
                    AccessController.doPrivileged(new PrivilegedExceptionAction() {
                                                      public Object run() throws Exception {
                                                          HttpServletRequest pnamer = 
                        (HttpServletRequest) 
                        pageContext.getRequest();
                    String pthinfo = 
                        (pnamer.getPathInfo() != null) ? 
                        pnamer.getPathInfo() : "";
                    return engine.eval (pnamer.getContextPath() +
                                        pnamer.getServletPath() +
                                        pthinfo,
                                        lineNo++, 0, bodyOut.getString());
                                                      }
                                                  });
            }
            catch (PrivilegedActionException prive) {
                throw (BSFException) prive.getException();
            }

            if (result != null) out.println(result.toString());
        } 
        catch( Exception e ) {
            System.out.println(e.toString());
            e.printStackTrace();
        }

        return EVAL_PAGE;
    }