• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!