Java Code Examples for javax.servlet.jsp.JspWriter#DEFAULT_BUFFER

The following examples show how to use javax.servlet.jsp.JspWriter#DEFAULT_BUFFER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public void release() {
       out = baseOut;
try {
           // Do not flush the buffer even if we're not included (i.e.
           // we are the main page. The servlet will flush it and close
           // the stream.
           ((JspWriterImpl)out).flushBuffer();
} catch (IOException ex) {
    log.warning("Internal error flushing the buffer in release()");
}

servlet = null;
config = null;
context = null;
       elContext = null;
       elResolver = null;
       jspApplicationContext = null;
needsSession = false;
errorPageURL = null;
bufferSize = JspWriter.DEFAULT_BUFFER;
request = null;
response = null;
       depth = -1;
baseOut.recycle();
session = null;

attributes.clear();
   }
 
Example 2
Source File: PageContextImpl.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void initialize(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL,
        boolean needsSession, int bufferSize, boolean autoFlush)
        throws IOException {

    // initialize state
    this.servlet = servlet;
    this.config = servlet.getServletConfig();
    this.context = config.getServletContext();
    this.errorPageURL = errorPageURL;
    this.request = request;
    this.response = response;

    // initialize application context
    this.applicationContext = JspApplicationContextImpl.getInstance(context);

    // Setup session (if required)
    if (request instanceof HttpServletRequest && needsSession)
        this.session = ((HttpServletRequest) request).getSession();
    if (needsSession && session == null)
        throw new IllegalStateException(
                "Page needs a session and none is available");

    // initialize the initial out ...
    depth = -1;
    if (bufferSize == JspWriter.DEFAULT_BUFFER) {
        bufferSize = Constants.DEFAULT_BUFFER_SIZE;
    }
    if (this.baseOut == null) {
        this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
    } else {
        this.baseOut.init(response, bufferSize, autoFlush);
    }
    this.out = baseOut;

    // register names/values as per spec
    setAttribute(OUT, this.out);
    setAttribute(REQUEST, request);
    setAttribute(RESPONSE, response);

    if (session != null)
        setAttribute(SESSION, session);

    setAttribute(PAGE, servlet);
    setAttribute(CONFIG, config);
    setAttribute(PAGECONTEXT, this);
    setAttribute(APPLICATION, context);

    isIncluded = request.getAttribute(
            RequestDispatcher.INCLUDE_SERVLET_PATH) != null;
}
 
Example 3
Source File: PageContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private void _initialize(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL,
        boolean needsSession, int bufferSize, boolean autoFlush) {

    // initialize state
    this.servlet = servlet;
    this.config = servlet.getServletConfig();
    this.context = config.getServletContext();
    this.errorPageURL = errorPageURL;
    this.request = request;
    this.response = response;
    
    // initialize application context
    this.applicationContext = JspApplicationContextImpl.getInstance(context);

    // Setup session (if required)
    if (request instanceof HttpServletRequest && needsSession)
        this.session = ((HttpServletRequest) request).getSession();
    if (needsSession && session == null)
        throw new IllegalStateException(
                "Page needs a session and none is available");

    // initialize the initial out ...
    depth = -1;
    if (bufferSize == JspWriter.DEFAULT_BUFFER) {
        bufferSize = Constants.DEFAULT_BUFFER_SIZE;
    }
    if (this.baseOut == null) {
        this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
    } else {
        this.baseOut.init(response, bufferSize, autoFlush);
    }
    this.out = baseOut;

    // register names/values as per spec
    setAttribute(OUT, this.out);
    setAttribute(REQUEST, request);
    setAttribute(RESPONSE, response);

    if (session != null)
        setAttribute(SESSION, session);

    setAttribute(PAGE, servlet);
    setAttribute(CONFIG, config);
    setAttribute(PAGECONTEXT, this);
    setAttribute(APPLICATION, context);

    isIncluded = request.getAttribute(
            RequestDispatcher.INCLUDE_SERVLET_PATH) != null;
}
 
Example 4
Source File: PageContextImpl.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
private void _initialize(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL,
        boolean needsSession, int bufferSize, boolean autoFlush) {

    // initialize state
    this.servlet = servlet;
    this.config = servlet.getServletConfig();
    this.context = config.getServletContext();
    this.errorPageURL = errorPageURL;
    this.request = request;
    this.response = response;
    
    // initialize application context
    this.applicationContext = JspApplicationContextImpl.getInstance(context);

    // Setup session (if required)
    if (request instanceof HttpServletRequest && needsSession)
        this.session = ((HttpServletRequest) request).getSession();
    if (needsSession && session == null)
        throw new IllegalStateException(
                "Page needs a session and none is available");

    // initialize the initial out ...
    depth = -1;
    if (bufferSize == JspWriter.DEFAULT_BUFFER) {
        bufferSize = Constants.DEFAULT_BUFFER_SIZE;
    }
    if (this.baseOut == null) {
        this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
    } else {
        this.baseOut.init(response, bufferSize, autoFlush);
    }
    this.out = baseOut;

    // register names/values as per spec
    setAttribute(OUT, this.out);
    setAttribute(REQUEST, request);
    setAttribute(RESPONSE, response);

    if (session != null)
        setAttribute(SESSION, session);

    setAttribute(PAGE, servlet);
    setAttribute(CONFIG, config);
    setAttribute(PAGECONTEXT, this);
    setAttribute(APPLICATION, context);

    isIncluded = request.getAttribute(
            RequestDispatcher.INCLUDE_SERVLET_PATH) != null;
}