Hi Jack,
On 23.6.2011 6:36, juminoz wrote:
> Hi,
>
> I was wondering what is the best way to initialize Jersey servlet. I tried
> implementing the Servlet interface and overiding this method, but it doesn't
> seem to get called.
>
> public void init(ServletConfig config) throws ServletException;
>
> Then I tried adding the init logic in the constructor only to find that it's
> being invoked multiple times with each request. Is this supposed to happen?
Do you mean a resource class constructor? If so, then yes - resources
are request-scoped - i.e. a new instance would be created for each
request unless you change the scope of the resource class.
Can you elaborate more on what you are trying to achieve?
Martin