0

I have webapp deployed on tomcat_5.0.28, Linux.

my app is multi users and profiles (user can be admin or just simple user).

In my web.xml I have these lines

...
<web-app>
    <display-name>my-app</display-name>
    <context-param>
        <param-name>configFileName</param-name>
        <param-value>/WEB-INF/my-app-config.xml</param-value>
    </context-param>
    ...

How to set the value of the param configFileName at user login according to his profile

Ould Abba
  • 813
  • 1
  • 12
  • 25
  • I mean if user's profile is admin then **/WEB-INF/my-app-config-adm.xml** if simple user **/WEB-INF/my-app-config-usr.xml** – Ould Abba Sep 12 '12 at 15:19
  • Are you getting the parameter value from within a servlet? If so why not determine the file name based on the logged in user by getting the user principal? This post may help. http://stackoverflow.com/questions/5976921/how-to-get-login-attributes-from-a-servlet-jsp – km1 Sep 13 '12 at 02:34
  • I used `request.getRemoteUser()` to get username after user login, but one I change the `param-value` it changes for all users (not only active one). – Ould Abba Sep 13 '12 at 09:45
  • Don't change the param value. Maybe set the param value to a template like `/WEB-INF/my-app-config-{username}.xml`. The after getting the remoteuser replace {username} with it. Now you have the path to the user's config file. – km1 Sep 13 '12 at 14:30

1 Answers1

1

If you can use the param value as a template

 <param-name>configFileName</param-name>
 <param-value>/WEB-INF/my-app-config-{username}.xml</param-value>

Then you jsp can be something like this

 String userName = request.getRemoteUser()
 String temp = context.getInitParameter("configFileName");
 String fileName = temp.replace("{username}", userName);
km1
  • 2,383
  • 1
  • 22
  • 27