How to use the "Guessed User name" in tomcat manager in a wicket application?
In Tomcat Manager on the Page "Sessions Administration", there is a column Guessed User name. How can i set this column from within my Wicket Session?
Note: I have successfully overridden 开发者_JAVA百科AuthenticatedWebSession.toString()
and this value is shown on the sessin details page.
I have tried to set AuthenticatedWebSession.userName
as recommended here.
Please mind that Wicket session is a different beast than actual servlet session. Creating a "userName" property in wicket session will not work.
You need to access the raw HttpServletRequest from wicket to set the value properly: this is how you do it.
Add this code to your WebPages:
HttpServletRequest request = getWebRequestCycle().getWebRequest().getHttpServletRequest();
request.getSession().setAttribute("userName", userName);
You can create any Java bean and add it to session like this, session.setAttribute("user", user); Tomcat will find the bean and whatever prints in toString will show up. see image here
精彩评论