How to save the username of the authenticated user in a variable?

Implemented the authorization using JDBCRealm. The username and password entered at login.jsp
<form action="j_security_check" method="POST">
<br / >
 Username:<input type="email" name="j_username">
 Password:<input type="password" name="j_password">
 <input type="submit" value="Login"> 

After login go to the main page.xhtml.
I display the username of a registered user obtained, but how to save in the variable as?
Probably a stupid question, but because of this problem, can't move on :(
June 26th 19 at 14:03
1 answer
June 26th 19 at 14:05
Found a slightly different way.
In java class:
private Object userLoginGo;
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
userLoginGo = request.getRemoteUser();

Find more questions by tags Java