Summary: | fmt:formatDate adds multiple content-language headers | ||
---|---|---|---|
Product: | Taglibs | Reporter: | Antti Suanto <antti.suanto> |
Component: | Standard Taglib | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED INVALID | ||
Severity: | major | ||
Priority: | P3 | ||
Version: | 1.0 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All |
Description
Antti Suanto
2004-04-07 07:39:10 UTC
You filed this bug against the i18n taglib, but that taglib does not have 1.0.3 and 1.0.5 versions. Did you mean the Standard taglib (i.e. JSTL)? *** Bug 28258 has been marked as a duplicate of this bug. *** Yes, sorry I selected wrong component. I meant standard taglib. I tested the tag with tomcat and no problems. So the problem seems to be in OC4J (10g). CC'ing the taglibs-dev address to all Standard bugs. I tried to reproduce the problem with JSTL 1.0.5 and Tomcat 4.1.30 but was unsuccessful. If it is a problem with the OC4J container, please bring this to Oracle's attention so they can fix the bug in their container. I'm facing the same problem on OC4J 10G (9.0.4.0.1). What happens is that response.setLocale(locale); is called as many times as formatDate (or formatNumber) is in the JSP, thus it provokes a header overflow (I analysed the traffic with Ethereal and you see as much a 20 Content-Language headers in the response). It works on Tomcat 4.1.30, but it is not a prove that it works because may be Tomcat ignores all the response.setLocale but the first what Oracle does not do. In the spec it it said that : "Sets the locale of the response, setting the headers (including the Content- Type's charset) as appropriate. This method should be called before a call to getWriter(). By default, the response locale is the default locale for the server." Nothing more. I checked Tomcat code of setHeader and it overwrites the header if it already exists but the call to setHeader("Content-Language", <value>) occurs 20 times: public void setHeader(String name, String value) { if (isCommitted()) return; if (included) return; // Ignore any call from an included servlet // This code overwrites ArrayList values = new ArrayList(); values.add(value); synchronized (headers) { headers.put(name, values); } // End of the code overwrites String match = name.toLowerCase(); if (match.equals("content-length")) { int contentLength = -1; try { contentLength = Integer.parseInt(value); } catch (NumberFormatException e) { ; } if (contentLength >= 0) setContentLength(contentLength); } else if (match.equals("content-type")) { setContentType(value); } } To be fully precise about the problem, I decompiled the OC4J implementation and the method setLocale() calls addHeader("Content-Language", language); not setHeader which explains the problem : public void setLocale(java.util.Locale locale) { /*1805*/ if(locale == null || isIncluded) /*1805*/ return; /*1807*/ if(isCommitted() && locale != this.locale) /*1808*/ throw new IllegalStateException("Response is already committed!"); /*1811*/ this.locale = locale; /*1814*/ java.lang.String _charset = (java.lang.String)LOCALE_MAP.get (locale.toString()); /*1815*/ if(_charset == null) /*1816*/ _charset = (java.lang.String)LOCALE_MAP.get (locale.getLanguage()); /*1819*/ if(outputFetchStatus == 2 && charset != null && ! _charset.equalsIgnoreCase(charset)) /*1823*/ throw new IllegalStateException("Output writer already acquired"); /*1827*/ if(contentType != null && (charset == null || ! charset.equalsIgnoreCase(_charset))) { /*1831*/ contentType = com.evermind.server.http.EvermindHttpServletResponse.constructContentType (contentType, _charset); /*1832*/ contentTypeHeader = null; } /*1836*/ charset = _charset; /*1837*/ isCharsetSet = true; /*1840*/ java.lang.String language = locale.getLanguage(); /*1841*/ if(language != null && language.length() > 0) { /*1843*/ java.lang.String country = locale.getCountry(); /*1844*/ if(country != null && country.length() > 0) /*1845*/ addHeader("Content-Language", language + "-" + country); /*1847*/ else /*1847*/ addHeader("Content-Language", language); } } This is an OC4J issue. |