How to pass an empty contentCharset to streamResult
"Ing. Andrea Vettori" <[email protected]> Tue, 30 Dec 2025 12:55:53 +0100
| Newsgroups | gmane.comp.jakarta.struts.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I’m facing an issue and I think it’s a “bug” on StreamResult (not sure about it however).
I know I can pass or do not pass a parameter contentCharSet on the result in struts.xml. If I do not pass it, for some reason I find UTF-8 is added automatically.
However if I do pass a value that is an expression I would expect that if the expression evaluates to null, the charset would not be added to the headers.
What happens instead is that a
;charSet=
string is added to the content type.
The “bug” is likely related to this code in StreamResult.java
if (contentCharSet != null && !contentCharSet.isEmpty()) {
oResponse.setContentType(conditionalParse(contentType, invocation) + ";charset=" + conditionalParse(contentCharSet, invocation));
} else {
oResponse.setContentType(conditionalParse(contentType, invocation));
}
So my questions are :
1. why I find UTF-8 if I don’t specify the parameter;
2. shouldn’t the if check the emptiness of the evaluated expression in the code above ?
Thanks
—
Ing. Andrea Vettori
Sistemi Informativi
B2BIres s.r.l.