Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem when trying code from HFSJ  RSS feed

 
Vierda Mila
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm just trying code in HFSJ page 346-347 with a little modifications.
my code as per below

Person.java


MyServlet.java


Test.jsp


all above code compiled perfectly but when I run, it throw null pointer exception.
I realized in Person.java, I don't define name variable. Does it the cause of NPE?? but I think it should read the name from MyServlet.java when I call setName method.

What did I miss here? thank you for any reply.

regards,
-Vierda Mila-
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code request.getAttribute ("person") must by itself be returning null. If name were null you would see 'Person is: null' when Person is: <%= p.getName() %> is executed.

Do you have a related stack trace ? You are reaching the JSP through the servlet right ?
 
Vierda Mila
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepak,

thanks for your prompt reply and ouch...silly me, yeah I forgot to run the servlet first
will be careful next time

regards,
-Vierda Mila-
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!