本文整理匯總了Java中javax.servlet.jsp.JspWriter.print方法的典型用法代碼示例。如果您正苦於以下問題:Java JspWriter.print方法的具體用法?Java JspWriter.print怎麽用?Java JspWriter.print使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.jsp.JspWriter
的用法示例。
在下文中一共展示了JspWriter.print方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: write
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
/**
* Write the specified text as the response to the writer associated with
* this page. <strong>WARNING</strong> - If you are writing body content
* from the <code>doAfterBody()</code> method of a custom tag class that
* implements <code>BodyTag</code>, you should be calling
* <code>writePrevious()</code> instead.
*
* @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 write(PageContext pageContext, String text)
throws JspException {
JspWriter writer = pageContext.getOut();
try {
writer.print(text);
} catch (IOException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw new JspException
(messages.getMessage("write.io", e.toString()));
}
}
示例2: 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()));
}
}
示例3: doStartTag
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
@Override
public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String path = WebUtil.getBaseServerURL() + request.getContextPath();
if (!path.endsWith("/")) {
path += "/";
}
try {
JspWriter writer = pageContext.getOut();
writer.print(path);
} catch (IOException e) {
WebAppURLTag.log.error("ServerURLTag unable to write out server URL due to IOException. ", e);
throw new JspException(e);
}
return Tag.SKIP_BODY;
}
示例4: doStartTag
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
@Override
public int doStartTag() throws JspException {
String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL);
serverURL = (serverURL != null ? serverURL.trim() : null);
if (serverURL != null && serverURL.length() > 0) {
JspWriter writer = pageContext.getOut();
try {
writer.print(serverURL);
} catch (IOException e) {
log.error("ServerURLTag unable to write out server URL due to IOException. ", e);
throw new JspException(e);
}
} else {
log.warn("ServerURLTag unable to write out server URL as it is missing from the configuration file.");
}
return SKIP_BODY;
}
示例5: 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();
}
示例6: 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);
}
示例7: output
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
public static boolean output(JspWriter out, Object input, String value,
String defaultValue, boolean escapeXml) throws IOException {
if (input instanceof Reader) {
char[] buffer = new char[8096];
int read = 0;
while (read != -1) {
read = ((Reader) input).read(buffer);
if (read != -1) {
if (escapeXml) {
String escaped = Util.escapeXml(buffer, read);
if (escaped == null) {
out.write(buffer, 0, read);
} else {
out.print(escaped);
}
} else {
out.write(buffer, 0, read);
}
}
}
return true;
} else {
String v = value != null ? value : defaultValue;
if (v != null) {
if(escapeXml){
v = Util.escapeXml(v);
}
out.write(v);
return true;
} else {
return false;
}
}
}
示例8: doStartTag
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
/**
* Render the JavaScript for to perform validations based on the form name.
*
* @exception JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
JspWriter writer = pageContext.getOut();
try {
writer.print(this.renderJavascript());
} catch (IOException e) {
throw new JspException(e.getMessage());
}
return EVAL_BODY_TAG;
}
示例9: doEndTag
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
/**
* Render the end of this form.
*
* @exception JspException if a JSP exception has occurred
*/
public int doEndTag() throws JspException {
// Remove the page scope attributes we created
pageContext.removeAttribute(Constants.BEAN_KEY, PageContext.REQUEST_SCOPE);
pageContext.removeAttribute(Constants.FORM_KEY, PageContext.REQUEST_SCOPE);
// Render a tag representing the end of our current form
StringBuffer results = new StringBuffer("</form>");
// Render JavaScript to set the input focus if required
if (this.focus != null) {
results.append(this.renderFocusJavascript());
}
// Print this value to our output writer
JspWriter writer = pageContext.getOut();
try {
writer.print(results.toString());
} catch (IOException e) {
throw new JspException(messages.getMessage("common.io", e.toString()));
}
// Continue processing this page
return (EVAL_PAGE);
}
示例10: doEndTag
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
@Override
public int doEndTag() throws JspException {
String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL);
serverURL = serverURL == null ? null : serverURL.trim();
try {
if (userId != null && userId.length() > 0) {
String code = null;
HashMap<String, String> cache = getPortraitCache();
code = cache.get(userId);
if (code == null) {
Integer userIdInt = Integer.decode(userId);
User user = (User) getUserManagementService().findById(User.class, userIdInt);
boolean isHover = (hover != null ? Boolean.valueOf(hover) : false);
if ( isHover ) {
code = buildHoverUrl(user);
} else {
code = buildDivUrl(user);
}
cache.put(userId, code);
}
JspWriter writer = pageContext.getOut();
writer.print(code);
}
} catch (NumberFormatException nfe) {
PortraitTag.log.error("PortraitId unable to write out portrait details as userId is invalid. " + userId,
nfe);
} catch (IOException ioe) {
PortraitTag.log.error(
"PortraitId unable to write out portrait details due to IOException. UserId is " + userId, ioe);
} catch (Exception e) {
PortraitTag.log.error(
"PortraitId unable to write out portrait details due to an exception. UserId is " + userId, e);
}
return Tag.SKIP_BODY;
}
示例11: doStartTag
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
@Override
public int doStartTag() throws JspException {
JspWriter writer = pageContext.getOut();
try {
writer.print(Configuration.get(getKey()));
} catch (IOException e) {
log.error("Error in configuration tag", e);
throw new JspException(e);
}
return SKIP_BODY;
}
示例12: doEndTag
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
@Override
public int doEndTag() throws JspException {
if ((jspFile.indexOf( ".." ) >= 0) ||
(jspFile.toUpperCase(Locale.ENGLISH).indexOf("/WEB-INF/") != 0) ||
(jspFile.toUpperCase(Locale.ENGLISH).indexOf("/META-INF/") != 0))
throw new JspTagException("Invalid JSP file " + jspFile);
InputStream in = pageContext.getServletContext().getResourceAsStream(
jspFile);
if (in == null)
throw new JspTagException("Unable to find JSP file: " + jspFile);
try {
JspWriter out = pageContext.getOut();
out.println("<body>");
out.println("<pre>");
for (int ch = in.read(); ch != -1; ch = in.read())
if (ch == '<')
out.print("<");
else
out.print((char) ch);
out.println("</pre>");
out.println("</body>");
} catch (IOException ex) {
throw new JspTagException("IOException: " + ex.toString());
} finally {
try {
in.close();
} catch (IOException e) {
throw new JspTagException("Can't close inputstream: ", e);
}
}
return super.doEndTag();
}
示例13: output
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
public static boolean output(JspWriter out, Object input, String value, String defaultValue, boolean escapeXml)
throws IOException {
if (input instanceof Reader) {
char[] buffer = new char[8096];
int read = 0;
while (read != -1) {
read = ((Reader) input).read(buffer);
if (read != -1) {
if (escapeXml) {
String escaped = Util.escapeXml(buffer, read);
if (escaped == null) {
out.write(buffer, 0, read);
} else {
out.print(escaped);
}
} else {
out.write(buffer, 0, read);
}
}
}
return true;
} else {
String v = value != null ? value : defaultValue;
if (v != null) {
if (escapeXml) {
v = Util.escapeXml(v);
}
out.write(v);
return true;
} else {
return false;
}
}
}
示例14: otherDoEndTagOperations
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
/** Called from the doEndTag()
*/
public void otherDoEndTagOperations() throws JspException {
super.otherDoEndTagOperations();
// Generate the HTML
if (!m_propertyRuleIntrospector.isHidden() && m_model != null) {
String html = null;
if (m_displayOnly) {
// Just display the text for a readOnly field
html = getDisplayOnlyHtml();
} else {
String classPrefix = m_propertyRuleIntrospector.isMandatory() ? "<span class=\"dropdownMandatoryPrefix\"> </span>" : "<span class=\"dropdownOptionalPrefix\"> </span>";
String classSuffix = m_propertyRuleIntrospector.isMandatory() ? "<span class=\"dropdownMandatorySuffix\"> </span>" : "<span class=\"dropdownOptionalSuffix\"> </span>";
html = classPrefix + getHtml() + classSuffix;
html += getJavascript();
}
if (html != null) {
// Write the HTML
JspWriter out = pageContext.getOut();
try {
out.print(html);
} catch (IOException e) {
String str = "Exception in writing the " + TAG_NAME;
log.error(str, e);
throw new JspWriteRuntimeException(str, e);
}
}
}
}
示例15: writeTagBodyContent
import javax.servlet.jsp.JspWriter; //導入方法依賴的package包/類
/** This generates the HTML for the tag, unless there is a layout, in which case it is sent there.
* @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 {
//log.debug("writeTagBodyContent: " + this.toString());
if (m_layoutTag != null) {
m_layoutTag.addSectionContent(m_id,bodyContent.getString());
} else {
// Generate a folding section
if (m_containsContent || (!m_hideIfNoWidgets)) {
out.print( LayoutTag.createFoldingSection( getId(), getLabel(), getLabelEditorLink(),
isClosed(), bodyContent.getString()));
}
}
// clear the body content for the next time through.
bodyContent.clearBody();
}