I am working on legacy project, I am just trying to make it running (it is supposed to work). But I found out a problem with the session in my JPSs
( No much settings changed on standalone.xml
)
Here is login instruction in my servlet doPost
method:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
PrintWriter out = response.getWriter();
try {
User user = loginService.login(username, password);
request.getSession().setAttribute("user", user);
} catch (OAuth2AccessDeniedException e) {
e.printStackTrace();
}
}
And in my main page:
<%if(session.getAttribute("user")==null){ %>
<html><body><script>window.location.href = "index.html"</script></body></html>
<%}else{
User user = (User)session.getAttribute("user");
%>
<html>
//rest of html page
When I debug, I find that the user is correctly set in the session but in my jsp
it is null