Results 1 to 8 of 8

Thread: SessionLocaleResolver not working on redirect

  1. #1

    Default SessionLocaleResolver not working on redirect

    I have a SessionLocaleResolver which is set up in one controller, then redirects to a jsp (I use a redirect to update the URL just this once). However the jsp does not reflect the correct locale. I then click on one of the links in the jsp and travel to another controller, which does its business then forwards to another jsp. The locale in this second jsp is correct. Why would the locale not work when a jsp is accessed through a redirect, but work when forwarded to?

    Thanks

    p.s. If you need to see code, please let me know

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    You shouldn't redirect to a jsp directly but pass through the DispatcherServlet else it isn't going to work.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote Originally Posted by Marten Deinum View Post
    You shouldn't redirect to a jsp directly but pass through the DispatcherServlet else it isn't going to work.
    Hi Marten,

    Can you clarify? I use the standard way of dispatching to views using the
    Code:
    return new ModelAndView("...");
    however I prepend "redirect:" to the view path. Is this way not going to pass through the DispatcherServlet? If not, how can I get around this. I need to use redirects occasionally.

    Thanks
    Last edited by Some_One; Sep 11th, 2008 at 08:32 AM.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    It depends. If you redirect to a url which passes through the DispatcherServlet then it works. If you redirect to a jsp directly then it doesn't.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default

    By "redirect to a jsp directly" do you mean using Response.sendRedirect("...")?

    I am returning a ModelAndView object from my controller, so this should be going through the DispatcherServlet, no? Why wouldn't it work then?

    Thanks

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Code:
    redirect:whjateveroinhere.jsp
    direct redirection to a jsp...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  7. #7

    Default

    So then, to the second part of my question. If I occasionally need use direct redirection in my webapp, SessionLocaleResolver is useless, correct?

  8. #8
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    No... Read.

    If you redirect to a JSP DIRECTLY it is useless. If you redirect to a url with passes through the DispatcherServlet (i.e. maps to a Controller) then it works. In fact you shouldn't have any jsp available directly, everything should be accessed through the DispatcherServlet.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •