I'm using Tomc开发者_开发问答at 7. I'm writing a servlet but I notice the init is being called for every request the user makes. I'm creating the servlet with annotations as seen below. I want the servlet to init itself once on startup and never again. But with this code its being called for every connection. If I'm missing something really obvious please let me know. Thanks.
@WebServlet(urlPatterns={"/Tesing"}, loadOnStartup=1)
public class Testing extends HttpServlet {
// ...
}
Found the issue ... it seems the very last call of my init was throwing an exception and as such the servlet was not getting initialized. Upon every remote connection it was trying to reconnect but failing on the same exception.
精彩评论