本文整理汇总了Java中javax.servlet.jsp.JspWriter类的典型用法代码示例。如果您正苦于以下问题:Java JspWriter类的具体用法?Java JspWriter怎么用?Java JspWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JspWriter类属于javax.servlet.jsp包,在下文中一共展示了JspWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doEndTag
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/**
* Does two things:
* <ul>
* <li>Stops the page if the corresponding attribute has been set</li>
* <li>Prints a message another tag encloses this one.</li>
* </ul>
*/
public int doEndTag() throws JspTagException
{
//get the parent if any
Tag parent = this.getParent();
if (parent != null) {
try {
JspWriter out = this.pageContext.getOut();
out.println("This tag has a parent. <BR>");
} catch (IOException e) {
throw new JspTagException(e.getMessage());
}
}
if (this.stopPage) {
return Tag.SKIP_PAGE;
}
return Tag.EVAL_PAGE;
}
示例2: writeTagBodyContent
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/** This generates the HTML for the tag.
* @param out The JspWriter object.
* @param bodyContent The BodyContent object.
* @throws IOException if any I/O error occurs.
*/
public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
// clear the body content for the next time through.
bodyContent.clearBody();
// get the model
TableModel model = null;
try {
model = (TableModel) TagHelper.getModel(pageContext, getField(), TAG_NAME);
} catch (ClassCastException e) {
String str = "Wrong WidgetModel for " + TAG_NAME + " on field " + getField();
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
if (model != null) {
// write out the html
String idPrefix = getHtmlIdPrefix();
out.println( getHtml(idPrefix, model));
}
}
示例3: pushBody
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
public JspWriter pushBody(Writer writer) {
depth++;
if (depth >= outs.length) {
BodyContentImpl[] newOuts = new BodyContentImpl[depth + 1];
for (int i = 0; i < outs.length; i++) {
newOuts[i] = outs[i];
}
newOuts[depth] = new BodyContentImpl(out);
outs = newOuts;
}
outs[depth].setWriter(writer);
out = outs[depth];
// Update the value of the "out" attribute in the page scope
// attribute namespace of this PageContext
setAttribute(OUT, out);
return outs[depth];
}
示例4: writePrevious
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/**
* Write the specified text as the response to the writer associated with
* the body content for the tag within which we are currently nested.
*
* @param pageContext The PageContext object for this page
* @param text The text to be written
*
* @exception JspException if an input/output error occurs (already saved)
*/
public void writePrevious(PageContext pageContext, String text)
throws JspException {
JspWriter writer = pageContext.getOut();
if (writer instanceof BodyContent) {
writer = ((BodyContent) writer).getEnclosingWriter();
}
try {
writer.print(text);
} catch (IOException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw new JspException
(messages.getMessage("write.io", e.toString()));
}
}
示例5: doStartTag
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/**
* Process the start of this tag.
*
* @exception 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;
String baseTag =
renderBaseElement(
request.getScheme(),
serverName,
request.getServerPort(),
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;
}
示例6: doEndTag
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/** This concludes the html of the Form tag.
* @throws JspException if any error occurs.
* @return EVAL_PAGE if the JSP engine should continue evaluating the JSP page, otherwise return SKIP_PAGE.
*/
public int doEndTag() throws JspException {
// Note: popping the nested component stack here causes runtime problems.
try {
JspWriter writer = pageContext.getOut();
doEndTagExt1(writer);
int i = super.doEndTag();
doEndTagExt2(writer);
return i;
} catch (IOException e) {
throw new JspException("error in FormTag: " + e);
} finally {
// Remove from stack
CustomTag.popParent(this,pageContext);
}
}
示例7: perform
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/** Looks up the request stream for input parameters and then generates appropriate metaData. */
public static void perform(HttpServletRequest request, JspWriter out, ServletContext servletContext) throws Exception {
// Create a parameter Map from the input request
Map<String, String> parameters = getParameters(request);
if (log.isDebugEnabled())
log.debug("Input: " + parameters);
// Error out if parameters are not passed
if (parameters == null) {
String m = "MetaData cannot be generated since parameters have not been passed";
log.error(m);
throw new IllegalArgumentException(m);
}
// Obtain metaData
String metaData = c_enableCaching ? obtainMetaData(parameters, servletContext) : generateMetaData(parameters, servletContext);
out.print(metaData);
}
示例8: include
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/**
* 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));
}
示例9: writeTagBodyContent
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/** This generates the HTML for the tag.
* @param out The JspWriter object.
* @param bodyContent The BodyContent object.
* @throws IOException if any I/O error occurs.
*/
public void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
if (isFirstPass())
// Write the main table tag, the table column headings, and start the table body
out.println( getInitialHtml() );
// Write out the start and end of the rows.
out.println( getRowStartHtml() );
if (m_hasRows)
out.println( processRow());
out.println( getRowEndingHtml() );
// clear the body content for the next time through.
bodyContent.clearBody();
// Increment the RowNo
++m_rowNo;
//Reset the column counters
m_currColumnNo = 0;
m_currColName = null;
}
示例10: doEndTag
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
@Override
public int doEndTag() throws JspException {
JspWriter out = pageContext.getOut();
try {
if (!"-1".equals(objectValue)) {
out.print(objectValue);
} else if (!"-1".equals(stringValue)) {
out.print(stringValue);
} else if (longValue != -1) {
out.print(longValue);
} else if (doubleValue != -1) {
out.print(doubleValue);
} else {
out.print("-1");
}
} catch (IOException ex) {
throw new JspTagException("IOException: " + ex.toString(), ex);
}
return super.doEndTag();
}
示例11: doStartTagInternal
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
@Override
protected int doStartTagInternal() throws Exception {
try {
String avatarUrl;
String id = userId;
String avatar = this.avatar;
if (current || id == null) {
DiscordUserDetails details = SecurityUtils.getCurrentUser();
if (details != null) {
id = details.getId();
avatar = details.getAvatar();
}
}
avatarUrl = AvatarType.USER.getUrl(id, avatar);
JspWriter out = pageContext.getOut();
out.write(avatarUrl);
} catch (Exception ex) {
throw new JspException(ex);
}
return SKIP_BODY;
}
示例12: doStartTagInternal
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
@Override
protected int doStartTagInternal() throws Exception {
try {
String result = code;
Long serverId = (Long) pageContext.getRequest().getAttribute("serverId");
if (serverId != null) {
Locale locale = (Locale) pageContext.getAttribute(LOCALE_ATTR);
ApplicationContext context = getRequestContext().getWebApplicationContext();
if (locale == null) {
ContextService contextService = context.getBean(ContextService.class);
locale = contextService.getLocale(serverId);
pageContext.setAttribute(LOCALE_ATTR, locale);
}
result = context.getMessage(code, null, locale);
}
if (StringUtils.isNotEmpty(var)) {
pageContext.setAttribute(var, result);
} else {
JspWriter out = pageContext.getOut();
out.write(result);
}
} catch (Exception ex) {
throw new JspException(ex);
}
return SKIP_BODY;
}
示例13: doAfterBody
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/** .//GEN-BEGIN:doAfterbody
*
*
* This method is called after the JSP engine processes the body content of the tag.
* @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
* This method is automatically generated. Do not modify this method.
* Instead, modify the methods that this method calls.
* @throws JspException
* @throws JspException */
public int doAfterBody() throws JspException, JspException {
try {
//
// This code is generated for tags whose bodyContent is "JSP"
//
JspWriter out = getPreviousOut();
BodyContent bodyContent = getBodyContent();
writeTagBodyContent(out, bodyContent);
} catch (Exception ex) {
throw new JspException("error in FunctionGuardTag: " + ex);
}
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
}
示例14: doAfterBody
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/** .//GEN-BEGIN:doAfterbody
*
*
* This method is called after the JSP engine processes the body content of the tag.
* @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
* This method is automatically generated. Do not modify this method.
* Instead, modify the methods that this method calls.
* @throws JspException */
public int doAfterBody() throws JspException {
try {
//
// This code is generated for tags whose bodyContent is "JSP"
//
JspWriter out = getPreviousOut();
BodyContent bodyContent = getBodyContent();
writeTagBodyContent(out, bodyContent);
} catch (Exception ex) {
throw new JspException("error in ComponentGuardTag: " + ex);
}
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
}
示例15: otherDoEndTagOperations
import javax.servlet.jsp.JspWriter; //导入依赖的package包/类
/** The HTML is generated in this end tag, assuming the underlying field
* is not read-only or hidden
*/
public void otherDoEndTagOperations() throws JspException {
super.otherDoEndTagOperations();
if (getPropertyRuleIntrospector() == null ||
(getPropertyRuleIntrospector() != null && !getPropertyRuleIntrospector().isHidden() && !getPropertyRuleIntrospector().isReadOnly() ) ) {
try {
JspWriter out = pageContext.getOut();
out.println( getHtml() );
} catch (IOException e) {
String str = "Exception in writing the " + TAG_NAME;
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
} else {
log.debug(TAG_NAME + " Not displayed as field " + getField() + " is hidden or read-only");
}
}