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">
Authorization
<br / >
 Username:<input type="email" name="j_username">
br><br>
 Password:<input type="password" name="j_password">
br><br>
 <input type="submit" value="Login"> 
 </form>

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
Solution
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