Hi I am upgrading a site, moving from Notes to Java JSP’s and need to support a redirect from the old url’s to the new ones. So /site/oldpage.nsf?home needs to redirect to /site/newpage.jsp.
In Tomcat I’ve set up an error-page to redirect:
404
/avi_redirect.jsp
in the avi_redirect.jsp I have :
pageContext.forward( "/newpage.jsp" );
But as I need to do this for many pages I need to know the old page name ie /site/oldpage.nsf?home.
Any idea how I can get this? The response & headers don’t have it. The query string has the params but not the url.
Rather use a Filter for this, not a JSP (otherwise you may risk
IllegalStateExceptions). Also rather use a redirect instead of a forward (otherwise the old URL will stay in the address bar). Also rather use a 301 redirect instead of a (default) 302 (otherwise the old URL will still be indexed by searchbots).So, you need to create a
Filterwhich listens on anurl-patternof the old extension*.nsfand implement it basically like follows:You see that I already have reconstructed the URL to include the querystring (the part after
?).Ideally would be if the new JSP files are structured and named exactly the same way as originally, but only with a different extension. This way you don’t need a mapping, but just a string replace on the URL would have been sufficient: