StringIndexOutOfBoundsException when Parsing Accept-Language Request Header

(Doc ID 342009.1)

Last updated on NOVEMBER 05, 2016

Applies to:

Oracle Containers for J2EE - Version and later
Information in this document applies to any platform.
Openwave Browser V7
***Checked for relevance on 05-May-2011***


When OC4J's request.getLocale() method receives an Accept-Language header with "; q=1.0" in it (the space is the critical part), the request fails with

  java.lang.StringIndexOutOfBoundsException: String index out of range: -2


   at com.evermind[Oracle Application Server Containers for J2EE 10g


The testcase is well reproducable:

Put the following JSP into an OC4J instance:

Locale: <%= request.getLocale() %>

and access it via Telnet as:

telnet 7781  

GET /j2ee/getlocale.jsp HTTP/1.0
Accept-Language: en-GB; q=1.0


Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms