в моем приложении java ee, я не могу реализовать функцию выхода из системы. это то, что происходит, когда я пытаюсь реализовать его: у меня есть header.xhtml, который Header Css часть моего приложения: header.xhtml: (код для выхода из системы)управляемый bean logout не работает
<div class="userid-link"><img src="images/app.png" alt=""/><p><a href="#{loginBean.logoutAction()}">Logout</a></p></div>
код для выхода из системы: loginBean. Java
public String logoutAction()
{
HttpServletRequest req=(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
try{
HttpSession session=req.getSession();
session.invalidate();
// req.logout();
}
catch(Exception e)
{
}
return"equityVolume.xhtml";
}
ошибка:
SEVERE: Error Rendering View[/ClientTemplate/userWatch.xhtml]
javax.el.ELException: /ClientTemplate/userWatch.xhtml @44,62 value="#{watchBean.ut}": java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
...
INFO: Exception when handling error trying to reset the response.
java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed
at...
на дом страница загружается нормально, но когда я пытаюсь войти в систему, то userWatch.xhtml не отображается должным образом, и я получаю й e выше ошибки, css также не применяется.
watchBean.java
public List<UserTrack> getUt() {
HttpServletRequest req=(HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
HttpSession session=req.getSession();// debugged and found that the session is null, this methos executes after login i.e. on the userWatch.xhtml that is redirected after login from homePage
this.uname=(String)session.getAttribute("uname");
ut=getAllUserTrack(uname);
return ut;
}
, когда я удалить метод logOutAction вызова из header.xhtml, то все работает отлично, за исключением, что я получаю viewExpired ошибка при выходе:
<div class="userid-link"><img src="images/app.png" alt=""/><p><a href="#/homePage">Logout</a></p></div>
как я решить Это?
Пожалуйста, вы можете проверить его с помощью 'request.getSession (ложь)' и опубликовать результаты? – higuaro
попробовал все же получить ту же ошибку :( – z22
Ознакомьтесь со следующими ссылками: они описывают возможные решения для 'IllegalStateException', которые бросают на вас приложения: (http://stackoverflow.com/questions/8426121/cannot -create-a-session-after-the-response-has-been-commit-why) (http://stackoverflow.com/questions/5540695/pwc3999-cannot-create-a-session-after-the- ответ-был принят) (http://stackoverflow.com/questions/8072311/illegalstateexception-cannot-create-a-session-after-the-response-has-been-commi) – higuaro