super.init(config) calls init(config) in javax.servlet.GenericServlet

  public void init(ServletConfig config) throws ServletException
    _config = config;

If the call is missing, methods like getInitParameter, getServletName,
etc. do not work as well as logging methods. But, I think, there is not
serious consequences. There could be some problems if your servlet calls
getSelvletConfig to do any clean up job.

I think is a better practice to override init() method and not
init(ServletConfig config) method.

public void init() throws ServletException {
   sc = getSelvletConfig().getServletContext() ;
  try {
    env = (Context) new InitialContext().lookup("java:comp/env");

Or even better
public void init() throws ServletException {
        sc = getServletContext() ;
        . . .

In init() method super().init() can be omitted safely.

Andrea Sodomaco
Andrea Sodomaco Consulenze Informatiche
Via Giacometti, 4 - 34146 TRIESTE
Tel.: 040 281648 / 338 3565702 - Fax: 040 46069349

-----Messaggio originale-----
[mailto:[EMAIL PROTECTED] Per conto di John Steel
Inviato: martedì 24 aprile 2007 17.05
Oggetto: [Resin-interest] What happens if you *don't* call

Just found (and corrected) a probable howler in a pretty busy servlet:

public void init(ServletConfig config) throws ServletException {
  sc = config.getServletContext();
  try {
    env = (Context) new InitialContext().lookup("java:comp/env");
    pool = (javax.sql.DataSource)
  } catch (NamingException e) {
  logConfPath = sc.getRealPath("")+"WEB-INF/log/";

The super.init() line was missing. We didn't notice because it was
serving correctly, but have seen a gradual slowdown over a few days
usually cured by a restart. Could the missing line have caused it? If
not, what bad side effects could we have expected please?


resin-interest mailing list

resin-interest mailing list

Reply via email to