0

i'm using apache HttpClient's GetMethod to get the contents in URL.That url contains nothing but 2 directories under it. My requirement is to read those directory name and displaying it.

I'm getting html source of that page as response, something like this

< ul>
< li >< a href="libraries/" >libraries /< /a>< /li>
< li >< a href="services/">services/< /li>
< /ul>

I feel, the response in the XML format or Json will be easy to use. Is there anyway to get the response in json/xml format?

I tried changing the content-type that didnt help

Jeevi
  • 2,962
  • 6
  • 39
  • 60

1 Answers1

2

The format of the response is the responsibility of the server not the client.

The client can only state in what format he would like the response and if the server supports it the client will get it in the wanted format.

Tomer
  • 17,787
  • 15
  • 78
  • 137
  • If client is requesting text/json format.. and server return the response in HTML(text/html).. can the client recieve the html response without any issue? – Jeevi Jul 12 '12 at 09:44
  • Depends on how you ask it, If your using jquery for example and state that you want the answer in a certain format and get another, i think it will cause problems. also the Content-type header should be application/json not text/json. – Tomer Jul 12 '12 at 09:46
  • 2
    The server sends a `content-type` in its response header to the client (e.g. `application/xhtml+xml` or `text/html`). Depending on that, the client can decide if he can process the answer or not. – Jan Gerlinger Jul 12 '12 at 09:47
  • Yes.. I'm getting content-type as text/html... I hav read Http protocol 1st i think :) – Jeevi Jul 12 '12 at 09:49