I have JSTL Java code that reads request header Accept language paremeter
<c:set var="locale" value="<%= request.getHeader("Accept-Language") %>"/>
The variable locale's value varies based on the order of browser's language setting.
Sometimes it is like this
Some other times it is like this
On either case I want to read the first occurrence of locale such as en-XX. In this case, en-GB.
I was using split function but I couldn't figure out the correct way to use it for this task.
I did this and it'd work only if en-XX was the first one in the string
<c:set var="locale" value="<%= request.getHeader("Accept-Language").split(",") %>"/>
Any help in terms of incorporating regex with split function (or anyother function) is much appreciated.