Two Laptop Bag*
The moose likes Servlets and the fly likes apache common httpclient response as xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "apache common httpclient response as xml" Watch "apache common httpclient response as xml" New topic
Author

apache common httpclient response as xml

Mahfuzul islam
Greenhorn

Joined: Jun 22, 2010
Posts: 16
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
Marshal

Joined: Mar 22, 2005
Posts: 42278
    
  64
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.


Ping & DNS - my free Android networking tools app
Mahfuzul islam
Greenhorn

Joined: Jun 22, 2010
Posts: 16
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
Marshal

Joined: Mar 22, 2005
Posts: 42278
    
  64
And you have examined the source of the web page, and it really contains just the numbers, not the XML markup?
Mahfuzul islam
Greenhorn

Joined: Jun 22, 2010
Posts: 16
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
Marshal

Joined: Mar 22, 2005
Posts: 42278
    
  64
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

Joined: Nov 08, 2003
Posts: 3479

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

Joined: Jan 10, 2002
Posts: 61426
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: apache common httpclient response as xml