Hi, I wanted to add that I am accessing the servlet via a javascript request from Apache HTTP. As such I am setting the following in the header of the POST response:
resp.setHeader( "Access-Control-Allow-Origin", mAllowedHost ); Just wanted to mention this just in case it had anything to do with the init/param problem I am seeing. Cheers, Stuart On 16 Oct 2012, at 18:06, Stuart Broad wrote: > > Hi all, > > I am not sure why but my servlet init method is getting called more than once > and I am not sure why. Any help would be much appreciated. > > My web.xml is as follows: > > <?xml version="1.0" encoding="UTF-8"?> > <web-app> > <servlet> > <servlet-name>myserlvet</servlet-name> > <servlet-class>MyServlet</servlet-class> > <async-supported>true</async-supported> > <init-param> > <param-name>example</param-name> > <param-value>value</param-value> > </init-param> > <load-on-startup>1</load-on-startup> > </servlet> > > <servlet-mapping> > <servlet-name>myservlet</servlet-name> > <url-pattern>/poll</url-pattern> > <url-pattern>/run</url-pattern> > <url-pattern>/stop</url-pattern> > </servlet-mapping> > <listener> > <listener-class>MySessionListener</listener-class> > </listener> > </web-app> > > I am accessing over HTTPS. The initial POST seems to work ok: > > 0:0:0:0:0:0:0:1%0 - - [16/Oct/2012:16:53:54 +0100] "POST /myservlet/run > HTTP/1.1" 200 34 > > But then this is followed by a GET which fails: > > 0:0:0:0:0:0:0:1%0 - - [16/Oct/2012:16:53:54 +0100] "GET > /myservlet/poll?_dc=1350402834770 HTTP/1.1" 500 2312 > > The reason the GET fails is because the creation of the Servlet fails. This > is the second time the servlet init is called and for the second time the > init parameters are null (so it fails to be created). If I could figure out > why the init params are null the second time around I could probably come up > with a work around BUT my preference is to figure out why the init method is > being called twice. > > I bit more information: > > Tomcat version: apache-tomcat-7.0.29 > Mac OS X 10.7.5 > > Cheers, > > Stuart > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org