Thanks Deepak, and sorry for putting the code this way.
here is the stack trace:
11:22:36,843 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException at org.apache.jsp.FileData_jsp._jspService(FileData_jsp.java:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Kunal Alshi wrote:i have my code in doPost() ... but my doPost method is not getting called, tried this by writeng some SOPs.
why is that ?
Then how you get to the JSP anyway? First make sure the program flow is working well then you may correct other errors
Kunal Alshi
Ranch Hand
Joined: Jan 07, 2009
Posts: 40
posted
0
Vijitha Kumara wrote:
Kunal Alshi wrote:i have my code in doPost() ... but my doPost method is not getting called, tried this by writeng some SOPs.
why is that ?
Then how you get to the JSP anyway? First make sure the program flow is working well then you may correct other errors
yeah madam ! i wrote the code in doGet(). Because in this case, doPost() will never execute.
the program flow is correct, because the static data is from my jsp is getting displayed. Only the List is passed as NULL.
I get the following exception.
I guess solving this exception will solve the problem as well.
Please help me to solve this exception.
Thanks.
14:16:17,593 ERROR [STDERR] java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@6adf2f{VFSClassLoaderPolicy@6288ed{name=vfszip:/C:/Program%20Files/JBoss/jboss-5.0.1.GA/server/default/deploy/SampleWebProject.war/ domain=ClassLoaderDomain@bffcc0{name=vfszip:/C:/Program%20Files/JBoss/jboss-5.0.1.GA/server/default/deploy/SampleWebProject.war/ parentPolicy=AFTER_BUT_JAVA_BEFORE parent=ClassLoaderDomain@996cca{DefaultDomain}} roots=[MemoryContextHandler@17531354[path= context=vfsmemory://5c4o033-8j4ejr-fw4no7b5-1-fw4nohfq-1x real=vfsmemory://5c4o033-8j4ejr-fw4no7b5-1-fw4nohfq-1x], ZipEntryHandler@8012028[path=SampleWebProject.war/WEB-INF/classes context=file:/C:/Program%20Files/JBoss/jboss-5.0.1.GA/server/default/deploy/ real=file:/C:/Program%20Files/JBoss/jboss-5.0.1.GA/server/default/deploy/SampleWebProject.war/WEB-INF/classes]] delegates=null exported=[com.file.sample] <IMPORT-ALL>NON_EMPTY}}
14:16:17,593 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:422)
14:16:17,593 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
14:16:17,593 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(Unknown Source)
14:16:17,593 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
14:16:17,593 ERROR [STDERR] at java.lang.Class.forName(Unknown Source)
14:16:17,593 ERROR [STDERR] at com.file.sample.ConnectionUtil.getConnection(ConnectionUtil.java:13)
14:16:17,593 ERROR [STDERR] at com.file.sample.FileDAO.getDataFromDB(FileDAO.java:31)
14:16:17,593 ERROR [STDERR] at com.file.sample.FileServlet.doGet(FileServlet.java:36)
14:16:17,593 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
14:16:17,593 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
14:16:17,593 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
14:16:17,593 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
14:16:17,593 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
14:16:17,593 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
14:16:17,593 ERROR [STDERR] java.lang.NullPointerException 14:16:17,593 ERROR [STDERR] at com.file.sample.FileDAO.getDataFromDB(FileDAO.java:36)
14:16:17,593 ERROR [STDERR] at com.file.sample.FileServlet.doGet(FileServlet.java:36)
14:16:17,593 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
14:16:17,593 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
14:16:17,593 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
14:16:17,593 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
14:16:17,593 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
14:16:17,593 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
14:16:17,593 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
14:16:17,593 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
I guess this wont work for servlets, right ??
where should I put this jar file, so as to include in classpath ?
Dawn Charangat
Ranch Hand
Joined: Apr 26, 2007
Posts: 249
posted
0
doPost() will get hit only if you specifically mention "method=POST" in the form declaration inside your JSP page, from where the control initially came to the servlet. Once inside the servlet, there are a lot of ways to know if the list returned is null :
1) if(null == servletList) sysout("list is null")
2) if(null == servletList && servletList.isEmpty()) sysout("list is not null, but empty")
etc.....
Kunal Alshi wrote:C:\Program Files\mysql-connector-java-5.1.7\mysql-connector-java-5.1.7-bin.jar
I am loading it from this location.I guess this wont work for servlets, right ??where should I put this jar file, so as to include in classpath ?
Where are you deployed this servlet? You have to put the JDBC jar file in a place where web/application server can find, usually inside your application's lib directory.
Kunal Alshi
Ranch Hand
Joined: Jan 07, 2009
Posts: 40
posted
0
Thanks for the help everyone.
The exception is gone by placing the connectorJ jar in the lib folder of application server and including it in the classpath.
But I am still having some issues with displaying the List elements on jsp page.
I will keep this thread updated for the solution.
Thanks a lot !!
Dawn Charangat
Ranch Hand
Joined: Apr 26, 2007
Posts: 249
posted
0
why dont you just place these dependent jars inside
folder, restart the web server/servlet container, and check if you are still getting the classnotfound ???
Loading the class from a different location other than the web server path is a bad idea.
Kunal Alshi
Ranch Hand
Joined: Jan 07, 2009
Posts: 40
posted
0
Hi everyone
Can anyone please say me what is wrong with these statements ?
Servlet code:
JSP code:
"dataList" has the value of NULL, even though "servletList" is NOT NULL.
You seem to be solving one problem after another but not exactly in the way desired. When posting your next question please also post a related stack trace and a specific cause for the problem. That way the answers will help you a lot more.
"dataList" has the value of NULL, even though "servletList" is NOT NULL.
This is an impossibility, unless the session attributes were removed for some reason.
Hit the servlet.
Confirm if the list was null
The servlet redirects to the JSP
The value should be printed.
As simple as that. Your libraries should ideally not be present on a container level classpath
Kunal Alshi
Ranch Hand
Joined: Jan 07, 2009
Posts: 40
posted
0
Deepak Bala wrote:When posting your next question please also post a related stack trace and a specific cause for the problem. That way the answers will help you a lot more.
Here it is:
08:58:43,687 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException at org.apache.jsp.FileData_jsp._jspService(FileData_jsp.java:112)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Hit the servlet.
Confirm if the list was null
The servlet redirects to the JSP
The value should be printed.
On hitting the servlet, the List is displayed. On hitting the jsp, List is not displayed.
So, the List is not getting passed to the jsp.
Okay, now show the code where the null pointer occurs (again, if it's the same code as before). Better yet, show *more* of the code in question. Things don't just disappear out of session for no reason, and this back-and-forth isn't very efficient.
Kunal Alshi
Ranch Hand
Joined: Jan 07, 2009
Posts: 40
posted
0
Hi All
Thanks for your concerns.
The real problem was that I was hitting the jsp url, instead of the servlet, which I later came to know was a mistake in itself.
My program got running by hitting the servlet url.