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 4072206
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:51:20+00:00 2026-05-20T16:51:20+00:00

I have a buzz to solve and need some help. Suppose I have a

  • 0

I have a buzz to solve and need some help. Suppose I have a URL from my domain, something like: http://mydomain.com/any_page.xhtml for example. I’d like to intercept the user request when clicking the link, that theoretically directs to my domain and need it to intercept and redirect it to determined new URL based in my criterion.
I’m working with simple Servlets. During my investigation I’ve seen that Filter may help me.
Does anybody know how to create something for this proposal?

  • 1 1 Answer
  • 1 View
  • 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-20T16:51:21+00:00Added an answer on May 20, 2026 at 4:51 pm

    Just implement javax.servlet.Filter.

    If you map this on an URL pattern of /* it will be executed on every request.

    <url-pattern>/*</url-pattern>
    

    or when you’re already on Servlet 3.0

    @WebFilter(urlPatterns = { "/*" })
    

    You can obtain the request URI by HttpServletRequest#getRequestURI() in filter’s doFilter() method as follows:

    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String uri = httpRequest.getRequestURI();
    // ...
    

    You can use any of the methods provided by java.lang.String class to compare/manipulate it.

    boolean matches = uri.startsWith("/something");
    

    You can use if/else keywords provided by the Java language to control the flow in code.

    if (matches) {
        // It matches.
    } else {
        // It doesn't match.
    }
    

    You can use HttpServletResponse#sendRedirect() to send a redirect.

    HttpServletResponse httpResponse = (HttpServletResponse) response;
    httpResponse.sendRedirect(newURL);
    

    You can use FilterChain#doFilter() to just let the request continue.

    chain.doFilter(request, response);
    

    Do the math. You can of course also use a 3rd party one, like Tuckey’s URL rewrite filter which is, say, the Java variant of Apache HTTPD’s mod_rewrite.

    See also:

    • Servlet filters info page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There seems to have a buzz around the Lightswitch application framework. Reading some posts/forums/articles
I have a function called test in namespace buzz . From this test function
I have written an F# program to solve the Escape from Zurg puzzle My
I have just scraped a bunch of Google Buzz data, and I want to
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have an application where i want to integrate multiple buzz accounts to the
I have an enum in a namespace and I'd like to use it as
Despite all of the buzz around html5 forms, it seems to me like you
I am trying to post some content to my google buzz account using google

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.