java - Servlet doGet Method getting called multiple times for the same HTTP request -


i have run weird problem. servlet's doget method getting called multiple times single http request. rerun happens every 10-12 seconds till initial process completes.

below servlet code

private static final long serialversionuid = webserviceservlet.class.getcanonicalname().hashcode();  private servletcontext servletcontext; /**  * @see httpservlet#httpservlet()  */ public void init(servletconfig servletconfig) throws servletexception {     super.init(servletconfig);     servletcontext = servletconfig.getservletcontext(); } /*public webserviceservlet() {     super(); }*/ /**  * @see httpservlet#doget(httpservletrequest request, httpservletresponse  *      response)  */ protected void doget(httpservletrequest request,         httpservletresponse response) throws servletexception, ioexception {     dopost(request, response); }  /**  * @see httpservlet#dopost(httpservletrequest request, httpservletresponse  *      response)  */ protected void dopost(httpservletrequest request,         httpservletresponse response) throws servletexception, ioexception {     string output = null;     /*      * calling operation manager decide operation type      * , call corresponding operation binder , set return      * response generated in http response.      */     // request processing     response.setcontenttype("application/json; charset=utf-8");     printwriter out = response.getwriter();     out.print(output);     out.close(); } @override public void destroy() {     super.destroy(); } 

below mapping in web.xml

<servlet>     <description></description>     <display-name>webserviceservlet</display-name>     <servlet-name>webserviceservlet</servlet-name>     <servlet-class>com.servlet.webserviceservlet</servlet-class> </servlet> <servlet-mapping>     <servlet-name>webserviceservlet</servlet-name>     <url-pattern>/web.do</url-pattern> </servlet-mapping> 

i using seam , jsf standalone servlet. there no exception in logs. have verified init method being called once. service method being repeated. identity hash code comes same reruns (system.identityhashcode(this)).

the call being made rest api tester. there no multiple calls happening caller. reruns happening on tomcat container.

i @ wit's end. has else faced issue?

the spec tell true, @ least hope. see here:

service(...): receives standard http requests public service method , dispatches them doxxx methods defined in class. method http-specific version of servlet.service(javax.servlet.servletrequest, javax.servlet.servletresponse) method. there's no need override method.

the service() method called java web container. method invokes doget dopost (the rest of doxxx methods). have nothing in service() method! override doxxx() (doget, dopost...) depending on method type (request type) expect solution. html form might set using method=get or method=post.

to understand how , why service() called need understand servlet life cycle, web container implementation, network layer etc.

as see in spec , wrote, service(...) called requests , can called container on different situations (depends of container vendor implementation). need focus on dispatched method, i.e. / post etc. service() can called once dohead (http head request) , calls again doget or dopost. should not relay on service(...) methods behavior, focus on doget , dopost etc...

i have seen odd behavior when run , test on local machine when accessing via loopback address (http://127.0.0.1). better go via http://localhost in cases.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -