• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPointerException  RSS feed

 
Luis Cardenas
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there fellows,
I've been doing a JSP about a teacher, that needs to log in, and when he does and his acc is verified in a database (db4net) he stays in the JSP,
the problem is all of the data gets returned to the JSP from the database (name, last name, cellphone, sex etc.) then I made a Combo Box where it
shows the different subjects he teaches.... in this case it shows "Math 5" and "Advanced Math" .... the thing is when I try to like select a subject and run
it with a button to get it "out.print" it shows me this annoying error of "java.lang.NullPointerException", so then I worried and tried to do a simple Combo Box
and also the "java.lang.NullPointerException" error came, but anyways here's my code (sorry for spanish code, tried to
translate it a bit). I put it in color red, hope you can help new to programming

 
Tim Cooke
Marshal
Posts: 3702
197
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's worth pointing out that you have essentially no JSP code in there at all. What you have is HTML with a bunch of Java code, this is very poor practice and will gain you no friends in industry if you were to write that. It saddens me that your teacher is teaching this today.

But back to you particular problem. You say you get a NullPointerException but you don't say where. Can you post the exact stack trace and indicate the line in your 'JSP' file it corresponds to?
 
Luis Cardenas
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Curious I didn't see it that way... Well my problem is when I click on my buttons the null exception appears,
I have 2, and none of them work
 
Tim Cooke
Marshal
Posts: 3702
197
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still need that stack trace to describe the exact error.
 
Luis Cardenas
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean this?
139 ROW IS 118
 
Paul Clapham
Sheriff
Posts: 22211
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, as you have found, it is annoyingly difficult to debug this kind of error in a JSP. That's only one of the reasons why people have been telling beginners not to put Java code in a JSP for more than a decade now. So I'm telling you that now. Get that code out of the JSP into a servlet for a start.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!