4

I'm working on a web project using guice and guice servlet. I've already setup both guice filter and listener.

With this setup I can emulate web.xml filters and servlets in a servletmodule using the serve(...) and filter(...) methods.

Now the question:

On the guice servlet page they claim that web.xml is no longer needed, but I have failed at figuring out how to:

register contextlisteners (listener-tag in web.xml) and

Add context-param (I an able to setup init-param thou)

Is this even possible with guice servlet?

mathiasbn
  • 881
  • 11
  • 21

1 Answers1

0

I don't know about Listeners, but to manage the servlet context, it's very simple. In your ServletModule.configureServlets() :

getServletContext().setAttribute("productionMode", "true");
Mikael Couzic
  • 12,283
  • 5
  • 22
  • 16
  • Thx for the suggestion. I have seen that method. The thing is that setAttribute() is not the same as an contextParam. You retrieve the values differently. The context param i need to declare is used by some external lib, and therefore it's out of my control where it will look it up. – mathiasbn Oct 01 '12 at 13:40