Re: Redirect before/during page load

Splash Forums PrettyFaces Users Redirect before/during page load Re: Redirect before/during page load

#22170

DRY2
Participant

Thx for response. Bellow is the info you asked for.

// page load

public void loadIndex(PhaseEvent phaseEvent) {

prettyRedirectCity(); }

// redirect city method

public void prettyRedirectCity() {

if(!getCookie(“defaultCity”).equalsIgnoreCase(“null”)){

city = getCookie(“defaultCity”);

updateStateParam();

this.prettyFacesRedirect(“city”, new Object[] { state, city });

}

}

The prettyFacesRedirect method is the code from my original post.

//stack trace

java.lang.IllegalStateException: Response already committed

at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1608)

at weblogic.servlet.internal.ServletResponseImpl.sendRedirect(ServletResponseImpl.java:834)

at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:136)

at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:136)

at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:136)

at siteUtils.siteTasks.prettyFacesRedirect(siteTasks.java:4348)

at siteUtils.siteTasks.prettyRedirectCity(siteTasks.java:4380)

at siteUtils.siteTasks.loadIndex(siteTasks.java:270)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.sun.el.parser.AstValue.invoke(Unknown Source)

at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)

at javax.faces.component.UIViewRoot.notifyPhaseListeners(UIViewRoot.java:608)

at javax.faces.component.UIViewRoot.notifyBefore(UIViewRoot.java:510)

at javax.faces.component.UIViewRoot.encodeBegin(UIViewRoot.java:564)

at javax.faces.component.UIComponent.encodeAll(UIComponent.java:928)

at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)

at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)

at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:87)

at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:189)

at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)

at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:800)

at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:294)

at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:214)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)

at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)

at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)

at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)

at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)

at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)

at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)

at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)

at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:126)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)

at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)

at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)

at java.security.AccessController.doPrivileged(Native Method)

at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)

at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)

at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)

at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)

at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)

at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)

at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)

at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)

at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)

at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

FYI: at siteUtils.siteTasks.prettyFacesRedirect(siteTasks.java:4348) is pointing to response.sendRedirect(targetURL);