Search in sources :

Example 1 with JspWriter

use of javax.servlet.jsp.JspWriter in project tomcat by apache.

the class ShowSource method doEndTag.

@Override
public int doEndTag() throws JspException {
    if ((jspFile.indexOf("..") >= 0) || (jspFile.toUpperCase(Locale.ENGLISH).indexOf("/WEB-INF/") != 0) || (jspFile.toUpperCase(Locale.ENGLISH).indexOf("/META-INF/") != 0))
        throw new JspTagException("Invalid JSP file " + jspFile);
    try (InputStream in = pageContext.getServletContext().getResourceAsStream(jspFile)) {
        if (in == null)
            throw new JspTagException("Unable to find JSP file: " + jspFile);
        JspWriter out = pageContext.getOut();
        try {
            out.println("<body>");
            out.println("<pre>");
            for (int ch = in.read(); ch != -1; ch = in.read()) if (ch == '<')
                out.print("&lt;");
            else
                out.print((char) ch);
            out.println("</pre>");
            out.println("</body>");
        } catch (IOException ex) {
            throw new JspTagException("IOException: " + ex.toString());
        }
    } catch (IOException ex2) {
        throw new JspTagException("IOException: " + ex2.toString());
    }
    return super.doEndTag();
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) JspTagException(javax.servlet.jsp.JspTagException)

Example 2 with JspWriter

use of javax.servlet.jsp.JspWriter in project head by mifos.

the class MifosImageTag method doStartTag.

/**
     * Function to render the tag
     *
     * @throws JspException
     */
@Override
public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();
    ResourceBundle resource = getResourceBundle();
    path = resource.getString(getId());
    try {
        out.println(render());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return SKIP_BODY;
}
Also used : ResourceBundle(java.util.ResourceBundle) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 3 with JspWriter

use of javax.servlet.jsp.JspWriter in project head by mifos.

the class TableTag method displayData.

private void displayData(List list, Table table, Locale locale, Integer currentValue) throws TableTagException, IOException, JspException {
    JspWriter out = pageContext.getOut();
    int number = ((currentValue - 1) * pageSize);
    for (Iterator it = list.iterator(); it.hasNext(); ) {
        Object object = it.next();
        boolean isFlowRequired = table.getPageRequirements().getFlowRequired().equalsIgnoreCase("true") ? true : false;
        String data = table.getTable(pageContext, object, locale, isFlowRequired);
        if (data == null) {
            throw new JspException("XML.filenotfound");
        }
        if (table.getPageRequirements().getNumbersRequired().equalsIgnoreCase("true")) {
            out.write("<tr class=\"fontnormal\"><td width=\"3%\" ");
            if (table.getPageRequirements().getValignnumbers().equalsIgnoreCase("true")) {
                out.write("valign=\"top\"");
            }
            out.write(">");
            out.write((++number) + ".</td><td width=\"97%\"");
        }
        out.write(data);
        if (table.getPageRequirements().getBlanklinerequired().equalsIgnoreCase("true")) {
            if (it.hasNext()) {
                out.write("<br />");
            }
        }
        if (table.getPageRequirements().getBluelineRequired().equalsIgnoreCase("true")) {
            if (it.hasNext()) {
                out.write("<tr><td colspan=\"2\" valign=\"top\" class=\"blueline\">");
                out.write("<img src=\"pages/framework/images/trans.gif \" width=\"10\" height=\"5\"></td></tr>");
            }
        }
        out.write("</td></tr>");
    }
    StringBuilder result = new StringBuilder();
    boolean bottomBlueLineRequired = table.getPageRequirements().getBottombluelineRequired().equalsIgnoreCase("true");
    createEndTable(result, bottomBlueLineRequired);
    String action = getAction(table);
    out.write(result.toString());
    String currentFlowkey = (String) ((HttpServletRequest) pageContext.getRequest()).getAttribute(Constants.CURRENTFLOWKEY);
    String perspective = (String) ((HttpServletRequest) pageContext.getRequest()).getAttribute(RequestConstants.PERSPECTIVE);
    out.write(PageScroll.getPages(currentValue, pageSize, size, action, currentFlowkey, locale, perspective));
    out.write("</table></td></tr>");
    out.write("</table>");
}
Also used : JspException(javax.servlet.jsp.JspException) Iterator(java.util.Iterator) JspWriter(javax.servlet.jsp.JspWriter)

