Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 AuthenticatedWebSession.toString() and this value is shown on the sessin details page.

I have tried to set AuthenticatedWebSession.userName as recommended here.

like image 719
Martin Schlagnitweit Avatar asked Sep 02 '11 12:09

Martin Schlagnitweit


2 Answers

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);
like image 67
lgawron Avatar answered Oct 22 '22 22:10

lgawron


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

like image 45
Manuel Tijerino Avatar answered Oct 22 '22 22:10

Manuel Tijerino