Actually, even better, use:
public void init() throws ServletException
{
ServletConfig config = getServletConfig();
ServletContext ctx = getServletContext();
...As with using 'public void init(ServletConfig config)' you should call super.init(config), whereas init() is a template method just there for users to override. By the time init() is called, the config/ ctx objects are set on the servlet.
I'll add a note to the Javadocs for this.
Eelco
Eelco Hillenius wrote:
Kevin, my guess is that you used getServletContext() in the WebApplication constructor. Just as with normal servlets (after all, the WebApplication class is a servlet), this won't work as the servlet container is probably still initializing.
If you want to use the servlet context, you should override:
public void init(ServletConfig config) throws ServletException { ...
And get your servlet context object from the config object.
If that doesn't solve your problem, pls let this list know.
Eelco
Kevin Burke wrote:
Is there any way to get the Servlet Context object in a WebApplication? I have tried using the getServletContext() method in my application class (which extends WebApplication) which returns null. I also tried getting the Servlet Config with getServletConfig() which also returns null. Is there a reason for this happening? Thanks.
Kevin
------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
