View | Details | Raw Unified | Return to bug 45931
Collapse All | Expand All

(-)java/org/apache/jasper/JspC.java (-4 / +14 lines)
Lines 139-145 Link Here
139
    protected static int die;
139
    protected static int die;
140
    protected String classPath = null;
140
    protected String classPath = null;
141
    protected URLClassLoader loader = null;
141
    protected URLClassLoader loader = null;
142
    protected boolean trimSpaces = false;
142
    protected TrimSpacesOption trimSpaces = TrimSpacesOption.FALSE;
143
    protected boolean genStringAsCharArray = false;
143
    protected boolean genStringAsCharArray = false;
144
    protected boolean xpoweredBy;
144
    protected boolean xpoweredBy;
145
    protected boolean mappedFile = false;
145
    protected boolean mappedFile = false;
Lines 297-303 Link Here
297
            } else if (tok.equals(SWITCH_XPOWERED_BY)) {
297
            } else if (tok.equals(SWITCH_XPOWERED_BY)) {
298
                xpoweredBy = true;
298
                xpoweredBy = true;
299
            } else if (tok.equals(SWITCH_TRIM_SPACES)) {
299
            } else if (tok.equals(SWITCH_TRIM_SPACES)) {
300
                setTrimSpaces(true);
300
                tok = nextArg();
301
                if (TrimSpacesOption.SINGLE.toString().equalsIgnoreCase(tok)) {
302
                    setTrimSpaces(TrimSpacesOption.SINGLE);
303
                } else {
304
                    setTrimSpaces(TrimSpacesOption.TRUE);
305
                    argPos--;
306
                }
301
            } else if (tok.equals(SWITCH_CACHE)) {
307
            } else if (tok.equals(SWITCH_CACHE)) {
302
                tok = nextArg();
308
                tok = nextArg();
303
                if ("false".equals(tok)) {
309
                if ("false".equals(tok)) {
Lines 362-375 Link Here
362
        return true;
368
        return true;
363
    }
369
    }
364
370
365
    public boolean getTrimSpaces() {
371
    public TrimSpacesOption getTrimSpaces() {
366
        return trimSpaces;
372
        return trimSpaces;
367
    }
373
    }
368
374
369
    public void setTrimSpaces(boolean ts) {
375
    public void setTrimSpaces(TrimSpacesOption ts) {
370
        this.trimSpaces = ts;
376
        this.trimSpaces = ts;
371
    }
377
    }
372
378
379
    public void setTrimSpaces(String ts) {
380
        this.trimSpaces = TrimSpacesOption.fromString(ts);
381
    }
382
373
    public boolean isPoolingEnabled() {
383
    public boolean isPoolingEnabled() {
374
        return poolingEnabled;
384
        return poolingEnabled;
375
    }
385
    }
(-)java/org/apache/jasper/EmbeddedServletOptions.java (-9 / +8 lines)
Lines 61-69 Link Here
61
    private boolean keepGenerated = true;
61
    private boolean keepGenerated = true;
62
    
62
    
63
    /**
63
    /**
64
     * Should white spaces between directives or actions be trimmed?
64
     * Should white spaces between directives or actions be trimmed and if so,
65
     * to nothing (per Section JSP.3.3.8) or to a single space?
65
     */
66
     */
66
    private boolean trimSpaces = false;
67
    private TrimSpacesOption trimSpaces = TrimSpacesOption.FALSE;
67
    
68
    
68
    /**
69
    /**
69
     * Determines whether tag handler pooling is enabled.
70
     * Determines whether tag handler pooling is enabled.
Lines 198-206 Link Here
198
    }
199
    }
199
    
200
    
200
    /**
201
    /**
201
     * Should white spaces between directives or actions be trimmed?
202
     * Should white spaces between directives or actions be trimmed and if so,
203
     * to nothing (per Section JSP.3.3.8) or to a single space?
202
     */
204
     */
203
    public boolean getTrimSpaces() {
205
    public TrimSpacesOption getTrimSpaces() {
204
        return trimSpaces;
206
        return trimSpaces;
205
    }
207
    }
206
    
208
    
Lines 423-433 Link Here
423
        
425
        
424
        String trimsp = config.getInitParameter("trimSpaces"); 
426
        String trimsp = config.getInitParameter("trimSpaces"); 
425
        if (trimsp != null) {
427
        if (trimsp != null) {
426
            if (trimsp.equalsIgnoreCase("true")) {
428
            trimSpaces = TrimSpacesOption.fromString(trimsp);
427
                trimSpaces = true;
429
            if (!trimSpaces.toString().equalsIgnoreCase(trimsp)) {
428
            } else if (trimsp.equalsIgnoreCase("false")) {
429
                trimSpaces = false;
430
            } else {
431
                if (log.isWarnEnabled()) {
430
                if (log.isWarnEnabled()) {
432
                    log.warn(Localizer.getMessage("jsp.warning.trimspaces"));
431
                    log.warn(Localizer.getMessage("jsp.warning.trimspaces"));
433
                }
432
                }
(-)java/org/apache/jasper/compiler/TextOptimizer.java (-2 / +7 lines)
Lines 34-39 Link Here
34
        private Node.TemplateText firstTextNode = null;
34
        private Node.TemplateText firstTextNode = null;
35
        private StringBuffer textBuffer;
35
        private StringBuffer textBuffer;
36
        private final String emptyText = new String("");
36
        private final String emptyText = new String("");
37
        private final String singleText = new String(" ");
37
38
38
        public TextCatVisitor(Compiler compiler) {
39
        public TextCatVisitor(Compiler compiler) {
39
            options = compiler.getCompilationContext().getOptions();
40
            options = compiler.getCompilationContext().getOptions();
Lines 72-80 Link Here
72
        }
73
        }
73
74
74
        public void visit(Node.TemplateText n) throws JasperException {
75
        public void visit(Node.TemplateText n) throws JasperException {
75
            if ((options.getTrimSpaces() || pageInfo.isTrimDirectiveWhitespaces()) 
76
            if ((!Options.TrimSpacesOption.FALSE.equals(options.getTrimSpaces())
77
                        || pageInfo.isTrimDirectiveWhitespaces()) 
76
                    && n.isAllSpace()) {
78
                    && n.isAllSpace()) {
77
                n.setText(emptyText);
79
                switch (options.getTrimSpaces()) {
80
                    case SINGLE: n.setText(singleText); break;
81
                    default: n.setText(emptyText);
82
                }
78
                return;
83
                return;
79
            }
84
            }
80
85
(-)java/org/apache/jasper/resources/LocalStrings.properties (-22 / +23 lines)
Lines 236-263 Link Here
236
or any number of\n\
236
or any number of\n\
237
\    <file>             A file to be parsed as a JSP page\n\
237
\    <file>             A file to be parsed as a JSP page\n\
238
where options include:\n\
238
where options include:\n\
239
\    -help              Print this help message\n\
239
\    -help                Print this help message\n\
240
\    -v                 Verbose mode\n\
240
\    -v                   Verbose mode\n\
241
\    -d <dir>           Output Directory (default -Djava.io.tmpdir)\n\
241
\    -d <dir>             Output Directory (default -Djava.io.tmpdir)\n\
242
\    -l                 Outputs the name of the JSP page upon failure\n\
242
\    -l                   Outputs the name of the JSP page upon failure\n\
243
\    -s                 Outputs the name of the JSP page upon success\n\
243
\    -s                   Outputs the name of the JSP page upon success\n\
244
\    -p <name>          Name of target package (default org.apache.jsp)\n\
244
\    -p <name>            Name of target package (default org.apache.jsp)\n\
245
\    -c <name>          Name of target class name (only applies to first JSP page)\n\
245
\    -c <name>            Name of target class name (only applies to first JSP page)\n\
246
\    -mapped            Generates separate write() calls for each HTML line in the JSP\n\
246
\    -mapped              Generates separate write() calls for each HTML line in the JSP\n\
247
\    -die[#]            Generates an error return code (#) on fatal errors (default 1)\n\
247
\    -die[#]              Generates an error return code (#) on fatal errors (default 1)\n\
248
\    -uribase <dir>     The uri directory compilations should be relative to\n\
248
\    -uribase <dir>       The uri directory compilations should be relative to\n\
249
\                       (default "/")\n\
249
\                         (default "/")\n\
250
\    -uriroot <dir>     Same as -webapp\n\
250
\    -uriroot <dir>       Same as -webapp\n\
251
\    -compile           Compiles generated servlets\n\
251
\    -compile             Compiles generated servlets\n\
252
\    -webinc <file>     Creates a partial servlet mappings in the file\n\
252
\    -webinc <file>       Creates a partial servlet mappings in the file\n\
253
\    -webxml <file>     Creates a complete web.xml in the file\n\
253
\    -webxml <file>       Creates a complete web.xml in the file\n\
254
\    -ieplugin <clsid>  Java Plugin classid for Internet Explorer\n\
254
\    -ieplugin <clsid>    Java Plugin classid for Internet Explorer\n\
255
\    -classpath <path>  Overrides java.class.path system property\n\
255
\    -classpath <path>    Overrides java.class.path system property\n\
256
\    -xpoweredBy        Add X-Powered-By response header\n\
256
\    -xpoweredBy          Add X-Powered-By response header\n\
257
\    -trimSpaces        Trim spaces in template text between actions, directives\n\
257
\    -trimSpaces [single] Trim spaces in template text between actions, directives\n\
258
\    -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\
258
\                         (if "single", whitespace trimmed to single space)\n\
259
\    -source <version>   Set the -source argument to the compiler (default 1.4)\n\
259
\    -javaEncoding <enc>  Set the encoding charset for Java classes (default UTF-8)\n\
260
\    -target <version>   Set the -target argument to the compiler (default 1.4)\n\
260
\    -source <version>    Set the -source argument to the compiler (default 1.4)\n\
261
\    -target <version>    Set the -target argument to the compiler (default 1.4)\n\
261
262
262
jspc.webxml.header=<?xml version="1.0" encoding="ISO-8859-1"?>\n\
263
jspc.webxml.header=<?xml version="1.0" encoding="ISO-8859-1"?>\n\
263
\n\
264
\n\
(-)java/org/apache/jasper/resources/LocalStrings_es.properties (-1 / +2 lines)
Lines 254-260 Link Here
254
	\    -ieplugin <clsid>  Java Plugin classid para Internet Explorer\n\
254
	\    -ieplugin <clsid>  Java Plugin classid para Internet Explorer\n\
255
	\    -classpath <path>  Pasa por alto la propiedad de sistema java.class.path\n\
255
	\    -classpath <path>  Pasa por alto la propiedad de sistema java.class.path\n\
256
	\    -xpoweredBy        A\u00F1ade cabecera de respuesta  X-Powered-By\n\
256
	\    -xpoweredBy        A\u00F1ade cabecera de respuesta  X-Powered-By\n\
257
	\    -trimSpaces        Trim spaces in template text between actions, directives\n\
257
	\    -trimSpaces [single] Trim spaces in template text between actions, directives\n\
258
	\                         (if "single", whitespace trimmed to single space)\n\
258
	\    -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\
259
	\    -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\
259
	\    -source <version>   Set the -source argument to the compiler (default 1.4)\n\
260
	\    -source <version>   Set the -source argument to the compiler (default 1.4)\n\
260
	\    -target <version>   Set the -target argument to the compiler (default 1.4)\n
261
	\    -target <version>   Set the -target argument to the compiler (default 1.4)\n
(-)java/org/apache/jasper/resources/LocalStrings_fr.properties (-1 / +2 lines)
Lines 196-202 Link Here
196
\    -webxml <file>  Création d''un fichier web.xml complet pour l''option -webapp.\n\
196
\    -webxml <file>  Création d''un fichier web.xml complet pour l''option -webapp.\n\
197
\    -ieplugin <clsid>  Le classid du Plugin Java Plugin pour Internet Explorer\n\
197
\    -ieplugin <clsid>  Le classid du Plugin Java Plugin pour Internet Explorer\n\
198
\    -sax2 <driverclassname>  Le nom de classe du Driver SAX 2.0 à utiliser\n\
198
\    -sax2 <driverclassname>  Le nom de classe du Driver SAX 2.0 à utiliser\n\
199
\    -trimSpaces        Trim spaces in template text between actions, directives\n\
199
\    -trimSpaces [single] Trim spaces in template text between actions, directives\n\
200
\                         (if "single", whitespace trimmed to single space)\n\
200
\    -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\
201
\    -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\
201
\    -source <version>   Set the -source argument to the compiler (default 1.4)\n\
202
\    -source <version>   Set the -source argument to the compiler (default 1.4)\n\
202
\    -target <version>   Set the -target argument to the compiler (default 1.4)\n\
203
\    -target <version>   Set the -target argument to the compiler (default 1.4)\n\
(-)java/org/apache/jasper/resources/LocalStrings_ja.properties (-2 / +3 lines)
Lines 238-245 Link Here
238
\    -ieplugin <clsid>  Internet Explorer\u306eJava Plugin\u306eclassid\n\
238
\    -ieplugin <clsid>  Internet Explorer\u306eJava Plugin\u306eclassid\n\
239
\    -classpath <path>  java.class.path\u30b7\u30b9\u30c6\u30e0\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u4e0a\u66f8\u304d\n\
239
\    -classpath <path>  java.class.path\u30b7\u30b9\u30c6\u30e0\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u4e0a\u66f8\u304d\n\
240
\    -xpoweredBy        X-Powered-By\u30ec\u30b9\u30dd\u30f3\u30b9\u30d8\u30c3\u30c0\u306e\u8ffd\u52a0\n\
240
\    -xpoweredBy        X-Powered-By\u30ec\u30b9\u30dd\u30f3\u30b9\u30d8\u30c3\u30c0\u306e\u8ffd\u52a0\n\
241
\    -trimSpaces        \u30a2\u30af\u30b7\u30e7\u30f3\u3084\u6307\u793a\u5b50\u306e\u9593\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c6\u30ad\u30b9\u30c8\u4e2d\u306e\u30b9\u30da\u30fc\u30b9\u3092\u524a\u9664\n\
241
\    -trimSpaces [single] \u30a2\u30af\u30b7\u30e7\u30f3\u3084\u6307\u793a\u5b50\u306e\u9593\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c6\u30ad\u30b9\u30c8\u4e2d\u306e\u30b9\u30da\u30fc\u30b9\u3092\u524a\u9664\n\
242
\    -trimSpaces        Trim spaces in template text between actions, directives\n\
242
\    -trimSpaces [single] Trim spaces in template text between actions, directives\n\
243
\                         (if "single", whitespace trimmed to single space)\n\
243
\    -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\
244
\    -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)\n\
244
\    -source <version>   Set the -source argument to the compiler (default 1.4)\n\
245
\    -source <version>   Set the -source argument to the compiler (default 1.4)\n\
245
\    -target <version>   Set the -target argument to the compiler (default 1.4)\n\
246
\    -target <version>   Set the -target argument to the compiler (default 1.4)\n\
(-)java/org/apache/jasper/Options.java (-2 / +44 lines)
Lines 96-106 Link Here
96
    public boolean isSmapDumped();
96
    public boolean isSmapDumped();
97
97
98
    /**
98
    /**
99
     * Should white spaces between directives or actions be trimmed?
99
     * Possible values for trimSpaces
100
     */
100
     */
101
    public boolean getTrimSpaces();
101
    public enum TrimSpacesOption {
102
        FALSE ("false"),
103
        TRUE ("true"),
104
        SINGLE ("single");
102
105
106
        private String value;
107
108
        TrimSpacesOption(String value) {
109
            this.value = value;
110
        }
111
112
        /**
113
         * Get the enum value from the option string
114
         */
115
        public static TrimSpacesOption fromString(String value) {
116
            if (value == null) {
117
                return FALSE;
118
            }
119
120
            value = value.toLowerCase().trim();
121
            
122
            if ("true".equals(value)) {
123
                return TRUE;
124
            } else if ("single".equals(value)) {
125
                return SINGLE;
126
            } else {
127
                return FALSE;
128
            }
129
        }
130
131
        /**
132
         * Return the option string value
133
         */
134
        public String toString() {
135
            return this.value;
136
        }
137
    }    
138
103
    /**
139
    /**
140
     * Should white spaces between directives or actions be trimmed and if so,
141
     * to nothing (per Section JSP.3.3.8) or to a single space?
142
     */
143
    public TrimSpacesOption getTrimSpaces();
144
145
    /**
104
     * Class ID for use in the plugin tag when the browser is IE. 
146
     * Class ID for use in the plugin tag when the browser is IE. 
105
     */
147
     */
106
    public String getIeClassId();
148
    public String getIeClassId();

Return to bug 45931