This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Redirecting to an outside URL from HandlerInterceptor  RSS feed

 
Ranch Hand
Posts: 2373
Java MySQL Database Spring
  • 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 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!