下面列出了javax.servlet.jsp.JspWriter#flush ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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));
}
/**
* 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));
}
/**
* 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));
}
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;
}
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;
}
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;
}
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;
}
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;
}
/**
* 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));
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
@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);
}
}
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;
}
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;
}