lukastymo
lukastymo

Reputation: 26809

Servlet Filter modify path to files

Could you help me with implementation Filter which will modify all request to files /DIR/* into /NEW_DOMAIN/NEW_CONTEXT_PATH/DIR/*

Upvotes: 0

Views: 151

Answers (2)

Bozho
Bozho

Reputation: 597046

  1. Map the filter to /DIR/*
  2. Use

    response.sendRedirect(NEW_DOMAIN + "/" + NEW_CONTEXT + request.getPathInfo())
    

    (see getPathInfo()). Note that if it's possible to have a query-string (?foo=bar), you'd have to append it as well.

Upvotes: 2

erloewe
erloewe

Reputation: 1349

Probably could but are you sure that is what you want? You could also use mod_rewrite with your reverse proxy (example for Apache and mod_rewrite):

RewriteEngine on
RewriteRule   ^/DIR/(.*)$  /NEW_DOMAIN/NEW_CONTEXT_PATH/DIR/$1  [R]

Upvotes: 0

Related Questions