我执行此重定向: -
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,它工作正常但会话ID更改。如果我通过jsessionid我得到上述错误:(。
答案 0 :(得分:1)
如错误所示,响应已经提交 - 这意味着HTTP状态代码和标头已经发送到浏览器。由于已经发生这种情况,因此发送重定向为时已晚。
据我所知,遗憾的是没有办法重置响应。
如果不了解更多关于您拨打objExternalContext.redirect
的地点和方式的信息,很难提供更多建议。