Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PrintWriter object's unusual error::  RSS feed

 
Harish Tiruvile
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,

While writing Servlet program i got error which is unusual ,while working with ordinary java programs..

Question: why PrintWriter Object is giving NullPointerException even after assigning proper object reference

Scenario: Here i am creating an object(PrintWriter) inside one method(doGet),then i am assigning that object to globally declared variable.

Even though i have assigned object reference to out variable ,in output it is giving NullPointerException.

I can resolve that issue(NullPointerException) by making PrintWriter object as static(i have tryed..it is executing properly)...

But I am not able to find out the reason why i am getting NullPointerException(even after assigning proper object reference,without static modifier)

Note: i am having problem with only PrintWriter object ...rest of the code is executing properly___i.e no error with reponse & request object.


If anybody knows the reason then please assist me in finding out where i made mistake...

I have tryed with ordinary java code(means,no servlet,no JSP....with program which have main method) it is executing even though i am doing assigning operation to globally declared variable inside inside local scope..But i am having problem with servlet.

If anybody knows the reason then please assist me in finding out where i made mistake...
[ September 12, 2006: Message edited by: harish thrivile ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!