开发者

Facelets error page as the response has already been committed. jsf

I perform this redirect :-

   objExternalContext.redirect("http://blogger.blogdns.com:8080/Blogger/Common/LoginRequestProcessor.jsp;jsessionid=" + objHttpSession.getId() + "?j_username="+ userName + "&j_password=" + password + "&rememberMe=" + rememberMe);

to page LoginRequestProcessor.jsp :-

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>

        <title>JSP Page</title>
        <script type="text/javascript">
            window.onload = function(){
                document.forms[0].submit();
            }
        </script>

    </head>
    <body style="background: black;">
        <div style="color: white;">


            <center><h1>Please wait login is being processed.</h1></center>
        </div>


        <%
            //change session id because it gets lost while switching from https to http

            System.out.println("Cookie in jsp " + request.getSession(true).getId());
        %>

        <form method="POST" action="j_security_check;jsessionid=<%= request.getSession(true).getId()%>" id ="frm">

            <input type="hidden" name= "j_username" value="${param.j_username}"/>

            <input type="hidden" name = "j_password" value="${param.j_password}"/>
            <input style="display: none;" type="submit" value="Submit"/>
        </form>
    </body>
</html>

And i get this error :-

WARNING: JSF1087: Unable to generate Facelets error page as the response has already been committed.
SEVERE: javax.faces.FacesException
javax.faces.FacesException
        at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:136)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
        at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostVal开发者_如何学JAVAve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:329)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:239)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalStateException
        at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:486)
        at com.sun.faces.context.ExternalContextImpl.responseSendError(ExternalContextImpl.java:831)
        at javax.faces.context.ExternalContextWrapper.responseSendError(ExternalContextWrapper.java:785)
        at com.sun.faces.application.view.MultiViewHandler.send404Error(MultiViewHandler.java:666)
        at com.sun.faces.application.view.MultiViewHandler.derivePhysicalViewId(MultiViewHandler.java:496)
        at com.sun.faces.application.view.MultiViewHandler.createView(MultiViewHandler.java:160)
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:253)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        ... 33 more

In browser also i see the address :-

http://blogger.blogdns.com:8080/Blogger/;jsessionid=a05bfc017aac39414876eccd38fe

No page name(LoginRequestProcessor.jsp), no username, no password. Even more interesting is the fact that sometimes it works! But 80% of the time it gives this error and redirects wrongly.

Any ideas how to solve this?

Edit :- if i don't pass jsessionid while redirecting, it works fine but then session id changes. And if i pass jsessionid i get the above error :(.


As the error says, the response has already been committed - what this means, is that the HTTP status codes and headers have already been sent to the browser. Since that has already happened, it is too late to send a redirect.

There is unfortunately no way to reset the response, as far as I know.

It is difficult to give more advice Without knowing more about where and how you call objExternalContext.redirect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