Referencing Environment Variables in web.xml

前端 未结 7 1269
無奈伤痛
無奈伤痛 2020-11-30 01:37

I\'m pre-packaging a JSP web-app that relies on some file path settings found within web.xml. These settings are unknown at packaging time, because they reference a path the

7条回答
  •  天命终不由人
    2020-11-30 02:25

    I'm not totally clear on your limitations, but just maybe you can do this (I'm assuming that it's an init-param you're trying to configure):

    1) Leave the variable unspecified in web.xml
    2) Create a ServletContextListener and add that to your application
    3) Listen for the initialization of your servlet
    4) Set the init-param for the servlet at that point

    I tried this with a similar problem, but it failed for me because it turned out that the 3rd party servlet (which I also didn't want to mess with) wasn't actually behaving as a servlet at all, so the context never got initialized. But maybe it has a chance here...

提交回复
热议问题