Java Code Examples for javax.servlet.jsp.JspWriter#flush()

The following examples show how to use javax.servlet.jsp.JspWriter#flush() . 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: JspRuntimeLibrary.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a RequestDispatcher.include() operation, with optional flushing
 * of the response beforehand.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 * @param relativePath The relative path of the resource to be included
 * @param out The Writer to whom we are currently writing
 * @param flush Should we flush before the include is processed?
 *
 * @exception IOException if thrown by the included servlet
 * @exception ServletException if thrown by the included servlet
 */
public static void include(ServletRequest request,
                           ServletResponse response,
                           String relativePath,
                           JspWriter out,
                           boolean flush)
    throws IOException, ServletException {

    if (flush && !(out instanceof BodyContent))
        out.flush();

    // FIXME - It is tempting to use request.getRequestDispatcher() to
    // resolve a relative path directly, but Catalina currently does not
    // take into account whether the caller is inside a RequestDispatcher
    // include or not.  Whether Catalina *should* take that into account
    // is a spec issue currently under review.  In the mean time,
    // replicate Jasper's previous behavior

    String resourcePath = getContextRelativePath(request, relativePath);
    RequestDispatcher rd = request.getRequestDispatcher(resourcePath);

    rd.include(request,
               new ServletResponseWrapperInclude(response, out));

}
 
Example 2
Source File: CkeditorTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 3
Source File: OrgSelectTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 4
Source File: DepartSelectTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 5
Source File: MutiLangTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 6
Source File: JspRuntimeLibrary.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Perform a RequestDispatcher.include() operation, with optional flushing
 * of the response beforehand.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 * @param relativePath The relative path of the resource to be included
 * @param out The Writer to whom we are currently writing
 * @param flush Should we flush before the include is processed?
 *
 * @exception IOException if thrown by the included servlet
 * @exception ServletException if thrown by the included servlet
 */
public static void include(ServletRequest request,
                           ServletResponse response,
                           String relativePath,
                           JspWriter out,
                           boolean flush)
    throws IOException, ServletException {

    if (flush && !(out instanceof BodyContent))
        out.flush();

    // FIXME - It is tempting to use request.getRequestDispatcher() to
    // resolve a relative path directly, but Catalina currently does not
    // take into account whether the caller is inside a RequestDispatcher
    // include or not.  Whether Catalina *should* take that into account
    // is a spec issue currently under review.  In the mean time,
    // replicate Jasper's previous behavior

    String resourcePath = getContextRelativePath(request, relativePath);
    RequestDispatcher rd = request.getRequestDispatcher(resourcePath);

    rd.include(request,
               new ServletResponseWrapperInclude(response, out));

}
 
