문제

Apparently the following is generating a loop(the GenericServlet class is calling the subclass's init())

public void init() throws ServletException {

  ServletConfig c = this.getServletConfig();
  super.init(c);

}

I'm probably just doing this wrong. Thank you guys in advance!

도움이 되었습니까?

해결책

Remove the super.init(c); line. You only need to call this in init(ServletConfig) method, not in the init() without ServletConfig argument. That's also exactly what the linked javadoc tells:

A convenience method which can be overridden so that there's no need to call super.init(config).

The infinite loop is indeed caused because the default init(config) implementation is under the hoods calling the init().

다른 팁

No need for the super.init(c);. Remove it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top