This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes Problem sending a string as Http response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem sending a string as Http response" Watch "Problem sending a string as Http response" New topic
Author

Problem sending a string as Http response

harsha galla
Greenhorn

Joined: Sep 24, 2008
Posts: 18
Hello,
I have a problem where i tried to send the string form of xml data as a response to the front end which makes a http call to the servlet. But my front end recieves response as java.lang.NullPointerException.

Can anybody tell why this is happening.
I send string to front end with the following command:

where xx is the string of xml i.e "xml data....."
which means xx has been converted to string data.
but when i send some string like "blah,,,blah..."

it is recieved correctly as "blah..blah" in the front end.
Is this issue because of xml data present as string..
Any help is welcome

Thanks in advance

[ November 20, 2008: Message edited by: harsha galla ]
[ November 20, 2008: Message edited by: harsha galla ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Go to your server's logs and find out what line of code is throwing the NullPointerException (NPE).

If that doesn't make it clear what you need to do, post the relevant section of code, along with something that lets us know which line is throwing the NPE and we might be able to help you.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
I am guessing that in the line:

pw.print(xx);

xx is in fact a null reference. How are you checking that it is not?

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem sending a string as Http response