gpt4 book ai didi

java - Facelets 错误页面,因为响应已提交。 JSF

转载 作者:行者123 更新时间:2023-12-01 16:04:29 26 4
gpt4 key购买 nike

我执行此重定向:-

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

到页面 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,它可以正常工作,但 session ID 会发生变化。如果我传递 jsessionid 我会收到上述错误:(。

最佳答案

正如错误所示,响应已经提交 - 这意味着 HTTP 状态代码和 header 已经发送到浏览器。由于这种情况已经发生,因此发送重定向已为时已晚。

不幸的是,据我所知,无法重置响应。

如果不了解更多关于在何处以及如何调用 objExternalContext.redirect 的信息,就很难提供更多建议。

关于java - Facelets 错误页面,因为响应已提交。 JSF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2921701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com