Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting to an outside URL from HandlerInterceptor

Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 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.

Any help?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic