iam getting connection to DB in Listener class and setting it as a Context Attribute.this class is called when deploying the application. i am not using connection pooling. thic connection obj iam using in alll jsp's & Servlets. Is it a good practice to do that.
In my application iam getting DBconnection obj from context attribute which iam using in all my servlets & jsp's. but While closing the application iam getting null pointer exception code goes like this
finally { try { cont.removeAttribute("connection"); System.out.println("*Context Deatroyed**"); System.out.println("In Finally-- REMOVED CONTEXT ATTRIBUTE "); } catch(Exception ex1) { System.out.println("In Catch-- EXCEPTION IN removing CONTEXT ATTRIBUTE "+ex1); } } }//end of file while closing tomcat iam getting following exception *Context Deatroyed** In Finally-- REMOVED CONTEXT ATTRIBUTE context destroyed java.lang.NullPointerException
hi , in my application iam getting connection obj from context attribute which iam using in all my sevlets & jsp's. The application is running fine but sometimes iam getting following exception java.sql.SQLException: Io exception: Software caused connection abort: recv failed at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323) at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:417) at oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConn ection.java:474) at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection. java:383) at org.apache.jsp.Vis_002dReg.GetCompNames_jsp._jspService(GetCompNames_ jsp.java:64) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp atcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD ispatcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis patcher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary .java:1002) at org.apache.jsp.Vis_002dReg.VisRegCustmer3_jsp._jspService(VisRegCustm er3_jsp.java:320) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche rValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22 3) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :594) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ssConnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java :565) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:619) at java.lang.Thread.run(Thread.java:534) 222222 In GET COMPANY NAMES EXCEPTION java.lang.NullPointerException at org.apache.jsp.Vis_002dReg.GetCompNames_jsp._jspService(GetCompNames_ jsp.java:101) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp atcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD ispatcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis patcher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary .java:1002) at org.apache.jsp.Vis_002dReg.VisRegCustmer3_jsp._jspService(VisRegCustm er3_jsp.java:320) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche rValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22 3) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :594) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ssConnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java :565) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:619) at java.lang.Thread.run(Thread.java:534)
can any body help me with this wat went wrong, need urgent
hi , in my application iam getting connection obj from context attribute which iam using in all my sevlets & jsp's. The application is running fine but sometimes iam getting following exception java.sql.SQLException: Io exception: Software caused connection abort: recv failed at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323) at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:417) at oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConn ection.java:474) at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection. java:383) at org.apache.jsp.Vis_002dReg.GetCompNames_jsp._jspService(GetCompNames_ jsp.java:64) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp atcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD ispatcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis patcher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary .java:1002) at org.apache.jsp.Vis_002dReg.VisRegCustmer3_jsp._jspService(VisRegCustm er3_jsp.java:320) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche rValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22 3) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :594) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ssConnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java :565) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:619) at java.lang.Thread.run(Thread.java:534) 222222 In GET COMPANY NAMES EXCEPTION java.lang.NullPointerException at org.apache.jsp.Vis_002dReg.GetCompNames_jsp._jspService(GetCompNames_ jsp.java:101) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp atcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD ispatcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis patcher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary .java:1002) at org.apache.jsp.Vis_002dReg.VisRegCustmer3_jsp._jspService(VisRegCustm er3_jsp.java:320) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 01) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche rValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex t.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22 3) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :594) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ssConnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java :565) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:619) at java.lang.Thread.run(Thread.java:534)
can any body help me with this wat went wrong, need urgent
hai, iam confused with issue of using declaration and scriptlet tag.
in my code i need to initialze Statement,Resultset..... if i do that as below <%! Statement st=null; ResultSet rs=null,rs1=null; ArrayList al=null,custal=null; int pid=0,si=0; PreparedStatement ps=null; String enqT=null,poT=null,serviceT=null; %>at the end iam closing stmt & rs in finlly block
will there be any problem if i do this.coz code in declrtion tag will execute only once & not for every request.
i think thr is no need to initialize in this block.
one more thing wat is the default initial value of String var? null/space
hai, iam confused with issue of using declaration and scriptlet tag.
in my code i need to initialze Statement,Resultset..... if i do that as below <%! Statement st=null; ResultSet rs=null,rs1=null; ArrayList al=null,custal=null; int pid=0,si=0; PreparedStatement ps=null; String enqT=null,poT=null,serviceT=null; %>at the end iam closing stmt & rs in finlly block
will there be any problem if i do this.coz code in declrtion tag will execute only once & not for every request.
i think thr is no need to initialize in this block.
one more thing wat is the default initial value of String var? null/space