How to use the "Guessed User name" in tomcat manager in a wicket application?
Asked Answered
P

2

13

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.

Pierian answered 2/9, 2011 at 12:22 Comment(0)
H
27

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);
Howler answered 5/9, 2011 at 11:45 Comment(3)
There is also a column in Tomcat Manager Guessed Locale, maybe you know how to set it also?Braeunig
@zygimantus, for locale, the manager tries the following attribute names: "org.apache.struts.action.LOCALE", "org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE", "javax.servlet.jsp.jstl.fmt.locale", "Locale", "java.util.Locale". See mail-archives.apache.org/mod_mbox/tomcat-users/200905.mbox/…Cony
Is there any option to update Guessed Locale in apache server 9.0Eberhard
S
1

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

Sciatic answered 11/2, 2018 at 19:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.