title: Can I intercept and change the request url of a HTTPServletRequest within a Java Servlet filter?
body: <p>I have a Java web application which manages data for many clubs. I would like the application to show club information depending on the URL that is typed in.</p>
  
  <p>Eg. If you enter "localhost:8080/MyApp/Club1"
  ...then the app should strip out the end of the requst url (Club1), do a lookup in the database for the club, and add this to the session. Then all database requests can look up data depending on which club is in the session.</p>
  
  <p>If you enter "localhost:8080/MyApp/Club2", you get club to registered in the session, and all database requests are for club 2.</p>
  
  <p>The way I thought I may do this is to use a servlet filter that calls HTTPServletRequest().getRequestURL(), and strips out the club name from the request url, to lookup the club from the database.</p>
  
  <p>But then I wan't to change the request URL to be <a href="http://localhost:8080/MyApp" rel="nofollow noreferrer">http://localhost:8080/MyApp</a> so that the application works as normal. However, I don't think I am able to do this?</p>
  
  <p>Anyone any ideas of how to do this, or if there is a better approach?</p>