Example 7
Source File: TreeSelectTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
			end().setLength(0);
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 8
Source File: ColorChangeTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 9
Source File: ComboBoxTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 10
Source File: FormValidationTag.java    From jeewx with Apache License 2.0 6 votes vote down vote up
public int doStartTag() throws JspException {
	try {
		JspWriter out = this.pageContext.getOut();
		StringBuffer sb = new StringBuffer();
		if ("div".equals(layout)) {
			sb.append("<div id=\"content\">");
			sb.append("<div id=\"wrapper\">");
			sb.append("<div id=\"steps\">");
		}
		sb.append("<form id=\"" + formid + "\" action=\"" + action + "\" name=\"" + formid + "\" method=\"post\">");
		if ("btn_sub".equals(btnsub) && dialog)
			sb.append("<input type=\"hidden\" id=\"" + btnsub + "\" class=\"" + btnsub + "\"/>");
		out.print(sb.toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
Example 11
Source File: ComboTreeTag.java    From jeecg with Apache License 2.0 6 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
Example 12
Source File: JspRuntimeLibrary.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a RequestDispatcher.include() operation, with optional flushing
 * of the response beforehand.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 * @param relativePath The relative path of the resource to be included
 * @param out The Writer to whom we are currently writing
 * @param flush Should we flush before the include is processed?
 *
 * @exception IOException if thrown by the included servlet
 * @exception ServletException if thrown by the included servlet
 */
public static void include(ServletRequest request,
                           ServletResponse response,
                           String relativePath,
                           JspWriter out,
                           boolean flush)
    throws IOException, ServletException {

    if (flush && !(out instanceof BodyContent))
        out.flush();

    // FIXME - It is tempting to use request.getRequestDispatcher() to
    // resolve a relative path directly, but Catalina currently does not
    // take into account whether the caller is inside a RequestDispatcher
    // include or not.  Whether Catalina *should* take that into account
    // is a spec issue currently under review.  In the mean time,
    // replicate Jasper's previous behavior

    String resourcePath = getContextRelativePath(request, relativePath);
    RequestDispatcher rd = request.getRequestDispatcher(resourcePath);

    rd.include(request,
               new ServletResponseWrapperInclude(response, out));

}
 
Example 13
Source File: JspRuntimeLibrary.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Perform a RequestDispatcher.include() operation, with optional flushing
 * of the response beforehand.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 * @param relativePath The relative path of the resource to be included
 * @param out The Writer to whom we are currently writing
 * @param flush Should we flush before the include is processed?
 *
 * @exception IOException if thrown by the included servlet
 * @exception ServletException if thrown by the included servlet
 */
public static void include(ServletRequest request,
                           ServletResponse response,
                           String relativePath,
                           JspWriter out,
                           boolean flush)
    throws IOException, ServletException {

    if (flush && !(out instanceof BodyContent))
        out.flush();

    // FIXME - It is tempting to use request.getRequestDispatcher() to
    // resolve a relative path directly, but Catalina currently does not
    // take into account whether the caller is inside a RequestDispatcher
    // include or not.  Whether Catalina *should* take that into account
    // is a spec issue currently under review.  In the mean time,
    // replicate Jasper's previous behavior

    String resourcePath = getContextRelativePath(request, relativePath);
    RequestDispatcher rd = request.getRequestDispatcher(resourcePath);

    rd.include(request,
               new ServletResponseWrapperInclude(response, out));

}
 
Example 14
Source File: CkfinderTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
public int doEndTag() throws JspTagException {
	try {
		JspWriter out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
Example 15
Source File: AuthFilterTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
public int doEndTag() throws JspException {
	try {
		JspWriter out = this.pageContext.getOut();
			out.print(end().toString());
			out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
	
}
 
Example 16
Source File: ChooseTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
public int doEndTag() throws JspTagException {
	try {
		JspWriter out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
Example 17
Source File: UploadTag.java    From jeewx with Apache License 2.0 5 votes vote down vote up
public int doEndTag() throws JspTagException {
	try {
		JspWriter out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
Example 18
Source File: RawContentTag.java    From lognavigator with Apache License 2.0 5 votes vote down vote up
@Override
public int doEndTag() throws JspException {
	
	// Get input and ouput variables
	Reader rawContent = (Reader) pageContext.getAttribute(Constants.RAW_CONTENT_KEY, PageContext.REQUEST_SCOPE);
	JspWriter out = pageContext.getOut();
	
	try {
		// Copy input (rawContent) to output (out)
		char[] buffer = new char[StreamUtils.BUFFER_SIZE];
		int bytesRead = -1;
		while ((bytesRead = rawContent.read(buffer)) != -1) {
			String stringToWrite = new String(buffer, 0, bytesRead);
			stringToWrite = HtmlUtils.htmlEscape(stringToWrite);
			out.write(stringToWrite);
		}
		out.flush();

		return EVAL_PAGE;
	}
	catch (IOException e) {
		throw new JspException(e);
	}
	finally {
		IOUtils.closeQuietly(rawContent);
	}
}
 
Example 19
Source File: AutocompleteTag.java    From jeecg with Apache License 2.0 5 votes vote down vote up
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
Example 20
Source File: FormValidationTag.java    From jeecg with Apache License 2.0 4 votes vote down vote up
public int doStartTag() throws JspException {
		//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		//long start = System.currentTimeMillis();
		//logger.debug("=================Form=====doStartTag==========开始时间:" + sdf.format(new Date()) + "==============================");
		JspWriter out = null;
		try {
			out = this.pageContext.getOut();
			StringBuffer sb = new StringBuffer();
				/*//			if(cssTheme==null){//手工设置值优先
				Cookie[] cookies = ((HttpServletRequest) super.pageContext
						.getRequest()).getCookies();
				for (Cookie cookie : cookies) {
					if (cookie == null || StringUtils.isEmpty(cookie.getName())) {
						continue;
					}
					if (cookie.getName().equalsIgnoreCase("JEECGCSSTHEME")) {
						cssTheme = cookie.getValue();
					}
				}
//			}
			if(cssTheme==null||"default".equals(cssTheme))cssTheme="";*/
			if ("div".equals(layout)) {
				sb.append("<div id=\"content\">");

				sb.append("<div id=\"wrapper\" style=\"border-left:1px solid #ddd;\">");

				sb.append("<div id=\"steps\">");
			}
			sb.append("<form id=\"" + formid + "\" " );

			if(this.getStyleClass()!=null){
				sb.append("class=\""+this.getStyleClass()+"\" ");
			}

					sb.append(" action=\"" + action + "\" name=\"" + formid + "\" method=\"post\">");
			if ("btn_sub".equals(btnsub) && dialog)
				sb.append("<input type=\"hidden\" id=\"" + btnsub + "\" class=\"" + btnsub + "\"/>");
			
			out.print(sb.toString());
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				out.clearBuffer();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		//long end = System.currentTimeMillis();
		//logger.debug("==============Form=====doStartTag=================结束时间:" + sdf.format(new Date()) + "==============================");
		//logger.debug("===============Form=====doStartTag=================耗时:" + (end - start) + "ms==============================");

		return EVAL_PAGE;
	}