Tabnine Logo
JspWriter
Code IndexAdd Tabnine to your IDE (free)

How to use
JspWriter
in
javax.servlet.jsp

Best Java code snippets using javax.servlet.jsp.JspWriter (Showing top 20 results out of 2,268)

Refine searchRefine arrow

  • PageContext
  • JspException
  • ServletContext
  • HttpServletResponse
  • JspTagException
  • JspFactory
origin: apache/hbase

  response.setContentType("text/html;charset=UTF-8");
  pageContext = _jspxFactory.getPageContext(this, request, response,
        null, true, 8192, true);
  _jspx_page_context = pageContext;
  application = pageContext.getServletContext();
  config = pageContext.getServletConfig();
  session = pageContext.getSession();
  out = pageContext.getOut();
  _jspx_out = out;
  _jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
  out.write("\n\n<!DOCTYPE html>\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n  <head>\n    <meta charset=\"utf-8\">\n    <title>");
  out.print( request.getParameter("pageTitle"));
  out.write("</title>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta name=\"description\" content=\"\">\n    <meta name=\"author\" content=\"\">\n\n    <link href=\"/static/css/bootstrap.min.css\" rel=\"stylesheet\">\n    <link href=\"/static/css/bootstrap-theme.min.css\" rel=\"stylesheet\">\n    <link href=\"/static/css/hbase.css\" rel=\"stylesheet\">\n  </head>\n  <body>\n    <div class=\"navbar  navbar-fixed-top navbar-default\">\n      <div class=\"container-fluid\">\n        <div class=\"navbar-header\">\n          <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\"\n                  data-target=\".navbar-collapse\">\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n          </button>\n          <a class=\"navbar-brand\" href=\"/rs-status\">\n            <img src=\"/static/hbase_logo_small.png\" alt=\"HBase Logo\"/>\n          </a>\n        </div>\n        <div class=\"collapse navbar-collapse\">\n          <ul class=\"nav navbar-nav\">\n            <li><a href=\"/rs-status\">Home</a></li>\n");
  out.write("            <li><a href=\"/processRS.jsp\">Process Metrics</a></li>\n            <li><a href=\"/logs/\">Local Logs</a></li>\n            <li><a href=\"/logLevel\">Log Level</a></li>\n            <li><a href=\"/dump\">Debug Dump</a></li>\n            <li><a href=\"/jmx\">Metrics Dump</a></li>\n            ");
if (HBaseConfiguration.isShowConfInServlet()) { 
  out.write("\n            <li><a href=\"/conf\">HBase Configuration</a></li>\n            ");
  out.write("\n          </ul>\n        </div><!--/.nav-collapse -->\n      </div>\n    </div>\n");
 } catch (Throwable t) {
  if (!(t instanceof SkipPageException)){
   out = _jspx_out;
   if (out != null && out.getBufferSize() != 0)
    out.clearBuffer();
   if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
   else throw new ServletException(t);
  _jspxFactory.releasePageContext(_jspx_page_context);
origin: org.freemarker/freemarker

@Override
public void include(String url) throws ServletException, IOException {
  jspOut.flush();
  request.getRequestDispatcher(url).include(request, response);
}
origin: spring-projects/spring-framework

@Override
public void println(boolean value) throws IOException {
  getEnclosingWriter().println(value);
}
origin: spring-projects/spring-framework

@Override
public int doEndTag() throws JspException {
  EvaluationContext evaluationContext =
      (EvaluationContext) this.pageContext.getAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE);
  if (evaluationContext == null) {
    evaluationContext = createEvaluationContext(this.pageContext);
    this.pageContext.setAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE, evaluationContext);
  }
  if (this.var != null) {
    Object result = (this.expression != null ? this.expression.getValue(evaluationContext) : null);
    this.pageContext.setAttribute(this.var, result, this.scope);
  }
  else {
    try {
      String result = (this.expression != null ?
          this.expression.getValue(evaluationContext, String.class) : null);
      result = ObjectUtils.getDisplayString(result);
      result = htmlEscape(result);
      result = (this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(result) : result);
      this.pageContext.getOut().print(result);
    }
    catch (IOException ex) {
      throw new JspException(ex);
    }
  }
  return EVAL_PAGE;
}
origin: org.glassfish.web/jstl-impl

public int doEndTag() throws JspException {
if (bodyContent != null) {
  try {
  pageContext.getOut().print(bodyContent.getString());
  } catch (IOException ioe) {
  throw new JspTagException(ioe.toString(), ioe);
  }
}
return EVAL_PAGE;
}
origin: igniterealtime/Openfire

HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
  JspWriter out = pageContext.getOut();
    out.write(buf.toString());
    throw new JspException(ioe.getMessage());
origin: igniterealtime/Openfire

@Override
public int doEndTag() throws JspException {
  try {
    final ASN1InputStream decoder = new ASN1InputStream(value);
    ASN1Primitive primitive = decoder.readObject();
    while (primitive != null && !(primitive instanceof ASN1Null)) {
      pageContext.getOut().write(doPrimitive(primitive));
      primitive = decoder.readObject();
    }
  } catch (Exception ex) {
    throw new JspException(ex.getMessage());
  }
  return super.doEndTag();
}
origin: oblac/jodd

@Override
public void doTag() throws IOException {
  PageContext pageContext = ((PageContext) getJspContext());
  HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
  String output = VtorUtil.resolveValidationMessage(request, violation);
  pageContext.getOut().write(output);
}
origin: oblac/jodd

  @Override
  public void doTag() {
    PageContext pageContext = (PageContext) getJspContext();
    URLCoder.Builder builder = URLCoder.build(baseUrl);

    for (int i = 0; i < attrs.size(); i += 2) {
      builder.queryParam(attrs.get(i), attrs.get(i + 1));
    }

    if (var == null) {
      JspWriter out = pageContext.getOut();
      try {
        out.print(builder.get());
      } catch (IOException ioex) {
        // ignore
      }
    } else {
      pageContext.setAttribute(var, builder.get());
    }
  }
}
origin: paoding-code/paoding-rose

  @Override
  public int doStartTag() throws JspException {
    Invocation invocation = InvocationUtils.getCurrentThreadInvocation();
    if (invocation != null) {
      String msg = invocation.getFlash().get(key);
      if (logger.isDebugEnabled()) {
        logger.debug("getFlashMessage: " + key + "=" + msg);
      }
      if (msg != null) {
        try {
          if (StringUtils.isNotEmpty(prefix)) {
            pageContext.getOut().print(prefix);
          }
          pageContext.getOut().print(msg);
          if (StringUtils.isNotEmpty(suffix)) {
            pageContext.getOut().print(suffix);
          }
        } catch (IOException e) {
          throw new JspException("", e);
        }
      }
    }
    return super.doStartTag();
  }
}
origin: apache/shiro

@SuppressWarnings({"unchecked"})
public int onDoStartTag() throws JspException {
  String strValue = null;
  if (getSubject() != null) {
    // Get the principal to print out
    Object principal;
    if (type == null) {
      principal = getSubject().getPrincipal();
    } else {
      principal = getPrincipalFromClassName();
    }
    // Get the string value of the principal
    if (principal != null) {
      if (property == null) {
        strValue = principal.toString();
      } else {
        strValue = getPrincipalProperty(principal, property);
      }
    }
  }
  // Print out the principal value if not null
  if (strValue != null) {
    try {
      pageContext.getOut().write(strValue);
    } catch (IOException e) {
      throw new JspTagException("Error writing [" + strValue + "] to JSP.", e);
    }
  }
  return SKIP_BODY;
}
origin: spring-projects/spring-framework

/**
 * Write the escaped body content to the page.
 * <p>Can be overridden in subclasses, e.g. for testing purposes.
 * @param content the content to write
 * @throws IOException if writing failed
 */
protected void writeBodyContent(String content) throws IOException {
  Assert.state(this.bodyContent != null, "No BodyContent set");
  this.bodyContent.getEnclosingWriter().print(content);
}
origin: spring-projects/spring-framework

/**
 * Write the message to the page.
 * <p>Can be overridden in subclasses, e.g. for testing purposes.
 * @param msg the message to write
 * @throws IOException if writing failed
 */
protected void writeMessage(String msg) throws IOException {
  this.pageContext.getOut().write(String.valueOf(msg));
}
origin: oblac/jodd

/**
 * Performs smart form population.
 */
@Override
public int doAfterBody() throws JspException {
  BodyContent body = getBodyContent();
  JspWriter out = body.getEnclosingWriter();
  String bodytext = populateForm(body.getString(), name -> value(name, pageContext));
  try {
    out.print(bodytext);
  } catch (IOException ioex) {
    throw new JspException(ioex);
  }
  return SKIP_BODY;
}
origin: oblac/jodd

  @Override
  public void doTag() throws IOException {
    JspContext jspContext = this.getJspContext();

    // generate token
    HttpServletRequest request = (HttpServletRequest) ((PageContext) jspContext).getRequest();
    HttpSession session = request.getSession();
    String value = CsrfShield.prepareCsrfToken(session);
    if (name == null) {
      name = CsrfShield.CSRF_TOKEN_NAME;
    }
    jspContext.getOut().write("<input type=\"hidden\" name=\"" + name + "\" value=\"" + value + "\"/>");
  }
}
origin: org.apache.myfaces.core/myfaces-api

