jQuery in Action, 2nd edition*
The moose likes Portals and Portlets and the fly likes Redirecting to an outside URL from HandlerInterceptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Redirecting to an outside URL from HandlerInterceptor" Watch "Redirecting to an outside URL from HandlerInterceptor" New topic
Author

Redirecting to an outside URL from HandlerInterceptor

Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

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.

Any help?


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redirecting to an outside URL from HandlerInterceptor