");
+ break;
+ case URL:
+ out.print(url);
+ break;
+ }
}
return EVAL_BODY_INCLUDE;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/VariableTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/VariableTag.java
index 4f746523d0..babeaa8bd5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/VariableTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/VariableTag.java
@@ -73,26 +73,27 @@ public void setDefault( final String arg )
@Override
public final int doWikiStartTag() throws JspException, IOException {
final Engine engine = m_wikiContext.getEngine();
- final JspWriter out = pageContext.getOut();
- String msg = null;
- String value = null;
-
- try {
- value = engine.getManager( VariableManager.class ).getValue( m_wikiContext, getVar() );
- } catch( final NoSuchVariableException e ) {
- msg = "No such variable: " + e.getMessage();
- } catch( final IllegalArgumentException e ) {
- msg = "Incorrect variable name: " + e.getMessage();
+ try (JspWriter out = pageContext.getOut()) {
+ String msg = null;
+ String value = null;
+
+ try {
+ value = engine.getManager(VariableManager.class).getValue(m_wikiContext, getVar());
+ } catch (final NoSuchVariableException e) {
+ msg = "No such variable: " + e.getMessage();
+ } catch (final IllegalArgumentException e) {
+ msg = "Incorrect variable name: " + e.getMessage();
+ }
+
+ if (value == null) {
+ value = m_default;
+ }
+
+ if (value == null) {
+ value = msg;
+ }
+ out.write(TextUtil.replaceEntities(value));
}
-
- if( value == null ) {
- value = m_default;
- }
-
- if( value == null ) {
- value = msg;
- }
- out.write( TextUtil.replaceEntities(value) );
return SKIP_BODY;
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
index 7d2bb0004c..52ccb9f0d5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
@@ -107,18 +107,19 @@ public void doFilter( final ServletRequest request, final ServletResponse respon
}
if( m_engine == null ) {
- final PrintWriter out = response.getWriter();
- out.print("Fatal problem with JSPWiki");
- out.print("");
- out.print("JSPWiki has not been started
");
- out.print("JSPWiki is not running. This is probably due to a configuration error in your jspwiki.properties file, ");
- out.print("or a problem with your servlet container. Please double-check everything before issuing a bug report ");
- out.print("at jspwiki.apache.org.
");
- out.print("We apologize for the inconvenience. No, really, we do. We're trying to ");
- out.print("JSPWiki as easy as we can, but there is only so much we have time to test ");
- out.print("platforms.
");
- out.print( "Please go to the installer to continue.
" );
- out.print("");
+ try (PrintWriter out = response.getWriter()) {
+ out.print("Fatal problem with JSPWiki");
+ out.print("");
+ out.print("JSPWiki has not been started
");
+ out.print("JSPWiki is not running. This is probably due to a configuration error in your jspwiki.properties file, ");
+ out.print("or a problem with your servlet container. Please double-check everything before issuing a bug report ");
+ out.print("at jspwiki.apache.org.
");
+ out.print("We apologize for the inconvenience. No, really, we do. We're trying to ");
+ out.print("JSPWiki as easy as we can, but there is only so much we have time to test ");
+ out.print("platforms.
");
+ out.print("Please go to the installer to continue.
");
+ out.print("");
+ }
return;
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
index d320ead111..508dc6fa60 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
@@ -124,9 +124,10 @@ public void doPost( final HttpServletRequest request, final HttpServletResponse
response.setContentType( "text/xml; charset=utf-8" );
response.setContentLength( result.length );
- final OutputStream out = response.getOutputStream();
- out.write( result );
- out.flush();
+ try (OutputStream out = response.getOutputStream()) {
+ out.write(result);
+ out.flush();
+ }
// LOG.debug("Result = "+new String(result) );
} catch( final IOException e ) {