• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

java.lang.NullPointerException

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Marshal
Posts: 5950
407
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5950
407
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean this?
139 ROW IS 118
 
Sheriff
Posts: 28398
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic