aspose file tools
The moose likes JSP and the fly likes problem when trying code from HFSJ Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "problem when trying code from HFSJ" Watch "problem when trying code from HFSJ" New topic
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
    
    1

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-
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: problem when trying code from HFSJ
 
Similar Threads
problem in jsp:useBean
El property not found problem
package foo doesnot exist
Why tomcat act like it error?
jsp:usebean | NoClassDefFoundError