Search in sources :

Example 31 with JspWriter

use of javax.servlet.jsp.JspWriter in project jodd by oblac.

the class FormTag method doAfterBody.

/**
	 * Performs smart form population.
	 */
@Override
public int doAfterBody() throws JspException {
    BodyContent body = getBodyContent();
    JspWriter out = body.getEnclosingWriter();
    String bodytext = populateForm(body.getString(), new FormFieldResolver() {

        public Object value(String name) {
            return JspResolver.value(name, pageContext);
        }
    });
    try {
        out.print(bodytext);
    } catch (IOException ioex) {
        throw new JspException(ioex);
    }
    return SKIP_BODY;
}
Also used : BodyContent(javax.servlet.jsp.tagext.BodyContent) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 32 with JspWriter

use of javax.servlet.jsp.JspWriter in project jodd by oblac.

the class DebugTag method doTag.

@Override
public void doTag() throws JspException, IOException {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = getJspContext().getOut();
    out.println(ServletUtil.debug(pageContext));
}
Also used : PageContext(javax.servlet.jsp.PageContext) JspWriter(javax.servlet.jsp.JspWriter)

Example 33 with JspWriter

use of javax.servlet.jsp.JspWriter in project jforum2 by rafaelsteil.

the class TrailTag method doWikiStartTag.

/**
	 * @see com.ecyrd.jspwiki.tags.WikiTagBase#doWikiStartTag()
	 */
public final int doWikiStartTag() throws IOException {
    HttpSession session = pageContext.getSession();
    FixedQueue trail = (FixedQueue) session.getAttribute(BREADCRUMBTRAIL_KEY);
    String page = m_wikiContext.getPage().getName();
    if (trail == null) {
        trail = new FixedQueue(maxPages);
    }
    if (m_wikiContext.getRequestContext().equals(WikiContext.VIEW)) {
        if (trail.isEmpty()) {
            trail.push(page);
        } else {
            // Don't add the page to the queue if the page was just refreshed
            if (!((String) trail.getLast()).equals(page)) {
                if (trailType.equalsIgnoreCase("visit")) {
                    if (!trail.contains(page)) {
                        trail.push(page);
                    }
                } else {
                    trail.push(page);
                }
            }
        }
    }
    // our trail
    session.setAttribute(BREADCRUMBTRAIL_KEY, trail);
    JspWriter out = pageContext.getOut();
    int queueSize = trail.size();
    String linkClass = "wikipage";
    WikiEngine engine = m_wikiContext.getEngine();
    int i = 0;
    for (Iterator iter = trail.iterator(); iter.hasNext(); i++) {
        String currentPage = (String) iter.next();
        StringBuffer sb = new StringBuffer(128).append("<a class='").append(linkClass).append("' href='").append(engine.getViewURL(currentPage)).append("'>");
        if (currentPage == page) {
            sb.append("<b>").append(currentPage).append("</b>");
        } else {
            sb.append(currentPage);
        }
        sb.append("</a>");
        out.print(sb.toString());
        if (i + 1 < queueSize) {
            out.print(trailSeparator);
        }
    }
    return SKIP_BODY;
}
Also used : HttpSession(javax.servlet.http.HttpSession) Iterator(java.util.Iterator) JspWriter(javax.servlet.jsp.JspWriter) WikiEngine(com.ecyrd.jspwiki.WikiEngine)

Example 34 with JspWriter

use of javax.servlet.jsp.JspWriter in project jodd by oblac.

the class TextTag method doTag.

@Override
public void doTag() throws JspException {
    PageContext pageContext = (PageContext) getJspContext();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    key = key.trim();
    String message;
    if (StringUtil.isEmpty(key)) {
        return;
    }
    message = defaultOnly ? findDefaultMessage(request, key) : findMessage(request, key);
    if (message == null) {
        message = UNKNOWN_PREFIX + key + UNKNOWN_SUFFIX;
    } else {
        for (String[] param : params) {
            String paramName = param[0];
            String paramValue = param[1];
            String value = paramValue;
            if (paramName.startsWith(KEY_ATTR_NAME)) {
                value = defaultOnly ? findDefaultMessage(request, paramValue) : findMessage(request, paramValue);
                if (value == null) {
                    value = UNKNOWN_PREFIX + paramValue + UNKNOWN_SUFFIX;
                }
            }
            message = StringUtil.replace(message, '{' + paramName + '}', value);
        }
    }
    JspWriter out = pageContext.getOut();
    try {
        out.print(HtmlEncoder.text(message));
    } catch (IOException ioex) {
    // ignore
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 35 with JspWriter

use of javax.servlet.jsp.JspWriter in project sonarqube by SonarSource.

the class BaseTag method doStartTag.

/**
     * Process the start of this tag.
     *
     * @throws JspException if a JSP exception has occurred
     */
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String serverName = (this.server == null) ? request.getServerName() : this.server;
    int port = request.getServerPort();
    String headerHost = request.getHeader("Host");
    if ((serverName == null) && (headerHost != null)) {
        StringTokenizer tokenizer = new StringTokenizer(headerHost, ":");
        serverName = tokenizer.nextToken();
        if (tokenizer.hasMoreTokens()) {
            String portS = tokenizer.nextToken();
            try {
                port = Integer.parseInt(portS);
            } catch (Exception e) {
                port = 80;
            }
        } else {
            port = 80;
        }
    }
    String baseTag = renderBaseElement(request.getScheme(), serverName, port, request.getRequestURI());
    JspWriter out = pageContext.getOut();
    try {
        out.write(baseTag);
    } catch (IOException e) {
        pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
        throw new JspException(messages.getMessage("common.io", e.toString()));
    }
    return EVAL_BODY_INCLUDE;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) StringTokenizer(java.util.StringTokenizer) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException)

Aggregations

JspWriter (javax.servlet.jsp.JspWriter)49 IOException (java.io.IOException)21 JspException (javax.servlet.jsp.JspException)21 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 Properties (java.util.Properties)6 HtmlCode (org.compiere.util.HtmlCode)6 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)5 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 HttpSession (javax.servlet.http.HttpSession)3 JspContext (javax.servlet.jsp.JspContext)3 PageContext (javax.servlet.jsp.PageContext)3 org.apache.ecs.xhtml.option (org.apache.ecs.xhtml.option)3 Element (org.dom4j.Element)3 StringWriter (java.io.StringWriter)2 Collection (java.util.Collection)2 JspTagException (javax.servlet.jsp.JspTagException)2 JspFragment (javax.servlet.jsp.tagext.JspFragment)2 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)2