Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

apache common httpclient response as xml

 
Mahfuzul islam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Experts,

I am calling a web using apache common httpclient as below:



The servlet output I am getting :

Length:299
Contents: 001

Only the xml attribute value.


the link (https://example.com/type.php?id=10) i am calling normally return a xml like:




How can i get the complete XML using ResponseHandler<String> responseHandler = new BasicResponseHandler();??

Thanks!

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to make sure: that isn't a web page where you're printing this to, which might be swallowing XML elements?

The numbers aren't attributes, by the way, they're content. In "<a b="c">d</a>", "b" is an attribute name, "c" is its value, and "d" is content.
 
Mahfuzul islam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the i am printing this in webpage using out.println

The numbers aren't attributes, by the way, they're content. In "<a b="c">d</a>", "b" is an attribute name, "c" is its value, and "d" is content.

-- yes agreed. thanks for correction.

My ultimate target is to get the complete xml using ResponseHandler<String> responseHandler = new BasicResponseHandler()

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you have examined the source of the web page, and it really contains just the numbers, not the XML markup?
 
Mahfuzul islam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i put the link in browser address bar and go ( https://example.com/type.php?id=10)


I got a XML like below format. No doubt it is returning XML:




I am not sure my servlet code




or any other need to use.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question wasn't about what happens when you go to that URL in a browser, it was about what happens with the response you're getting programmatically. Where are you printing that - from your answer I assumed to a web page; is that not correct? If it is, have you looked at the source code of that web page to see whether it contains XML markup?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not following this thread 100% but I think that you have to set the response type to text/xml or application/xml?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64982
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is that the OP is using the browser display to view the results, and of course, that's nonsense because the browser will interpret the output as HTML, not XML. What the browser shows is irrelevant in this case.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic