Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6110507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:31:26+00:00 2026-05-23T14:31:26+00:00

If I set the HTTP response locale programmatically in a servlet as follows: @Override

  • 0

If I set the HTTP response locale programmatically in a servlet as follows:

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
{
    response.setLocale(SOME_LOCALE);
    // .. etc
}

Then under Jetty 7 and later, any JSPs trying to read that locale via the expression ${pageContext.response.locale} will get the server’s default locale instead of the one set above. If I use Jetty 6 or Tomcat, it works fine.

Here’s the full code to demonstrate the problem:

public class MyServlet extends HttpServlet {

    // Use a dummy locale that's unlikely to be the user's default
    private static final Locale TEST_LOCALE = new Locale("abcdefg");

    @Override
    protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
        throws IOException, ServletException
    {
        // Set a known response locale
        response.setLocale(TEST_LOCALE);

        // Publish some interesting locales to the JSP as request attributes for debugging
        request.setAttribute("defaultLocale", Locale.getDefault());
        request.setAttribute("testLocale", TEST_LOCALE);

        // Forward the request to our JSP
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
}

And the JSP:

<html>
    <head>
        <title>Locale Tester</title>
    </head>
    <body>
        <h2>Locale Tester</h2>
        <ul>
            <li>pageContext.request.locale = '${pageContext.request.locale}'</li>
            <li>default locale = '<%= request.getAttribute("defaultLocale") %>'</li>
            <li>pageContext.response.locale = '${pageContext.response.locale}' (should be '<%= request.getAttribute("testLocale") %>')</li>
        </ul>
    </body>
</html>

Tomcat returns this (correctly):

Locale Tester

    pageContext.request.locale = 'en_AU'
    default locale = 'en_US'
    pageContext.response.locale = 'abcdefg' (should be 'abcdefg')

Jetty 7 returns this (wrongly):

Locale Tester

    pageContext.request.locale = 'en_AU'
    default locale = 'en_US'
    pageContext.response.locale = 'en_US' (should be 'abcdefg')

FWIW, I did all the above testing using the Jetty/Tomcat Maven plugins.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:31:26+00:00Added an answer on May 23, 2026 at 2:31 pm

    I found out via the Jetty mailing list that this is a bug in Jetty 7, which has now been fixed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to send a CSV file in HTTP response. How can I set
Is this defined? Or is it set with a header, similar to the HTTP-response?
In my application I need to set a http response header. I'd like to
Some web servers return content-length set to zero in the HTTP response headers. I'd
I need to set http header for disabling ie (7-8) caching (it disturbs my
What is the minimum set of HTTP verbs that a server should allow for
Is there any way to set the HTTP header fields of a HTML form
I've got a basic HTTP client set up in C++, which works ok so
I just set up my new homepage at http://ritter.vg . I'm using jQuery, but
Is it possible to set a cookie for http://www.example.com from a PHP file located

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.