Redirecting to an outside URL from HandlerInterceptor
Post by:Ashik Uzzaman
I am using Spring Portlet MVC with BEA WebLogic Server. Consider the following scenario.
I have a portlet that extends simple form controller and this controller has an associated interceptor. From my interceptor's preHandle(), I check for a buisness logic. If that logic passes it goes normally to my portlet, but if it fails, I would like to redirect the user to a different URL outside of my portal application, for example, to http://www.google.com if you don't mind.
I tried taking the HttpServletRequest out of the PortletRequest object available to me as preHandle() argument, then getRequestDispatcher() and forward it like we do in case of servlets. But naturally it doesn't work as servlet request dispatcher can be used to forward to a resource within the same web application using relative URL.
An alternate way may be to forward to a JSP within the portal application where I can use response object's sendRedirect() to redirect to anywhere I want. Is there any better idea without using this JSP page's help, so that I can redirect from within the handler interceptor? I am not sure even how I would redirect to the JSP page, because preHandle() doesn't return a ModelAndView, only a boolean.
This thread has been viewed 3785 times.
All times above are in ranch (not your local) time.
The current ranch time is Dec 15, 2018 08:35:21.