• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP client HTML vs XML Response  RSS feed

 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
i'm using appache commons http client to send HTTP post queries to a given url and receive HTTP response then process it.
one of the requirements of my Application is the following:
one of these HTTP Post methods is supposed to return an HTML form with different html types (text filed, text area etc..) that i will need to display in my swing application. one important function is that i can't know in advance what the html form types will be ; it depends on a given parameters that my application send as part of HTTP Post method (using apache http client).
i thought of two possibilities :
1-the http method returns html String with all form fields that i can render in my java application using a JEditorPane : the draw back of this solution is that when user fills the html form inside JEditorPane , my application will need to send a HTTP POST method with parameters the values filled in from by user. I'm not sure if there is a way JEditorpane can detect what html types are in html form and what are their values . i doubt JEditorPane can do this work ,unless i parse the html content inside JEditorpane. what you think ? how can i post the html form in JEditorPane and recieve http response from sending this html form inside my swing app?
2-second solution : the http method returns an xml string that i parse and then i will need to map the xml fields (representing html form types) to corresponding swing components . it's sort of xml to swing conversion work.
Now I'm not sure what is easier and better solution from the 2 above ? is it better to receive html stream or xml stream which contains html form types ?
any Ideas how to handle this problem would be very welcome.

thanks
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "Hamza Hamza"-

It's a bit unusual to have the same first and last name. We have a policy on screen names here at JavaRanch that states it must consist of a first name and a last name. Unles you really have the same forst and last name, please take a moment to change it, which you can do using the "My Profile" link at the top of the page.

As to your question, why are you using HttpClient? I believe the JEditorPane -limited as it is- can access URLs and POST to them just fine. There are more fully featured Java browser components, though - check out Lobo on SourceForge.
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Hello "Hamza Hamza"-

It's a bit unusual to have the same first and last name. We have a policy on screen names here at JavaRanch that states it must consist of a first name and a last name. Unles you really have the same forst and last name, please take a moment to change it, which you can do using the "My Profile" link at the top of the page.

As to your question, why are you using HttpClient? I believe the JEditorPane -limited as it is- can access URLs and POST to them just fine. There are more fully featured Java browser components, though - check out Lobo on SourceForge.


thank you for pointing out Lobo browser.I just think i will consider using it to make my life easier.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!