• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Java client querying web page  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a greenhorn. I'm an experienced (actually, just old) programmer, but new to Java. I've read Head First Java and am trying to muddle through some simple but real initial applications.

I'm looking for examples of simple java client apps that query (i.e. submit POST requests with form parameters to) web pages. I can find lots about writing servlets to respond to such requests, but haven't found anything that shows how to emulate a browser sending the request. (I have found examples of that perform GET operations by simply opening a URL stream.) Any suggestions on how to explore this functionality would be appreaciated. Thanks.
 
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the java.net.URL.openConnection() method.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might find the HttpClient toolkit useful for emulating the browser side of web application interaction. For example, it can handle cookies like a browser does.
Bill
 
Sheriff
Posts: 6920
 
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I second Franks suggestion of HttpUnit. Don't let the fact that it has its roots in unit testing turn you off - it is a very handy tool for accessing web pages, and it can even deal with simple JavaScript. It has its own API that lets you access the contents of the web page, but also presents that web page as a DOM object, so there are a number of possibilities for further processing.
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this has more to do with writing client code in Java than servlets, I'm going to move it to the "Sockets And Internet Protocols" forum.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!