Now here is ExternalRedirectView as planned in my comment above... did it that way.
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.view.RedirectView;
/** variant of RedirectView, will not add a session id to the url
*/
public class ExternalRedirectView extends RedirectView {
public ExternalRedirectView(String url, boolean contextRelative) {
super(url, contextRelative);
}
/** copied from @link{RedirectView#sendRedirect} and removed calls to
* reponse.encodeRedirectURL()
*/
@Override
protected void sendRedirect( HttpServletRequest request,
HttpServletResponse response, String targetUrl,
boolean http10Compatible ) throws IOException {
if (http10Compatible) {
// Always send status code 302.
response.sendRedirect(targetUrl);
}
else {
// Correct HTTP status code is 303, in particular for POST requests.
response.setStatus(303);
response.setHeader("Location", targetUrl);
}
}
}
I also already had my own ViewResolver in which I added the functionality for the new externalRedirect: magic vier name prefix, which now reads:
class MyViewResolver extends AbstractCachingViewResolver implements BeanFactoryAware {
[...]
private static final String EXTERNAL_REDIRECT_URL_PREFIX = "externalRedirect:";
[...]
@Override
protected View loadView( String viewName, Locale locale ) throws Exception {
View view;
if (viewName.startsWith(UrlBasedViewResolver.REDIRECT_URL_PREFIX))
{
view = new RedirectView(viewName.substring(UrlBasedViewResolver.REDIRECT_URL_PREFIX.length()), true);
}
else if (viewName.startsWith(EXTERNAL_REDIRECT_URL_PREFIX))
{
view = new ExternalRedirectView(viewName.substring(EXTERNAL_REDIRECT_URL_PREFIX.length()), true);
}
else
[...]
Thanks to everyone who read this and thought about it.