users@glassfish.java.net

Re: Load on start up servlet initializing two times

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Fri, 19 Jun 2009 09:30:51 -0700

If your Servlet extends javax.servlet.http.HttpServlet, then you
either override init(ServletConfig config), in which case you must
call super.init(config), or you override the zero-arg init(), in which
case no call to super.init() will be required.

Relevant javadocs quotes:

javax.servlet.GenericServlet#init(ServletConfig config):

     * <p>This implementation stores the {_at_link ServletConfig}
     * object it receives from the servlet container for later use.
     * When overriding this form of the method, call
     * <code>super.init(config)</code>.

javax.servlet.GenericServlet#init():

     * A convenience method which can be overridden so that there's no need
     * to call <code>super.init(config)</code>.
     *
     * <p>Instead of overriding {_at_link #init(ServletConfig)}, simply
override
     * this method and it will be called by
     * <code>GenericServlet.init(ServletConfig config)</code>.
     * The <code>ServletConfig</code> object can still be retrieved via
{_at_link
     * #getServletConfig}.

If your servlet does not perform any initialization, then simply don't
override any
of the init methods.


Jan


On 06/18/09 11:32 PM, glassfish_at_javadesktop.org wrote:
> Hello,
>
>
> Yep I missed that the init(ServletConfig) method was used !
>
> Since the config is not used, the init() method should probably be the right place to make this kind of treatment.
> What would you recommand from your point of view ?
>
>
> Bye
> [Message sent by forum member 'vkoniecz' (vkoniecz)]
>
> http://forums.java.net/jive/thread.jspa?messageID=352025
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>