Init filter and final

I was writing a filter just now and I wanted to set a private final variable inside the init method so it is initialized only once.

basicly it was like this:

publicclass FilterXXXXimplements Filter

{

...

privatefinal String errorPage;

...

publicvoid init( FilterConfig filterConfig)

{

...

this.errorPage = com.project.global.Configuration.getErrorPageLocation();

...

}

...

}

But of course this is not possible, since a final variable can't have a new value assigned to it.

Is there any other way to do this? (and make it final)

[971 byte] By [radicjesa] at [2007-11-27 2:26:20]
# 1

The Filter#init() is not a static method and is invoked everytime when a filter is called, so you cannot declare the var final.

Do it outside the Filter#init() method right after the declaration or do it in a static block. Or just remove the final modifier if it obviously cannot be final.

BalusCa at 2007-7-12 2:35:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hm i was under the impression that the init() method is only called when the filter is compiled?If it is done every time a user accesses the filter, then what use does the init() have actually?Correct me if i'm wrong.
radicjesa at 2007-7-12 2:35:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...