| Author |
problem when trying code from HFSJ
|
Vierda Mila
Ranch Hand
Joined: Feb 25, 2008
Posts: 61
|
|
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-
|
SCJP 5
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6588
|
|
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 ?
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Vierda Mila
Ranch Hand
Joined: Feb 25, 2008
Posts: 61
|
|
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-
|
 |
 |
|
|
subject: problem when trying code from HFSJ
|
|
|