开发者

How to solve stackoverflow errors in servlets?

i have declared all of my variables and methods in public inside the (servletconn.java). i want to access that variables and methods from another one servlet(NewServlet.java), am creating an object using conn co=new conn(); .but that code displays a开发者_Go百科n error (stackoverflow Error). how do i solve this problem?


Sounds like you're recursivelly calling your servlets. Without some code, it's anyone's guess.


Usually a servlet throws IOException,ServletException by default in the callback methods like doGet,doPost etc.

Creating a Database Connection also needs to throw SQLException, ClassNotFoundException Just try to catch these instead of throwing them explicitly.


If you want to share information between servlets, Why not use ServletContext? You can use ServletContext.setAttribute(key, object) (for uploading) and ServletContext.getAttribute(key) for retrieval.

There is 1 ServletContext per web application, per JVM. So, each servlet, in your webapp, have the same ServletContext.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