Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

null pointer exception  RSS feed

 
srikanth arroju
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i run a jsp program getting exception at Tomcat console




java.lang.NullPointerException
at org.apache.jsp.index_jsp._jspService(index_jsp.java:121)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase
at javax.servlet.http.HttpServlet.service(HttpServlet.java:8
at org.apache.jasper.servlet.JspServletWrapper.service(JspSe
.java:334)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspSe
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.j
at javax.servlet.http.HttpServlet.service(HttpServlet.java:8
at org.apache.catalina.core.ApplicationFilterChain.internalD
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(Stan
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(Stan
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(Standar
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorR
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(Stand
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(Coyot
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Pr
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11Connect
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.run
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable
ool.java:684)
at java.lang.Thread.run(Unknown Source)
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open up index_jsp.java file from your work folder in Tomcat and see what's on line no. 121.
 
srikanth arroju
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//checking user name and password

if(user.equals("genesis") && pwd.equals("genesis"))
 
Duddiyanda Siraj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of user.equals("XYz"), use "XYZ".equals(user). but your error is due to String user which is not initialized
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If user or pwd is null then it would throw a nullPointerException. As suggested check it in the reverse manner in which case it would return false.

Change it to
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Siraj DH", you have previously been warned on multiple occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.

Failure to comply will result in the removal of your account.

bear
JavaRanch Sheriff
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!