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

  • SEARCH
  • Home
  • 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 6691947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:48:39+00:00 2026-05-26T05:48:39+00:00

I am building a Spring MVC based application where I want to redirect user’s

  • 0

I am building a Spring MVC based application where I want to redirect user’s to specific portion of the site based on their browser.

I am using a Filter applied to /site/home.jsp to read the User-Agent to determine the browser type.

HttpServletRequest req = (HttpServletRequest) request;
String uaString = req.getHeader("User-Agent");

Further I want to redirect users as below:

  • Firefox: redirect to /site/firefox/home.jsp
  • IE: redirect to /site/ie/home.jsp
  • Unknown: redirect to /site/UnsupportedBrowser.jsp

My confusion is what is the correct way to redirect the user from my BrowserDetector filter?

1) Simply redirect the user?

resp.sendRedirect("/AppName/site/ie/home.jsp");

2) Use an HTTP Temp redirect?

resp.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
resp.setHeader("Location", "/AppName/site/ie/home.jsp");

3) Server side redirect?

RequestDispatcher request_Dispatcher=request.getRequestDispatcher("/ie/home.jsp");
request_Dispatcher.forward(request,response);

4) Any other correct way?

  • 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-26T05:48:39+00:00Added an answer on May 26, 2026 at 5:48 am

    Idea number 3 is probably a bad idea, as it will most likely result in you having to perform this check for every request, which is inefficient (only slightly, but small inefficiencies can mount up).

    Idea’s number 1 & 2 are also not the best approach, because both will result in a Temporary redirect (307) response, wheras what you probably want is a permanent redirect (301). This is because the browser in question will always be the same – FF and IE never share there list of permanent moves, so even if both browsers are used by the same client machine this will not cause a problem. You should use 301 for reasons of, again, efficiency – if the browser always goes directly to the correct place, it is less work for your server to do.

    To sum up, I think idea 2 is the closest, but you should use this instead:

    resp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
    resp.setHeader("Location", "/AppName/site/ie/home.jsp");
    

    Keep in mind that User-Agent strings can be spoofed and cannot be 100% relied upon.

    This is my personal opinion, YMMV…

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

Sidebar

Related Questions

I am building web application using Spring MVC Spring Security Hibenate MySQl I want
I'm building a MVC web application (using the Spring MVC framework), and I'm a
I am building a web application with RESTful web services using Spring MVC 3.
I am using Spring MVC for an application I am building. Everything is working
I'm currently building a Spring MVC application. I was looking to use JSP pages
I'm building a Spring MVC web application with Tiles/JSP as the view technology. Previously
I'm building a web application using Stripes and Spring. It needs to have a
I am currently building an application using Tomcat, Spring and JAVA. I am using
I'm building an ASP.NET MVC site where I want to decorate my ViewModels with
Hello I'm building a Spring MVC web application that runs on Tomcat 6.0.20 and

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.