Home
TeamSite
Page forward from one page to another page
sri536
Hi I need to forward response from one page to another page , for that we are using
return new Http302ForwardAction(new FullUrlTarget(page)); in controller component.
but this is causing HTTP 302 response on CDN(amazon webservice) which dont accept HTTP 302, I am trying to replace Http302ForwardAction with RequestDispatcherForwardAction, not able to get the correct syntax.
I was trying as below, but it is giving HTTP 404 on livesite when it try to redirects to second page. Page it is trying to redirect is /en_TH/search.page, which is not there, it should instead redirect to /en_TH/search/search.page. Below is the method used.
public ForwardAction forwardToPicoSearch(RequestContext context)
{
BaseRequestContext baseContext = (BaseRequestContext) context;
String page = context.getPageLink("search/search");
System.out.println("Controller=>forwardToSearch page url:" +page.toString() );
return new RequestDispatcherForwardAction(new ContextRelativeTarget(new FullUrlTarget(baseContext.getRequest(), new ServerRelativeTarget(page))));
}
Let me is this is the correct syntax?
Thanks in advance
Find more posts tagged with
Comments
sri536
Hi All,
Now I have chanegd my method as below, after this it is trying to forward to correct path /en_TH/search/search.page, but still livesite giving "HTTP Status 404 - /en_TH/search/search.page".
Though I can access the page directly if I try in browser.
http://serverName:1776/en_TH/search/search.page
public ForwardAction forwardToPicoSearch(RequestContext context)
{
BaseRequestContext baseContext = (BaseRequestContext) context;
String page = context.getPageLink("search/search");
System.out.println("Controller=>forwardToSearch page url:" +page.toString() );
return new RequestDispatcherForwardAction(new ContextRelativeTarget(page));
}
Any help is highly appreciated
Thanks,
Sreedhar
Rick Poulin
This will never work because the request dispatcher forwards it to the servlet engine, which won't run the LiveSite code again (because it's implemented as a filter). So basically, you get a 404 because the servlet is looking for LiveSiteDisplayService/runtime/web/en_TH/search/search.page and trying to serve it as a static asset, which doesn't exist. If you want to do internal request forwarding, you have to write your own filter to act before the LiveSite one, and change the httprequest object before you pass it along in the filter chain.
sri536
Thanks rpoulin for your reply,
Based on you reply On the same line I have tried below change.
edited web.xml added dispatcher tag.
<filter-mapping>
<filter-name>runtime.filter.LiveSiteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
and used RequestDispatcherForwardAction in controller, now I am getting
03:28:44,045 ERROR [RuntimeRenderingManager] Unhandled exception thrown during rendering
com.interwoven.livesite.runtime.rendering.RenderingException: Unhandled Exception
at com.interwoven.livesite.runtime.rendering.RenderingManager.handleException(RenderingManager.java:987)
at com.interwoven.livesite.runtime.rendering.RenderingManager.render(RenderingManager.java:266)
at com.interwoven.livesite.runtime.filter.LiveSiteFilter.doFilter(LiveSiteFilter.java:129)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
..
..
Caused by: java.lang.RuntimeException: Component ID submitted not found on page, componentID=1391531584027
Any idea why it is saying component Id not found on page?
Rick Poulin
Any idea why it is saying component Id not found on page?
Remember how I just said that this can't (or, I guess, shouldn't) be done? You're running off into unsupportedland, so who knows what errors you're going to run into. If you're going to ignore the supported development paths, then you're going to have to be ready to support and debug your solution yourself.
That said, this particular exception might just be complaining about your target page, so try a different one.
Bowker
Here is another solution for you that is working for us.
In your controller instead of returning a 302, I assume you just want to return the content in place and return a 200.
We did this by creating an external (pre-controller will work too) that looks up a which page we want to "forward to" and "slurped" the URL within Java and copied the response into the response object. Then return "new StopForwardAction()" to terminate processing by LiveSite.
Basically it works like a proxy and works like a charm. I'm trying to use the same concept for a total server relocation (see forum my posting of 3/1 for a challenge I'm having with it, unrelated to what you are trying to accomplish.)