Example 4 with JspWriter

use of javax.servlet.jsp.JspWriter in project head by mifos.

the class TableTag method doStartTag.

/**
     * Function to render the tag
     */
@Override
public int doStartTag() throws JspException {
    // call the helper method to display the result.
    try {
        // Value of the list which we are getting from the Cache
        List list = getList();
        if (list == null) {
            return super.doStartTag();
        }
        if (list.size() == 0) {
            JspWriter out = pageContext.getOut();
            XmlBuilder result;
            result = noResults((String) SessionUtils.getAttribute(Constants.OFFICE_NAME, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.BRANCH_ID, (HttpServletRequest) pageContext.getRequest()), (String) SessionUtils.getAttribute(Constants.SEARCH_STRING, (HttpServletRequest) pageContext.getRequest()));
            out.write(result.getOutput());
            return super.doStartTag();
        }
        getTableData(list);
    } catch (TableTagException tte) {
        throw new JspException(tte);
    } catch (TableTagParseException ttpe) {
        throw new JspException(ttpe);
    } catch (TableTagTypeParserException tttpe) {
        throw new JspException(tttpe);
    } catch (IOException ioe) {
        throw new JspException(ioe);
    } catch (HibernateSearchException hse) {
        throw new JspException(hse);
    } catch (PageExpiredException e) {
        throw new JspException(e);
    }
    return super.doStartTag();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TableTagException(org.mifos.framework.exceptions.TableTagException) JspException(javax.servlet.jsp.JspException) TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) XmlBuilder(org.mifos.framework.struts.tags.XmlBuilder) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) TableTagTypeParserException(org.mifos.framework.exceptions.TableTagTypeParserException)

Example 5 with JspWriter

use of javax.servlet.jsp.JspWriter in project head by mifos.

the class TableTag method displayDataMultiple.

private void displayDataMultiple(Object object, Table table, int number, Locale locale) throws TableTagException, IOException, JspException {
    String data = null;
    JspWriter out = pageContext.getOut();
    getAction(table);
    boolean isFlowRequired = table.getPageRequirements().getFlowRequired().equalsIgnoreCase("true") ? true : false;
    data = table.getTable(pageContext, object, locale, isFlowRequired);
    out.write("<tr class=\"fontnormal\"><td width=\"3%\" valign=\"top\">");
    out.write((number) + ".</td><td width=\"97%\">");
    out.write(data);
    if (table.getPageRequirements().getBlanklinerequired().equalsIgnoreCase("true")) {
        out.write("<br />");
    }
    out.write("</td></tr>");
}
Also used : JspWriter(javax.servlet.jsp.JspWriter)

Aggregations

JspWriter (javax.servlet.jsp.JspWriter)145 IOException (java.io.IOException)72 JspException (javax.servlet.jsp.JspException)69 HttpServletRequest (javax.servlet.http.HttpServletRequest)17 JspWriteRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException)14 PageContext (javax.servlet.jsp.PageContext)10 Iterator (java.util.Iterator)9 JspContext (javax.servlet.jsp.JspContext)8 JspTagException (javax.servlet.jsp.JspTagException)8 WikiEngine (org.apache.wiki.WikiEngine)8 OuterFormTagMissingRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException)7 ArrayList (java.util.ArrayList)6 Properties (java.util.Properties)6 HttpSession (javax.servlet.http.HttpSession)5 BodyContent (javax.servlet.jsp.tagext.BodyContent)5 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)5 HtmlCode (org.compiere.util.HtmlCode)5 MissingParametersRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException)5 IPropertyRuleIntrospector (org.jaffa.rules.IPropertyRuleIntrospector)5 JspFragment (javax.servlet.jsp.tagext.JspFragment)4