2010-05-27 53 views
0

我執行此重定向: -Facelets錯誤頁面,因爲響應已經提交。 JSF

頁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> 

,我得到這個錯誤: -

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.StandardHostValve.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 

在瀏覽器也我看到地址: -

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

沒有頁面名稱(LoginRequestProcessor.jsp),沒有用戶名,沒有密碼。 更有趣的是,它有時它的工作原理!但是,有80%的時間出現此錯誤並重新導向錯誤。

任何想法如何解決這個問題?

編輯: - 如果我不通過jsessionid重定向時,它工作正常,但然後會話ID更改。如果我通過jsessionid我得到上面的錯誤:(。

回答

1

由於錯誤說,響應已被提交 - 這意味着,HTTP狀態代碼和頭已被髮送到瀏覽器。自認爲已經發生了,這是來不及發送重定向。

不幸的是沒有辦法重置響應,據我所知。

這是很難不知道給予更多的建議更多關於您在哪裏以及如何撥打objExternalContext.redirect

相關問題