@Override
public void flush() throws IOException
{
  _pageContext.getOut().flush();
}
origin: spring-projects/spring-framework

@Override
public void write(char[] value, int offset, int length) throws IOException {
  getEnclosingWriter().write(value, offset, length);
}
origin: spring-projects/spring-framework

@Override
public void clearBuffer() throws IOException {
  getEnclosingWriter().clearBuffer();
}
origin: spring-projects/spring-framework

@Override
public int doEndTag() throws JspException {
  String url = createUrl();
  RequestDataValueProcessor processor = getRequestContext().getRequestDataValueProcessor();
  ServletRequest request = this.pageContext.getRequest();
  if ((processor != null) && (request instanceof HttpServletRequest)) {
    url = processor.processUrl((HttpServletRequest) request, url);
  }
  if (this.var == null) {
    // print the url to the writer
    try {
      this.pageContext.getOut().print(url);
    }
    catch (IOException ex) {
      throw new JspException(ex);
    }
  }
  else {
    // store the url as a variable
    this.pageContext.setAttribute(this.var, url, this.scope);
  }
  return EVAL_PAGE;
}
origin: javax.servlet/com.springsource.javax.servlet.jsp.jstl

public int doEndTag() throws JspException {
try {
  pageContext.getOut().print(bodyContent.getString());
} catch (IOException ioe) {
  throw new JspTagException(ioe.toString(), ioe);
}
return EVAL_PAGE;
}
javax.servlet.jspJspWriter

Javadoc

The actions and template data in a JSP page is written using the JspWriter object that is referenced by the implicit variable out which is initialized automatically using methods in the PageContext object.

This abstract class emulates some of the functionality found in the java.io.BufferedWriter and java.io.PrintWriter classes, however it differs in that it throws java.io.IOException from the print methods while PrintWriter does not.

Buffering

The initial JspWriter object is associated with the PrintWriter object of the ServletResponse in a way that depends on whether the page is or is not buffered. If the page is not buffered, output written to this JspWriter object will be written through to the PrintWriter directly, which will be created if necessary by invoking the getWriter() method on the response object. But if the page is buffered, the PrintWriter object will not be created until the buffer is flushed and operations like setContentType() are legal. Since this flexibility simplifies programming substantially, buffering is the default for JSP pages.

Buffering raises the issue of what to do when the buffer is exceeded. Two approaches can be taken:

  • Exceeding the buffer is not a fatal error; when the buffer is exceeded, just flush the output.
  • Exceeding the buffer is a fatal error; when the buffer is exceeded, raise an exception.

Both approaches are valid, and thus both are supported in the JSP technology. The behavior of a page is controlled by the autoFlush attribute, which defaults to true. In general, JSP pages that need to be sure that correct and complete data has been sent to their client may want to set autoFlush to false, with a typical case being that where the client is an application itself. On the other hand, JSP pages that send data that is meaningful even when partially constructed may want to set autoFlush to true; such as when the data is sent for immediate display through a browser. Each application will need to consider their specific needs.

An alternative considered was to make the buffer size unbounded; but, this had the disadvantage that runaway computations would consume an unbounded amount of resources.

The "out" implicit variable of a JSP implementation class is of this type. If the page directive selects autoflush="true" then all the I/O operations on this class shall automatically flush the contents of the buffer if an overflow condition would result if the current operation were performed without a flush. If autoflush="false" then all the I/O operations on this class shall throw an IOException if performing the current operation would result in a buffer overflow condition.

Most used methods

  • print
    Print an array of characters. The characters are written to the JspWriter's buffer or, if no buffer
  • write
  • flush
    Flush the stream. If the stream has saved any characters from the various write() methods in a buffe
  • clearBuffer
  • println
    Print an array of characters and then terminate the line. This method behaves as though it invokes p
  • getBufferSize
  • clear
    Clear the contents of the buffer. If the buffer has been already been flushed then the clear operati
  • append
  • close
    Close the stream, flushing it first. This method needs not be invoked explicitly for the initial Jsp
  • getRemaining
    This method returns the number of unused bytes in the buffer.
  • newLine
    Write a line separator. The line separator string is defined by the system property line.separator,
  • isAutoFlush
    This method indicates whether the JspWriter is autoFlushing.
  • newLine,
  • isAutoFlush

Popular in Java

  • Finding current android device location
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Table (org.hibernate.mapping)
    A relational table
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now