This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit cef80e0c57de09c1ed581ef500b4eec1f3f8a11a Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Mar 20 15:05:42 2025 +0000 Code clean-up - formatting. No functional change. --- java/org/apache/jasper/tagplugins/jstl/Util.java | 110 ++++---- .../apache/jasper/tagplugins/jstl/core/Catch.java | 30 +-- .../jasper/tagplugins/jstl/core/ForEach.java | 18 +- .../jasper/tagplugins/jstl/core/ForTokens.java | 64 ++--- .../apache/jasper/tagplugins/jstl/core/Import.java | 292 ++++++++++++--------- .../apache/jasper/tagplugins/jstl/core/Out.java | 42 ++- .../apache/jasper/tagplugins/jstl/core/Param.java | 42 +-- .../jasper/tagplugins/jstl/core/Redirect.java | 41 ++- .../apache/jasper/tagplugins/jstl/core/Remove.java | 12 +- .../apache/jasper/tagplugins/jstl/core/Set.java | 93 ++++--- .../apache/jasper/tagplugins/jstl/core/Url.java | 50 ++-- .../apache/jasper/tagplugins/jstl/core/When.java | 2 +- 12 files changed, 416 insertions(+), 380 deletions(-) diff --git a/java/org/apache/jasper/tagplugins/jstl/Util.java b/java/org/apache/jasper/tagplugins/jstl/Util.java index 8cd9612815..6185420291 100644 --- a/java/org/apache/jasper/tagplugins/jstl/Util.java +++ b/java/org/apache/jasper/tagplugins/jstl/Util.java @@ -37,22 +37,18 @@ import jakarta.servlet.jsp.PageContext; import org.apache.jasper.compiler.Localizer; /** - * Util contains some often used consts, static methods and embedded class - * to support the JSTL tag plugin. + * Util contains some often used consts, static methods and embedded class to support the JSTL tag plugin. */ public class Util { - private static final String VALID_SCHEME_CHAR = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-"; + private static final String VALID_SCHEME_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-"; - public static final String DEFAULT_ENCODING = - "ISO-8859-1"; + public static final String DEFAULT_ENCODING = "ISO-8859-1"; private static final int HIGHEST_SPECIAL = '>'; - private static final char[][] specialCharactersRepresentation = - new char[HIGHEST_SPECIAL + 1][]; + private static final char[][] specialCharactersRepresentation = new char[HIGHEST_SPECIAL + 1][]; static { specialCharactersRepresentation['&'] = "&".toCharArray(); @@ -63,26 +59,22 @@ public class Util { } /** - * Converts the given string description of a scope to the corresponding - * PageContext constant. - * - * The validity of the given scope has already been checked by the - * appropriate TLV. + * Converts the given string description of a scope to the corresponding PageContext constant. The validity of the + * given scope has already been checked by the appropriate TLV. * * @param scope String description of scope * - * @return PageContext constant corresponding to given scope description - * - * taken from org.apache.taglibs.standard.tag.common.core.Util + * @return PageContext constant corresponding to given scope description taken from + * org.apache.taglibs.standard.tag.common.core.Util */ - public static int getScope(String scope){ + public static int getScope(String scope) { int ret = PageContext.PAGE_SCOPE; - if("request".equalsIgnoreCase(scope)){ + if ("request".equalsIgnoreCase(scope)) { ret = PageContext.REQUEST_SCOPE; - }else if("session".equalsIgnoreCase(scope)){ + } else if ("session".equalsIgnoreCase(scope)) { ret = PageContext.SESSION_SCOPE; - }else if("application".equalsIgnoreCase(scope)){ + } else if ("application".equalsIgnoreCase(scope)) { ret = PageContext.APPLICATION_SCOPE; } @@ -90,24 +82,25 @@ public class Util { } /** - * Returns <code>true</code> if our current URL is absolute, - * <code>false</code> otherwise. - * taken from org.apache.taglibs.standard.tag.common.core.ImportSupport + * Returns <code>true</code> if our current URL is absolute, <code>false</code> otherwise. taken from + * org.apache.taglibs.standard.tag.common.core.ImportSupport + * * @param url The URL + * * @return <code>true</code> if the URL is absolute */ - public static boolean isAbsoluteUrl(String url){ - if(url == null){ + public static boolean isAbsoluteUrl(String url) { + if (url == null) { return false; } int colonPos = url.indexOf(':'); - if(colonPos == -1){ + if (colonPos == -1) { return false; } - for(int i=0;i<colonPos;i++){ - if(VALID_SCHEME_CHAR.indexOf(url.charAt(i)) == -1){ + for (int i = 0; i < colonPos; i++) { + if (VALID_SCHEME_CHAR.indexOf(url.charAt(i)) == -1) { return false; } } @@ -116,11 +109,12 @@ public class Util { } /** - * Get the value associated with a content-type attribute. - * Syntax defined in RFC 2045, section 5.1. - * taken from org.apache.taglibs.standard.tag.common.core.Util + * Get the value associated with a content-type attribute. Syntax defined in RFC 2045, section 5.1. taken from + * org.apache.taglibs.standard.tag.common.core.Util + * * @param input The attribute string - * @param name The attribute name + * @param name The attribute name + * * @return the attribute value */ public static String getContentTypeAttribute(String input, String name) { @@ -159,19 +153,18 @@ public class Util { } /** - * Performs the following substring replacements - * (to facilitate output to XML/HTML pages): + * Performs the following substring replacements (to facilitate output to XML/HTML pages): * <ul> - * <li>{@code &} -> {@code &}</li> - * <li>{@code <} -> {@code <}</li> - * <li>{@code >} -> {@code >}</li> - * <li>{@code "} -> {@code "}</li> - * <li>{@code '} -> {@code '}</li> + * <li>{@code &} -> {@code &}</li> + * <li>{@code <} -> {@code <}</li> + * <li>{@code >} -> {@code >}</li> + * <li>{@code "} -> {@code "}</li> + * <li>{@code '} -> {@code '}</li> * </ul> - * See also OutSupport.writeEscapedXml(). + * See also OutSupport.writeEscapedXml(). taken from org.apache.taglibs.standard.tag.common.core.Util * - * taken from org.apache.taglibs.standard.tag.common.core.Util * @param buffer Data to escape + * * @return escaped data */ public static String escapeXml(String buffer) { @@ -195,7 +188,7 @@ public class Util { } // add unescaped portion if (start < i) { - escapedBuffer.append(arrayBuffer,start,i-start); + escapedBuffer.append(arrayBuffer, start, i - start); } start = i + 1; // add escaped xml @@ -209,31 +202,30 @@ public class Util { } // add rest of unescaped portion if (start < length) { - escapedBuffer.append(arrayBuffer,start,length-start); + escapedBuffer.append(arrayBuffer, start, length - start); } return escapedBuffer.toString(); } /** - * Utility methods - * taken from org.apache.taglibs.standard.tag.common.core.UrlSupport - * @param url The URL - * @param context The context + * Utility methods taken from org.apache.taglibs.standard.tag.common.core.UrlSupport + * + * @param url The URL + * @param context The context * @param pageContext The page context + * * @return the absolute URL + * * @throws JspException If the URL doesn't start with '/' */ - public static String resolveUrl( - String url, String context, PageContext pageContext) - throws JspException { + public static String resolveUrl(String url, String context, PageContext pageContext) throws JspException { // don't touch absolute URLs if (isAbsoluteUrl(url)) { return url; } // normalize relative URLs against a context root - HttpServletRequest request = - (HttpServletRequest) pageContext.getRequest(); + HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); if (context == null) { if (url.startsWith("/")) { return request.getContextPath() + url; @@ -256,10 +248,10 @@ public class Util { } /** - * Wraps responses to allow us to retrieve results as Strings. Mainly taken - * from org.apache.taglibs.standard.tag.common.core.importSupport. + * Wraps responses to allow us to retrieve results as Strings. Mainly taken from + * org.apache.taglibs.standard.tag.common.core.importSupport. */ - public static class ImportResponseWrapper extends HttpServletResponseWrapper{ + public static class ImportResponseWrapper extends HttpServletResponseWrapper { private final StringWriter sw = new StringWriter(); private final ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -282,7 +274,6 @@ public class Util { } - }; private boolean isWriterUsed; private boolean isStreamUsed; @@ -331,11 +322,11 @@ public class Util { return status; } - public String getCharEncoding(){ + public String getCharEncoding() { return this.charEncoding; } - public void setCharEncoding(String ce){ + public void setCharEncoding(String ce) { this.charEncoding = ce; } @@ -348,8 +339,7 @@ public class Util { } else { return bos.toString(StandardCharsets.ISO_8859_1); } - } - else { + } else { return ""; // target didn't write anything } } diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Catch.java b/java/org/apache/jasper/tagplugins/jstl/core/Catch.java index a51af3025d..5eeee41d43 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Catch.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Catch.java @@ -24,41 +24,41 @@ public class Catch implements TagPlugin { @Override public void doTag(TagPluginContext ctxt) { - //flag for the existence of the var attribute + // flag for the existence of the var attribute boolean hasVar = ctxt.isAttributeSpecified("var"); - //temp name for exception and caught + // temp name for exception and caught String exceptionName = ctxt.getTemporaryVariableName(); String caughtName = ctxt.getTemporaryVariableName(); - //main part to generate code + // main part to generate code ctxt.generateJavaSource("boolean " + caughtName + " = false;"); ctxt.generateJavaSource("try{"); ctxt.generateBody(); ctxt.generateJavaSource("}"); - //do catch + // do catch ctxt.generateJavaSource("catch(Throwable " + exceptionName + "){"); - //if the var specified, the exception object should - //be set to the attribute "var" defines in page scope - if(hasVar){ + // if the var specified, the exception object should + // be set to the attribute "var" defines in page scope + if (hasVar) { String strVar = ctxt.getConstantAttribute("var"); - ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\", " - + exceptionName + ", PageContext.PAGE_SCOPE);"); + ctxt.generateJavaSource( + " pageContext.setAttribute(\"" + strVar + "\", " + exceptionName + ", PageContext.PAGE_SCOPE);"); } - //whenever there's exception caught, - //the flag caught should be set true; + // whenever there's exception caught, + // the flag caught should be set true; ctxt.generateJavaSource(" " + caughtName + " = true;"); ctxt.generateJavaSource("}"); - //do finally + // do finally ctxt.generateJavaSource("finally{"); - //if var specified, the attribute it defines - //in page scope should be removed - if(hasVar){ + // if var specified, the attribute it defines + // in page scope should be removed + if (hasVar) { String strVar = ctxt.getConstantAttribute("var"); ctxt.generateJavaSource(" if(!" + caughtName + "){"); ctxt.generateJavaSource(" pageContext.removeAttribute(\"" + strVar + "\", PageContext.PAGE_SCOPE);"); diff --git a/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java b/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java index 19bdede07e..b3d318f034 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java @@ -71,8 +71,7 @@ public final class ForEach implements TagPlugin { } /** - * Generate codes for Collections - * The pseudo code is: + * Generate codes for Collections The pseudo code is: */ private void doCollection(TagPluginContext ctxt) { @@ -84,7 +83,7 @@ public final class ForEach implements TagPlugin { ctxt.generateAttribute("items"); ctxt.generateJavaSource(";"); - String indexV=null, beginV=null, endV=null, stepV=null; + String indexV = null, beginV = null, endV = null, stepV = null; if (hasBegin) { beginV = ctxt.getTemporaryVariableName(); ctxt.generateJavaSource("int " + beginV + " = "); @@ -161,9 +160,8 @@ public final class ForEach implements TagPlugin { if (hasBegin) { String tV = ctxt.getTemporaryVariableName(); - ctxt.generateJavaSource("for (int " + tV + "=" + beginV + ";" + - tV + ">0 && " + iterV + ".hasNext(); " + - tV + "--)"); + ctxt.generateJavaSource( + "for (int " + tV + "=" + beginV + ";" + tV + ">0 && " + iterV + ".hasNext(); " + tV + "--)"); ctxt.generateJavaSource(iterV + ".next();"); } @@ -178,9 +176,8 @@ public final class ForEach implements TagPlugin { if (hasStep) { String tV = ctxt.getTemporaryVariableName(); - ctxt.generateJavaSource("for (int " + tV + "=" + stepV + "-1;" + - tV + ">0 && " + iterV + ".hasNext(); " + - tV + "--)"); + ctxt.generateJavaSource( + "for (int " + tV + "=" + stepV + "-1;" + tV + ">0 && " + iterV + ".hasNext(); " + tV + "--)"); ctxt.generateJavaSource(iterV + ".next();"); } if (hasEnd) { @@ -190,8 +187,7 @@ public final class ForEach implements TagPlugin { ctxt.generateJavaSource(indexV + "++;"); } if (hasBegin) { - ctxt.generateJavaSource("if(" + beginV + "+" + indexV + - ">"+ endV + ")"); + ctxt.generateJavaSource("if(" + beginV + "+" + indexV + ">" + endV + ")"); } else { ctxt.generateJavaSource("if(" + indexV + ">" + endV + ")"); } diff --git a/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java b/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java index c4e1cabf94..2e37b08e70 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java @@ -25,60 +25,61 @@ public class ForTokens implements TagPlugin { public void doTag(TagPluginContext ctxt) { boolean hasVar, hasVarStatus, hasBegin, hasEnd, hasStep; - //init the flags + // init the flags hasVar = ctxt.isAttributeSpecified("var"); hasVarStatus = ctxt.isAttributeSpecified("varStatus"); hasBegin = ctxt.isAttributeSpecified("begin"); hasEnd = ctxt.isAttributeSpecified("end"); hasStep = ctxt.isAttributeSpecified("step"); - if(hasVarStatus){ + if (hasVarStatus) { ctxt.dontUseTagPlugin(); return; } - //define all the temp variables' names + // define all the temp variables' names String itemsName = ctxt.getTemporaryVariableName(); String delimsName = ctxt.getTemporaryVariableName(); String stName = ctxt.getTemporaryVariableName(); String beginName = ctxt.getTemporaryVariableName(); - String endName = ctxt.getTemporaryVariableName(); + String endName = ctxt.getTemporaryVariableName(); String stepName = ctxt.getTemporaryVariableName(); String index = ctxt.getTemporaryVariableName(); - String temp = ctxt.getTemporaryVariableName(); + String temp = ctxt.getTemporaryVariableName(); String tokensCountName = ctxt.getTemporaryVariableName(); - //get the value of the "items" attribute + // get the value of the "items" attribute ctxt.generateJavaSource("String " + itemsName + " = (String)"); ctxt.generateAttribute("items"); ctxt.generateJavaSource(";"); - //get the value of the "delim" attribute + // get the value of the "delim" attribute ctxt.generateJavaSource("String " + delimsName + " = (String)"); ctxt.generateAttribute("delims"); ctxt.generateJavaSource(";"); - //new a StringTokenizer Object according to the "items" and the "delim" - ctxt.generateJavaSource("java.util.StringTokenizer " + stName + " = " + - "new java.util.StringTokenizer(" + itemsName + ", " + delimsName + ");"); + // new a StringTokenizer Object according to the "items" and the "delim" + ctxt.generateJavaSource("java.util.StringTokenizer " + stName + " = " + "new java.util.StringTokenizer(" + + itemsName + ", " + delimsName + ");"); - //if "begin" specified, move the token to the "begin" place - //and record the begin index. default begin place is 0. + // if "begin" specified, move the token to the "begin" place + // and record the begin index. default begin place is 0. ctxt.generateJavaSource("int " + tokensCountName + " = " + stName + ".countTokens();"); - if(hasBegin){ - ctxt.generateJavaSource("int " + beginName + " = " ); + if (hasBegin) { + ctxt.generateJavaSource("int " + beginName + " = "); ctxt.generateAttribute("begin"); ctxt.generateJavaSource(";"); - ctxt.generateJavaSource("for(int " + index + " = 0; " + index + " < " + beginName + " && " + stName + ".hasMoreTokens(); " + index + "++, " + stName + ".nextToken()){}"); - }else{ + ctxt.generateJavaSource("for(int " + index + " = 0; " + index + " < " + beginName + " && " + stName + + ".hasMoreTokens(); " + index + "++, " + stName + ".nextToken()){}"); + } else { ctxt.generateJavaSource("int " + beginName + " = 0;"); } - //when "end" is specified, if the "end" is more than the last index, - //record the end place as the last index, otherwise, record it as "end"; - //default end place is the last index - if(hasEnd){ - ctxt.generateJavaSource("int " + endName + " = 0;" ); + // when "end" is specified, if the "end" is more than the last index, + // record the end place as the last index, otherwise, record it as "end"; + // default end place is the last index + if (hasEnd) { + ctxt.generateJavaSource("int " + endName + " = 0;"); ctxt.generateJavaSource("if((" + tokensCountName + " - 1) < "); ctxt.generateAttribute("end"); ctxt.generateJavaSource("){"); @@ -87,26 +88,27 @@ public class ForTokens implements TagPlugin { ctxt.generateJavaSource(" " + endName + " = "); ctxt.generateAttribute("end"); ctxt.generateJavaSource(";}"); - }else{ + } else { ctxt.generateJavaSource("int " + endName + " = " + tokensCountName + " - 1;"); } - //get the step value from "step" if specified. - //default step value is 1. - if(hasStep){ - ctxt.generateJavaSource("int " + stepName + " = " ); + // get the step value from "step" if specified. + // default step value is 1. + if (hasStep) { + ctxt.generateJavaSource("int " + stepName + " = "); ctxt.generateAttribute("step"); ctxt.generateJavaSource(";"); - }else{ + } else { ctxt.generateJavaSource("int " + stepName + " = 1;"); } - //the loop - ctxt.generateJavaSource("for(int " + index + " = " + beginName + "; " + index + " <= " + endName + "; " + index + "++){"); + // the loop + ctxt.generateJavaSource( + "for(int " + index + " = " + beginName + "; " + index + " <= " + endName + "; " + index + "++){"); ctxt.generateJavaSource(" String " + temp + " = " + stName + ".nextToken();"); ctxt.generateJavaSource(" if(((" + index + " - " + beginName + ") % " + stepName + ") == 0){"); - //if var specified, put the current token into the attribute "var" defines. - if(hasVar){ + // if var specified, put the current token into the attribute "var" defines. + if (hasVar) { String strVar = ctxt.getConstantAttribute("var"); ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\", " + temp + ");"); } diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Import.java b/java/org/apache/jasper/tagplugins/jstl/core/Import.java index aea45c0683..5e9097f38b 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Import.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Import.java @@ -26,19 +26,19 @@ public class Import implements TagPlugin { public void doTag(TagPluginContext ctxt) { boolean hasContext, hasVar, hasScope, hasVarReader, hasCharEncoding; - //flags - hasContext = ctxt.isAttributeSpecified("context"); + // flags + hasContext = ctxt.isAttributeSpecified("context"); hasVar = ctxt.isAttributeSpecified("var"); hasScope = ctxt.isAttributeSpecified("scope"); hasVarReader = ctxt.isAttributeSpecified("varReader"); hasCharEncoding = ctxt.isAttributeSpecified("charEncoding"); - //variables' names + // variables' names String urlName = ctxt.getTemporaryVariableName(); String contextName = ctxt.getTemporaryVariableName(); - String iauName = ctxt.getTemporaryVariableName(); // is absolute url - String urlObjName = ctxt.getTemporaryVariableName(); //URL object - String ucName = ctxt.getTemporaryVariableName(); //URLConnection + String iauName = ctxt.getTemporaryVariableName(); // is absolute url + String urlObjName = ctxt.getTemporaryVariableName(); // URL object + String ucName = ctxt.getTemporaryVariableName(); // URLConnection String inputStreamName = ctxt.getTemporaryVariableName(); String tempReaderName = ctxt.getTemporaryVariableName(); String tempReaderName2 = ctxt.getTemporaryVariableName(); @@ -49,172 +49,187 @@ public class Import implements TagPlugin { String servletContextName = ctxt.getTemporaryVariableName(); String servletPathName = ctxt.getTemporaryVariableName(); String requestDispatcherName = ctxt.getTemporaryVariableName(); - String irwName = ctxt.getTemporaryVariableName(); //ImportResponseWrapper name - String brName = ctxt.getTemporaryVariableName(); //BufferedReader name - String sbName = ctxt.getTemporaryVariableName(); //StringBuilder name + String irwName = ctxt.getTemporaryVariableName(); // ImportResponseWrapper name + String brName = ctxt.getTemporaryVariableName(); // BufferedReader name + String sbName = ctxt.getTemporaryVariableName(); // StringBuilder name String tempStringName = ctxt.getTemporaryVariableName(); - //is absolute url + // is absolute url ctxt.generateJavaSource("boolean " + iauName + ";"); - //get the url value + // get the url value ctxt.generateJavaSource("String " + urlName + " = "); ctxt.generateAttribute("url"); ctxt.generateJavaSource(";"); - //validate the url + // validate the url ctxt.generateJavaSource("if(" + urlName + " == null || " + urlName + ".equals(\"\")){"); ctxt.generateJavaSource(" throw new JspTagException(\"The \\\"url\\\" attribute " + - "illegally evaluated to \\\"null\\\" or \\\"\\\" in <import>\");"); + "illegally evaluated to \\\"null\\\" or \\\"\\\" in <import>\");"); ctxt.generateJavaSource("}"); - //initialize the is_absolute_url - ctxt.generateJavaSource(iauName + " = " + - "org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + urlName + ");"); + // initialize the is_absolute_url + ctxt.generateJavaSource( + iauName + " = " + "org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + urlName + ");"); - //validate the context - if(hasContext){ + // validate the context + if (hasContext) { ctxt.generateJavaSource("String " + contextName + " = "); ctxt.generateAttribute("context"); ctxt.generateJavaSource(";"); - ctxt.generateJavaSource("if((!" + contextName + ".startsWith(\"/\")) " + - "|| (!" + urlName + ".startsWith(\"/\"))){"); + ctxt.generateJavaSource( + "if((!" + contextName + ".startsWith(\"/\")) " + "|| (!" + urlName + ".startsWith(\"/\"))){"); ctxt.generateJavaSource(" throw new JspTagException" + "(\"In URL tags, when the \\\"context\\\" attribute is specified, " + - "values of both \\\"context\\\" and \\\"url\\\" must start with \\\"/\\\".\");"); + "values of both \\\"context\\\" and \\\"url\\\" must start with \\\"/\\\".\");"); ctxt.generateJavaSource("}"); } - //define charset + // define charset ctxt.generateJavaSource("String " + charSetName + " = null;"); - //if the charEncoding attribute is specified - if(hasCharEncoding){ + // if the charEncoding attribute is specified + if (hasCharEncoding) { - //initialize the charEncoding + // initialize the charEncoding ctxt.generateJavaSource("String " + charEncodingName + " = "); ctxt.generateAttribute("charEncoding"); ctxt.generateJavaSource(";"); - //assign appropriate value to the charset - ctxt.generateJavaSource("if(null != " + charEncodingName + " " + - "&& !" + charEncodingName + ".equals(\"\")){"); - ctxt.generateJavaSource(" " + charSetName + " = " - + charEncodingName + ";"); + // assign appropriate value to the charset + ctxt.generateJavaSource( + "if(null != " + charEncodingName + " " + "&& !" + charEncodingName + ".equals(\"\")){"); + ctxt.generateJavaSource(" " + charSetName + " = " + charEncodingName + ";"); ctxt.generateJavaSource("}"); } - //reshape the url string - ctxt.generateJavaSource("if(!"+iauName+"){"); + // reshape the url string + ctxt.generateJavaSource("if(!" + iauName + "){"); ctxt.generateJavaSource(" if(!" + urlName + ".startsWith(\"/\")){"); ctxt.generateJavaSource(" String " + servletPathName + " = " + - "((HttpServletRequest)pageContext.getRequest()).getServletPath();"); - ctxt.generateJavaSource(" " + urlName + " = " - + servletPathName + ".substring(0," + servletPathName + ".lastIndexOf('/')) + '/' + " + urlName + ";"); + "((HttpServletRequest)pageContext.getRequest()).getServletPath();"); + ctxt.generateJavaSource(" " + urlName + " = " + servletPathName + ".substring(0," + servletPathName + + ".lastIndexOf('/')) + '/' + " + urlName + ";"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource("}"); - //if the varReader attribute specified - if(hasVarReader){ + // if the varReader attribute specified + if (hasVarReader) { - //get the String value of varReader + // get the String value of varReader ctxt.generateJavaSource("String " + varReaderName + " = "); ctxt.generateAttribute("varReader"); ctxt.generateJavaSource(";"); - //if the url is absolute url + // if the url is absolute url ctxt.generateJavaSource("if(" + iauName + "){"); - //get the content of the target + // get the content of the target ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");"); - ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = " - + urlObjName + ".openConnection();"); - ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = " - + ucName + ".getInputStream();"); + ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = " + urlObjName + ".openConnection();"); + ctxt.generateJavaSource( + " java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();"); ctxt.generateJavaSource(" if(" + charSetName + " == null){"); - ctxt.generateJavaSource(" String " + contentTypeName + " = " - + ucName + ".getContentType();"); + ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();"); ctxt.generateJavaSource(" if(null != " + contentTypeName + "){"); ctxt.generateJavaSource(" " + charSetName + " = " + - "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");"); - ctxt.generateJavaSource(" if(" + charSetName + " == null) " - + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); + "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + + ", \"charset\");"); + ctxt.generateJavaSource(" if(" + charSetName + " == null) " + charSetName + + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); ctxt.generateJavaSource(" }else{"); - ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); + ctxt.generateJavaSource( + " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" }"); - if(!hasCharEncoding){ + if (!hasCharEncoding) { ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();"); } - //define the Reader + // define the Reader ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;"); - //initialize the Reader object + // initialize the Reader object ctxt.generateJavaSource(" try{"); - ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", " + charSetName + ");"); + ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + + inputStreamName + ", " + charSetName + ");"); ctxt.generateJavaSource(" }catch(Exception ex){"); - ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);"); + ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + + inputStreamName + ", org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);"); ctxt.generateJavaSource(" }"); - //validate the response + // validate the response ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){"); - ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();"); + ctxt.generateJavaSource( + " int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();"); ctxt.generateJavaSource(" if(status < 200 || status > 299){"); ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" }"); - //set attribute in the page context scope + // set attribute in the page context scope ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");"); - //if the url is relative + // if the url is relative ctxt.generateJavaSource("}else{"); - //if the url is relative, http request is needed + // if the url is relative, http request is needed ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " + - "&& pageContext.getResponse() instanceof HttpServletResponse)){"); - ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");"); + "&& pageContext.getResponse() instanceof HttpServletResponse)){"); + ctxt.generateJavaSource( + " throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");"); ctxt.generateJavaSource(" }"); - //get the servlet context of the context defined in the context attribute + // get the servlet context of the context defined in the context attribute ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;"); - if(hasContext){ + if (hasContext) { ctxt.generateJavaSource(" if(null != " + contextName + "){"); - ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" ); + ctxt.generateJavaSource(" " + servletContextName + + " = pageContext.getServletContext().getContext(" + contextName + ");"); ctxt.generateJavaSource(" }else{"); ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();"); ctxt.generateJavaSource(" }"); - }else{ + } else { ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();"); } // ctxt.generateJavaSource(" if(" + servletContextName + " == null){"); - if(hasContext){ - ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \"+" + contextName + "+\" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");"); - }else{ - ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");"); + if (hasContext) { + ctxt.generateJavaSource( + " throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \"+" + + contextName + "+\" \\\" and URL: \\\" \" +" + urlName + + "+ \" \\\". Verify values and/or enable cross context access.\");"); + } else { + ctxt.generateJavaSource( + " throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");"); } ctxt.generateJavaSource(" }"); - //get the request dispatcher - ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));"); - ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));"); + // get the request dispatcher + ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + + ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));"); + ctxt.generateJavaSource(" if(" + requestDispatcherName + + " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession(" + + urlName + "));"); - //initialize a ImportResponseWrapper to include the resource - ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());"); + // initialize a ImportResponseWrapper to include the resource + ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + + " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());"); ctxt.generateJavaSource(" if(" + charSetName + " == null){"); - ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); + ctxt.generateJavaSource( + " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" + charSetName + ");"); ctxt.generateJavaSource(" try{"); - ctxt.generateJavaSource(" " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");"); + ctxt.generateJavaSource( + " " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");"); ctxt.generateJavaSource(" }catch(java.io.IOException ex){"); ctxt.generateJavaSource(" throw new JspException(ex);"); ctxt.generateJavaSource(" }catch(RuntimeException ex){"); @@ -227,35 +242,38 @@ public class Import implements TagPlugin { ctxt.generateJavaSource(" throw new JspException(rc);"); ctxt.generateJavaSource(" }"); - //validate the response status + // validate the response status ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){"); - ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));"); + ctxt.generateJavaSource(" throw new JspTagException(" + irwName + + ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));"); ctxt.generateJavaSource(" }"); - //push in the page context - ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = new java.io.StringReader(" + irwName + ".getString());"); + // push in the page context + ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = new java.io.StringReader(" + irwName + + ".getString());"); ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");"); ctxt.generateJavaSource("}"); - //execute the body action + // execute the body action ctxt.generateBody(); - //close the reader - ctxt.generateJavaSource("java.io.Reader " + tempReaderName2 + " = (java.io.Reader)pageContext.getAttribute(" + varReaderName + ");"); + // close the reader + ctxt.generateJavaSource("java.io.Reader " + tempReaderName2 + + " = (java.io.Reader)pageContext.getAttribute(" + varReaderName + ");"); ctxt.generateJavaSource("if(" + tempReaderName2 + " != null) " + tempReaderName2 + ".close();"); ctxt.generateJavaSource("pageContext.removeAttribute(" + varReaderName + ",1);"); } - //if the varReader is not specified - else{ + // if the varReader is not specified + else { ctxt.generateJavaSource("pageContext.setAttribute(\"url_without_param\"," + urlName + ");"); ctxt.generateBody(); ctxt.generateJavaSource(urlName + " = (String)pageContext.getAttribute(\"url_without_param\");"); ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");"); String strScope = "page"; - if(hasScope){ + if (hasScope) { strScope = ctxt.getConstantAttribute("scope"); } int iScope = Util.getScope(strScope); @@ -264,88 +282,108 @@ public class Import implements TagPlugin { ctxt.generateJavaSource("if(" + iauName + "){"); - //get the content of the target + // get the content of the target ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");"); ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = " + urlObjName + ".openConnection();"); - ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();"); + ctxt.generateJavaSource( + " java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();"); ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;"); ctxt.generateJavaSource(" if(" + charSetName + " == null){"); - ctxt.generateJavaSource(" String " + contentTypeName + " = " - + ucName + ".getContentType();"); + ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();"); ctxt.generateJavaSource(" if(null != " + contentTypeName + "){"); ctxt.generateJavaSource(" " + charSetName + " = " + - "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");"); - ctxt.generateJavaSource(" if(" + charSetName + " == null) " - + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); + "org.apache.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + + ", \"charset\");"); + ctxt.generateJavaSource(" if(" + charSetName + " == null) " + charSetName + + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); ctxt.generateJavaSource(" }else{"); - ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); + ctxt.generateJavaSource( + " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" try{"); - ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + "," + charSetName + ");"); + ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + + inputStreamName + "," + charSetName + ");"); ctxt.generateJavaSource(" }catch(Exception ex){"); - //ctxt.generateJavaSource(" throw new JspTagException(ex.toString());"); - ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ",org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);"); + // ctxt.generateJavaSource(" throw new JspTagException(ex.toString());"); + ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + + inputStreamName + ",org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);"); ctxt.generateJavaSource(" }"); - //validate the response + // validate the response ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){"); - ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();"); + ctxt.generateJavaSource( + " int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();"); ctxt.generateJavaSource(" if(status < 200 || status > 299){"); ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" }"); - ctxt.generateJavaSource(" java.io.BufferedReader " + brName + " = new java.io.BufferedReader(" + tempReaderName + ");"); + ctxt.generateJavaSource( + " java.io.BufferedReader " + brName + " = new java.io.BufferedReader(" + tempReaderName + ");"); ctxt.generateJavaSource(" StringBuilder " + sbName + " = new StringBuilder();"); String index = ctxt.getTemporaryVariableName(); ctxt.generateJavaSource(" int " + index + ";"); - ctxt.generateJavaSource(" while(("+index+" = "+brName+".read()) != -1) "+sbName+".append((char)"+index+");"); - ctxt.generateJavaSource(" " + tempStringName + " = " +sbName + ".toString();"); + ctxt.generateJavaSource(" while((" + index + " = " + brName + ".read()) != -1) " + sbName + + ".append((char)" + index + ");"); + ctxt.generateJavaSource(" " + tempStringName + " = " + sbName + ".toString();"); ctxt.generateJavaSource("}else{"); - //if the url is relative, http request is needed. + // if the url is relative, http request is needed. ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " + - "&& pageContext.getResponse() instanceof HttpServletResponse)){"); - ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");"); + "&& pageContext.getResponse() instanceof HttpServletResponse)){"); + ctxt.generateJavaSource( + " throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");"); ctxt.generateJavaSource(" }"); - //get the servlet context of the context defined in the context attribute + // get the servlet context of the context defined in the context attribute ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;"); - if(hasContext){ + if (hasContext) { ctxt.generateJavaSource(" if(null != " + contextName + "){"); - ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" ); + ctxt.generateJavaSource(" " + servletContextName + + " = pageContext.getServletContext().getContext(" + contextName + ");"); ctxt.generateJavaSource(" }else{"); ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();"); ctxt.generateJavaSource(" }"); - }else{ + } else { ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();"); } // ctxt.generateJavaSource(" if(" + servletContextName + " == null){"); - if(hasContext){ - ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \" +" + contextName + "+ \" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");"); - }else{ - ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");"); + if (hasContext) { + ctxt.generateJavaSource( + " throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \" +" + + contextName + "+ \" \\\" and URL: \\\" \" +" + urlName + + "+ \" \\\". Verify values and/or enable cross context access.\");"); + } else { + ctxt.generateJavaSource( + " throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");"); } ctxt.generateJavaSource(" }"); - //get the request dispatcher - ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));"); - ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));"); + // get the request dispatcher + ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + + ".getRequestDispatcher(org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));"); + ctxt.generateJavaSource(" if(" + requestDispatcherName + + " == null) throw new JspTagException(org.apache.jasper.tagplugins.jstl.Util.stripSession(" + + urlName + "));"); - //initialize a ImportResponseWrapper to include the resource - ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());"); + // initialize a ImportResponseWrapper to include the resource + ctxt.generateJavaSource(" org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + + " = new org.apache.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());"); ctxt.generateJavaSource(" if(" + charSetName + " == null){"); - ctxt.generateJavaSource(" " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); + ctxt.generateJavaSource( + " " + charSetName + " = org.apache.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" " + irwName + ".setCharEncoding(" + charSetName + ");"); ctxt.generateJavaSource(" try{"); - ctxt.generateJavaSource(" " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");"); + ctxt.generateJavaSource( + " " + requestDispatcherName + ".include(pageContext.getRequest(), " + irwName + ");"); ctxt.generateJavaSource(" }catch(java.io.IOException ex){"); ctxt.generateJavaSource(" throw new JspException(ex);"); ctxt.generateJavaSource(" }catch(RuntimeException ex){"); @@ -358,19 +396,21 @@ public class Import implements TagPlugin { ctxt.generateJavaSource(" throw new JspException(rc);"); ctxt.generateJavaSource(" }"); - //validate the response status + // validate the response status ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){"); - ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));"); + ctxt.generateJavaSource(" throw new JspTagException(" + irwName + + ".getStatus()+\" \" + org.apache.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" " + tempStringName + " = " + irwName + ".getString();"); ctxt.generateJavaSource("}"); - if(hasVar){ + if (hasVar) { String strVar = ctxt.getConstantAttribute("var"); - ctxt.generateJavaSource("pageContext.setAttribute(\""+strVar+"\"," + tempStringName + "," + iScope + ");"); - }else{ + ctxt.generateJavaSource( + "pageContext.setAttribute(\"" + strVar + "\"," + tempStringName + "," + iScope + ");"); + } else { ctxt.generateJavaSource("pageContext.getOut().print(" + tempStringName + ");"); } } diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Out.java b/java/org/apache/jasper/tagplugins/jstl/core/Out.java index 9c06a08b04..da43b80a16 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Out.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Out.java @@ -31,35 +31,33 @@ public final class Out implements TagPlugin { @Override public void doTag(TagPluginContext ctxt) { - //these two data member are to indicate - //whether the corresponding attribute is specified + // these two data member are to indicate + // whether the corresponding attribute is specified boolean hasDefault = ctxt.isAttributeSpecified("default"); boolean hasEscapeXml = ctxt.isAttributeSpecified("escapeXml"); - //strValName, strEscapeXmlName & strDefName are two variables' name - //standing for value, escapeXml and default attribute + // strValName, strEscapeXmlName & strDefName are two variables' name + // standing for value, escapeXml and default attribute String strObjectName = ctxt.getTemporaryVariableName(); String strValName = ctxt.getTemporaryVariableName(); String strDefName = ctxt.getTemporaryVariableName(); String strEscapeXmlName = ctxt.getTemporaryVariableName(); String strSkipBodyName = ctxt.getTemporaryVariableName(); - //according to the tag file, the value attribute is mandatory. + // according to the tag file, the value attribute is mandatory. ctxt.generateImport("java.io.Reader"); ctxt.generateJavaSource("Object " + strObjectName + "="); ctxt.generateAttribute("value"); ctxt.generateJavaSource(";"); ctxt.generateJavaSource("String " + strValName + "=null;"); - ctxt.generateJavaSource("if(!(" + strObjectName + - " instanceof Reader) && "+ strObjectName + " != null){"); - ctxt.generateJavaSource( - strValName + " = " + strObjectName + ".toString();"); + ctxt.generateJavaSource("if(!(" + strObjectName + " instanceof Reader) && " + strObjectName + " != null){"); + ctxt.generateJavaSource(strValName + " = " + strObjectName + ".toString();"); ctxt.generateJavaSource("}"); - //initiate the strDefName with null. - //if the default has been specified, then assign the value to it; + // initiate the strDefName with null. + // if the default has been specified, then assign the value to it; ctxt.generateJavaSource("String " + strDefName + " = null;"); - if(hasDefault){ + if (hasDefault) { ctxt.generateJavaSource("if("); ctxt.generateAttribute("default"); ctxt.generateJavaSource(" != null){"); @@ -69,28 +67,26 @@ public final class Out implements TagPlugin { ctxt.generateJavaSource("}"); } - //initiate the strEscapeXmlName with true; - //if the escapeXml is specified, assign the value to it; + // initiate the strEscapeXmlName with true; + // if the escapeXml is specified, assign the value to it; ctxt.generateJavaSource("boolean " + strEscapeXmlName + " = true;"); - if(hasEscapeXml){ + if (hasEscapeXml) { ctxt.generateJavaSource(strEscapeXmlName + " = "); ctxt.generateAttribute("escapeXml"); ctxt.generateJavaSource(";"); } - //main part. + // main part. ctxt.generateJavaSource( - "boolean " + strSkipBodyName + " = " + - "org.apache.jasper.tagplugins.jstl.core.Out.output(out, " + - strObjectName + ", " + strValName + ", " + strDefName + ", " + - strEscapeXmlName + ");"); + "boolean " + strSkipBodyName + " = " + "org.apache.jasper.tagplugins.jstl.core.Out.output(out, " + + strObjectName + ", " + strValName + ", " + strDefName + ", " + strEscapeXmlName + ");"); ctxt.generateJavaSource("if(!" + strSkipBodyName + ") {"); ctxt.generateBody(); ctxt.generateJavaSource("}"); } - public static boolean output(JspWriter out, Object input, String value, - String defaultValue, boolean escapeXml) throws IOException { + 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; @@ -113,7 +109,7 @@ public final class Out implements TagPlugin { } else { String v = value != null ? value : defaultValue; if (v != null) { - if(escapeXml){ + if (escapeXml) { v = Util.escapeXml(v); } out.write(v); diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Param.java b/java/org/apache/jasper/tagplugins/jstl/core/Param.java index 1496c5dbbc..d182cf118c 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Param.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Param.java @@ -24,51 +24,55 @@ public class Param implements TagPlugin { @Override public void doTag(TagPluginContext ctxt) { - //don't support the body content + // don't support the body content - //define names of all the temp variables + // define names of all the temp variables String nameName = ctxt.getTemporaryVariableName(); String valueName = ctxt.getTemporaryVariableName(); String urlName = ctxt.getTemporaryVariableName(); String encName = ctxt.getTemporaryVariableName(); String index = ctxt.getTemporaryVariableName(); - //if the param tag has no parents, throw a exception + // if the param tag has no parents, throw a exception TagPluginContext parent = ctxt.getParentContext(); - if(parent == null){ - ctxt.generateJavaSource(" throw new JspTagException" + - "(\"<param> outside <import> or <urlEncode>\");"); + if (parent == null) { + ctxt.generateJavaSource( + " throw new JspTagException" + "(\"<param> outside <import> or <urlEncode>\");"); return; } - //get the url string before adding this param - ctxt.generateJavaSource("String " + urlName + " = " + - "(String)pageContext.getAttribute(\"url_without_param\");"); + // get the url string before adding this param + ctxt.generateJavaSource( + "String " + urlName + " = " + "(String)pageContext.getAttribute(\"url_without_param\");"); - //get the value of "name" + // get the value of "name" ctxt.generateJavaSource("String " + nameName + " = "); ctxt.generateAttribute("name"); ctxt.generateJavaSource(";"); - //if the "name" is null then do nothing. - //else add such string "name=value" to the url. - //and the url should be encoded + // if the "name" is null then do nothing. + // else add such string "name=value" to the url. + // and the url should be encoded ctxt.generateJavaSource("if(" + nameName + " != null && !" + nameName + ".equals(\"\")){"); ctxt.generateJavaSource(" String " + valueName + " = "); ctxt.generateAttribute("value"); ctxt.generateJavaSource(";"); ctxt.generateJavaSource(" if(" + valueName + " == null) " + valueName + " = \"\";"); ctxt.generateJavaSource(" String " + encName + " = pageContext.getResponse().getCharacterEncoding();"); - ctxt.generateJavaSource(" " + nameName + " = java.net.URLEncoder.encode(" + nameName + ", " + encName + ");"); - ctxt.generateJavaSource(" " + valueName + " = java.net.URLEncoder.encode(" + valueName + ", " + encName + ");"); + ctxt.generateJavaSource( + " " + nameName + " = java.net.URLEncoder.encode(" + nameName + ", " + encName + ");"); + ctxt.generateJavaSource( + " " + valueName + " = java.net.URLEncoder.encode(" + valueName + ", " + encName + ");"); ctxt.generateJavaSource(" int " + index + ";"); ctxt.generateJavaSource(" " + index + " = " + urlName + ".indexOf(\'?\');"); - //if the current param is the first one, add a "?" ahead of it - //else add a "&" ahead of it + // if the current param is the first one, add a "?" ahead of it + // else add a "&" ahead of it ctxt.generateJavaSource(" if(" + index + " == -1){"); - ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"?\" + " + nameName + " + \"=\" + " + valueName + ";"); + ctxt.generateJavaSource( + " " + urlName + " = " + urlName + " + \"?\" + " + nameName + " + \"=\" + " + valueName + ";"); ctxt.generateJavaSource(" }else{"); - ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";"); + ctxt.generateJavaSource( + " " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" pageContext.setAttribute(\"url_without_param\"," + urlName + ");"); ctxt.generateJavaSource("}"); diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java b/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java index cd695ad478..a8c6d455ad 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java @@ -24,54 +24,51 @@ public class Redirect implements TagPlugin { @Override public void doTag(TagPluginContext ctxt) { - //flag for the existence of the "context" + // flag for the existence of the "context" boolean hasContext = ctxt.isAttributeSpecified("context"); - //names of the temp variables + // names of the temp variables String urlName = ctxt.getTemporaryVariableName(); String contextName = ctxt.getTemporaryVariableName(); String baseUrlName = ctxt.getTemporaryVariableName(); String resultName = ctxt.getTemporaryVariableName(); String responseName = ctxt.getTemporaryVariableName(); - //get context + // get context ctxt.generateJavaSource("String " + contextName + " = null;"); - if(hasContext){ + if (hasContext) { ctxt.generateJavaSource(contextName + " = "); ctxt.generateAttribute("context"); ctxt.generateJavaSource(";"); } - //get the url + // get the url ctxt.generateJavaSource("String " + urlName + " = "); ctxt.generateAttribute("url"); ctxt.generateJavaSource(";"); - //get the raw url according to "url" and "context" - ctxt.generateJavaSource("String " + baseUrlName + " = " + - "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" + urlName + ", " + contextName + ", pageContext);"); - ctxt.generateJavaSource("pageContext.setAttribute" + - "(\"url_without_param\", " + baseUrlName + ");"); + // get the raw url according to "url" and "context" + ctxt.generateJavaSource("String " + baseUrlName + " = " + "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" + + urlName + ", " + contextName + ", pageContext);"); + ctxt.generateJavaSource("pageContext.setAttribute" + "(\"url_without_param\", " + baseUrlName + ");"); - //add params + // add params ctxt.generateBody(); - ctxt.generateJavaSource("String " + resultName + " = " + - "(String)pageContext.getAttribute(\"url_without_param\");"); - ctxt.generateJavaSource("pageContext.removeAttribute" + - "(\"url_without_param\");"); + ctxt.generateJavaSource( + "String " + resultName + " = " + "(String)pageContext.getAttribute(\"url_without_param\");"); + ctxt.generateJavaSource("pageContext.removeAttribute" + "(\"url_without_param\");"); - //get the response object - ctxt.generateJavaSource("HttpServletResponse " + responseName + " = " + - "((HttpServletResponse) pageContext.getResponse());"); + // get the response object + ctxt.generateJavaSource( + "HttpServletResponse " + responseName + " = " + "((HttpServletResponse) pageContext.getResponse());"); - //if the url is relative, encode it + // if the url is relative, encode it ctxt.generateJavaSource("if(!org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){"); - ctxt.generateJavaSource(" " + resultName + " = " - + responseName + ".encodeRedirectURL(" + resultName + ");"); + ctxt.generateJavaSource(" " + resultName + " = " + responseName + ".encodeRedirectURL(" + resultName + ");"); ctxt.generateJavaSource("}"); - //do redirect + // do redirect ctxt.generateJavaSource("try{"); ctxt.generateJavaSource(" " + responseName + ".sendRedirect(" + resultName + ");"); ctxt.generateJavaSource("}catch(java.io.IOException ex){"); diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Remove.java b/java/org/apache/jasper/tagplugins/jstl/core/Remove.java index 1978fe091f..3880594618 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Remove.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Remove.java @@ -25,18 +25,18 @@ public class Remove implements TagPlugin { @Override public void doTag(TagPluginContext ctxt) { - //scope flag + // scope flag boolean hasScope = ctxt.isAttributeSpecified("scope"); - //the value of the "var" + // the value of the "var" String strVar = ctxt.getConstantAttribute("var"); - //remove attribute from certain scope. - //default scope is "page". - if(hasScope){ + // remove attribute from certain scope. + // default scope is "page". + if (hasScope) { int iScope = Util.getScope(ctxt.getConstantAttribute("scope")); ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");"); - }else{ + } else { ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");"); } } diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Set.java b/java/org/apache/jasper/tagplugins/jstl/core/Set.java index edd57a129e..1d02507fb4 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Set.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Set.java @@ -25,42 +25,42 @@ public class Set implements TagPlugin { @Override public void doTag(TagPluginContext ctxt) { - //the scope name + // the scope name String strScope; - //the id of the scope + // the id of the scope int iScope; - //the flags to indicate whether the attributes have been specified - //initialize the flags + // the flags to indicate whether the attributes have been specified + // initialize the flags boolean hasValue = ctxt.isAttributeSpecified("value"); boolean hasVar = ctxt.isAttributeSpecified("var"); boolean hasScope = ctxt.isAttributeSpecified("scope"); boolean hasTarget = ctxt.isAttributeSpecified("target"); - //the temp variables name + // the temp variables name String resultName = ctxt.getTemporaryVariableName(); String targetName = ctxt.getTemporaryVariableName(); String propertyName = ctxt.getTemporaryVariableName(); - //initialize the "result" which will be assigned to the var or target.property + // initialize the "result" which will be assigned to the var or target.property ctxt.generateJavaSource("Object " + resultName + " = null;"); - if(hasValue){ + if (hasValue) { ctxt.generateJavaSource(resultName + " = "); ctxt.generateAttribute("value"); ctxt.generateJavaSource(";"); - }else{ + } else { ctxt.dontUseTagPlugin(); return; } - //initialize the strScope - if(hasScope){ + // initialize the strScope + if (hasScope) { strScope = ctxt.getConstantAttribute("scope"); - }else{ + } else { strScope = "page"; } - //get the iScope according to the strScope + // get the iScope according to the strScope iScope = Util.getScope(strScope); String jspCtxt = null; @@ -69,29 +69,30 @@ public class Set implements TagPlugin { } else { jspCtxt = "_jspx_page_context"; } - //if the attribute var has been specified then assign the result to the var; - if(hasVar){ + // if the attribute var has been specified then assign the result to the var; + if (hasVar) { String strVar = ctxt.getConstantAttribute("var"); ctxt.generateJavaSource("if(null != " + resultName + "){"); - ctxt.generateJavaSource(" " + jspCtxt + ".setAttribute(\"" + strVar + "\"," + resultName + "," + iScope + ");"); + ctxt.generateJavaSource( + " " + jspCtxt + ".setAttribute(\"" + strVar + "\"," + resultName + "," + iScope + ");"); ctxt.generateJavaSource("} else {"); - if(hasScope){ + if (hasScope) { ctxt.generateJavaSource(" " + jspCtxt + ".removeAttribute(\"" + strVar + "\"," + iScope + ");"); - }else{ + } else { ctxt.generateJavaSource(" " + jspCtxt + ".removeAttribute(\"" + strVar + "\");"); } ctxt.generateJavaSource("}"); - //else assign the result to the target.property - }else if(hasTarget){ + // else assign the result to the target.property + } else if (hasTarget) { - //generate the temp variable name + // generate the temp variable name String pdName = ctxt.getTemporaryVariableName(); String successFlagName = ctxt.getTemporaryVariableName(); String index = ctxt.getTemporaryVariableName(); String methodName = ctxt.getTemporaryVariableName(); - //initialize the property + // initialize the property ctxt.generateJavaSource("String " + propertyName + " = null;"); ctxt.generateJavaSource("if("); ctxt.generateAttribute("property"); @@ -101,57 +102,69 @@ public class Set implements TagPlugin { ctxt.generateJavaSource(").toString();"); ctxt.generateJavaSource("}"); - //initialize the target + // initialize the target ctxt.generateJavaSource("Object " + targetName + " = "); ctxt.generateAttribute("target"); ctxt.generateJavaSource(";"); - //the target is ok + // the target is ok ctxt.generateJavaSource("if(" + targetName + " != null){"); - //if the target is a map, then put the result into the map with the key property + // if the target is a map, then put the result into the map with the key property ctxt.generateJavaSource(" if(" + targetName + " instanceof java.util.Map){"); ctxt.generateJavaSource(" if(null != " + resultName + "){"); - ctxt.generateJavaSource(" ((java.util.Map) " + targetName + ").put(" + propertyName + "," + resultName + ");"); + ctxt.generateJavaSource( + " ((java.util.Map) " + targetName + ").put(" + propertyName + "," + resultName + ");"); ctxt.generateJavaSource(" }else{"); ctxt.generateJavaSource(" ((java.util.Map) " + targetName + ").remove(" + propertyName + ");"); ctxt.generateJavaSource(" }"); - //else assign the result to the target.property + // else assign the result to the target.property ctxt.generateJavaSource(" }else{"); ctxt.generateJavaSource(" try{"); - //get all the property of the target - ctxt.generateJavaSource(" java.beans.PropertyDescriptor " + pdName + "[] = java.beans.Introspector.getBeanInfo(" + targetName + ".getClass()).getPropertyDescriptors();"); + // get all the property of the target + ctxt.generateJavaSource(" java.beans.PropertyDescriptor " + pdName + + "[] = java.beans.Introspector.getBeanInfo(" + targetName + + ".getClass()).getPropertyDescriptors();"); - //the success flag is to imply whether the assign is successful + // the success flag is to imply whether the assign is successful ctxt.generateJavaSource(" boolean " + successFlagName + " = false;"); - //find the right property - ctxt.generateJavaSource(" for(int " + index + "=0;" + index + "<" + pdName + ".length;" + index + "++){"); - ctxt.generateJavaSource(" if(" + pdName + "[" + index + "].getName().equals(" + propertyName + ")){"); + // find the right property + ctxt.generateJavaSource( + " for(int " + index + "=0;" + index + "<" + pdName + ".length;" + index + "++){"); + ctxt.generateJavaSource( + " if(" + pdName + "[" + index + "].getName().equals(" + propertyName + ")){"); - //get the "set" method; - ctxt.generateJavaSource(" java.lang.reflect.Method " + methodName + " = " + pdName + "[" + index + "].getWriteMethod();"); + // get the "set" method; + ctxt.generateJavaSource(" java.lang.reflect.Method " + methodName + " = " + pdName + + "[" + index + "].getWriteMethod();"); ctxt.generateJavaSource(" if(null == " + methodName + "){"); - ctxt.generateJavaSource(" throw new JspException(\"No setter method in <set> for property \"+" + propertyName + ");"); + ctxt.generateJavaSource( + " throw new JspException(\"No setter method in <set> for property \"+" + + propertyName + ");"); ctxt.generateJavaSource(" }"); - //invoke the method through the reflection + // invoke the method through the reflection ctxt.generateJavaSource(" if(" + resultName + " != null){"); - ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + ", new Object[]{org.apache.el.lang.ELSupport.coerceToType(" + jspCtxt + ".getELContext(), " + resultName + ", " + methodName + ".getParameterTypes()[0])});"); + ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + + ", new Object[]{org.apache.el.lang.ELSupport.coerceToType(" + jspCtxt + ".getELContext(), " + + resultName + ", " + methodName + ".getParameterTypes()[0])});"); ctxt.generateJavaSource(" }else{"); - ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + ", new Object[]{null});"); + ctxt.generateJavaSource( + " " + methodName + ".invoke(" + targetName + ", new Object[]{null});"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" " + successFlagName + " = true;"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" if(!" + successFlagName + "){"); - ctxt.generateJavaSource(" throw new JspException(\"Invalid property in <set>:\"+" + propertyName + ");"); + ctxt.generateJavaSource(" throw new JspException(\"Invalid property in <set>:\"+" + + propertyName + ");"); ctxt.generateJavaSource(" }"); ctxt.generateJavaSource(" }"); - //catch the el exception and throw it as a JspException + // catch the el exception and throw it as a JspException ctxt.generateJavaSource(" catch (IllegalAccessException ex) {"); ctxt.generateJavaSource(" throw new JspException(ex);"); ctxt.generateJavaSource(" } catch (java.beans.IntrospectionException ex) {"); diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Url.java b/java/org/apache/jasper/tagplugins/jstl/core/Url.java index 6df77f6835..a771e969d4 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/Url.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/Url.java @@ -25,70 +25,68 @@ public class Url implements TagPlugin { @Override public void doTag(TagPluginContext ctxt) { - //flags + // flags boolean hasVar, hasContext, hasScope; - //init flags + // init flags hasVar = ctxt.isAttributeSpecified("var"); hasContext = ctxt.isAttributeSpecified("context"); hasScope = ctxt.isAttributeSpecified("scope"); - //define name of the temp variables + // define name of the temp variables String valueName = ctxt.getTemporaryVariableName(); String contextName = ctxt.getTemporaryVariableName(); String baseUrlName = ctxt.getTemporaryVariableName(); String resultName = ctxt.getTemporaryVariableName(); String responseName = ctxt.getTemporaryVariableName(); - //get the scope + // get the scope String strScope = "page"; - if(hasScope){ + if (hasScope) { strScope = ctxt.getConstantAttribute("scope"); } int iScope = Util.getScope(strScope); - //get the value + // get the value ctxt.generateJavaSource("String " + valueName + " = "); ctxt.generateAttribute("value"); ctxt.generateJavaSource(";"); - //get the context + // get the context ctxt.generateJavaSource("String " + contextName + " = null;"); - if(hasContext){ + if (hasContext) { ctxt.generateJavaSource(contextName + " = "); ctxt.generateAttribute("context"); ctxt.generateJavaSource(";"); } - //get the raw url - ctxt.generateJavaSource("String " + baseUrlName + " = " + - "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" + valueName + ", " + contextName + ", pageContext);"); - ctxt.generateJavaSource("pageContext.setAttribute" + - "(\"url_without_param\", " + baseUrlName + ");"); + // get the raw url + ctxt.generateJavaSource("String " + baseUrlName + " = " + "org.apache.jasper.tagplugins.jstl.Util.resolveUrl(" + + valueName + ", " + contextName + ", pageContext);"); + ctxt.generateJavaSource("pageContext.setAttribute" + "(\"url_without_param\", " + baseUrlName + ");"); - //add params + // add params ctxt.generateBody(); - ctxt.generateJavaSource("String " + resultName + " = " + - "(String)pageContext.getAttribute(\"url_without_param\");"); + ctxt.generateJavaSource( + "String " + resultName + " = " + "(String)pageContext.getAttribute(\"url_without_param\");"); ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");"); - //if the url is relative, encode it + // if the url is relative, encode it ctxt.generateJavaSource("if(!org.apache.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){"); ctxt.generateJavaSource(" HttpServletResponse " + responseName + " = " + - "((HttpServletResponse) pageContext.getResponse());"); - ctxt.generateJavaSource(" " + resultName + " = " - + responseName + ".encodeURL(" + resultName + ");"); + "((HttpServletResponse) pageContext.getResponse());"); + ctxt.generateJavaSource(" " + resultName + " = " + responseName + ".encodeURL(" + resultName + ");"); ctxt.generateJavaSource("}"); - //if "var" is specified, the url string store in the attribute var defines - if(hasVar){ + // if "var" is specified, the url string store in the attribute var defines + if (hasVar) { String strVar = ctxt.getConstantAttribute("var"); - ctxt.generateJavaSource("pageContext.setAttribute" + - "(\"" + strVar + "\", " + resultName + ", " + iScope + ");"); + ctxt.generateJavaSource( + "pageContext.setAttribute" + "(\"" + strVar + "\", " + resultName + ", " + iScope + ");"); - //if var is not specified, just print out the url string - }else{ + // if var is not specified, just print out the url string + } else { ctxt.generateJavaSource("try{"); ctxt.generateJavaSource(" pageContext.getOut().print(" + resultName + ");"); ctxt.generateJavaSource("}catch(java.io.IOException ex){"); diff --git a/java/org/apache/jasper/tagplugins/jstl/core/When.java b/java/org/apache/jasper/tagplugins/jstl/core/When.java index 8a1141319c..b6568003e7 100644 --- a/java/org/apache/jasper/tagplugins/jstl/core/When.java +++ b/java/org/apache/jasper/tagplugins/jstl/core/When.java @@ -42,7 +42,7 @@ public final class When implements TagPlugin { ctxt.generateBody(); // We don't generate the closing "}" for the "if" here because there - // may be whitespaces in between <c:when>'s. Instead we delay + // may be whitespaces in between <c:when>'s. Instead we delay // generating it until the next <c:when> or <c:otherwise> or // <c:choose> } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org