• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem regarding URLConnection

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

I am using URLConnection to connect to third party page. The code is as follows


This form submits to the specified url in the action
My problem is I want to access the values of this form after it submits, in the same java file.
Right now I am parsing the form in the while loop and retrieving the values.(that is bad approach)

I have a solution is that to shift this code into a servlet and mention action="http://ourhomepage.com/SomeServlet", I think this would solve the problem.
But if anyone knows a better approach for getting the data ... please do share it with me.

Is it possible to communicate with same connection multiple times?



Regards
Atul
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand you correctly, you are calling a third party web server and it's returning html. Of course this html must be parsed. Maybe you can use a XML parser since XML is supposed to be super-set of html. Also, can the third party create a web service for you?
 
Atul Prabhu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rovas,

Yes I am calling a third party page which submits it to a "specified url".I want to access the parameters that are hidden in the form.Parsing the form is not a good idea according to me.What I want is to access parameters in terms of request.So my question is can I get the parameters in the request object?

Actually I can get the parameters in the request object,i.e. in the "specified url". But can I get the response in the same java file given above ?
 
Rovas Kram
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Atul,

Using the URLConnnection, the output is an Outputstream which returns the html form. There is no response object so the html must be parsed. If you actually submit the form(i.e. from a browser), the parameters will be parsed by the server and put into a request object. But there is no 'request' object on the client side. Rememeber that HTML is a text based protocol and it must be parsed. There maybe a class out there that can parse a html document and then provide 'get' methods for accessing the default parameters and hiddenvalues of a form but I don't know of one.
 
Everybody's invited. Except this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic