Obtaining data from website url via GET/POST

How do i code my program to obtain data via HTTP from a url for example:
http://www.goldencasket.com/results/search.asp

Have it able to virtually search for results on this url and retrieve
the results to and from my program?

Any ref urls or sample codes with explanations will help.

Thanks!
jedistarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mayank SAssociate Director - Product EngineeringCommented:
You can read from a URL using this:

http://www.javaalmanac.com/egs/java.net/ReadFromURL.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jedistarAuthor Commented:
anymore samples?
0
jedistarAuthor Commented:
what are the basic functions i need?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Mayank SAssociate Director - Product EngineeringCommented:
For simply reading text from a URL, that is simply all you need. I can post more samples but effectively they will do the same thing. Did you try to run the example and see if it works? If you want to ask more about your application (in your Swing/ J2ME question), then post there.

>> Have it able to virtually search for results on this url and retrieve the results

I don't know what results you want to search from the URL. You'll probably need to remove the HTML tags from it for processing it further. If the URL needs a POST request, you need to send a POST request and then read the response:

http://www.javaalmanac.com/egs/java.net/Post.html
0
jedistarAuthor Commented:
seen all, thanks.

what abt sample programs that does this?
i want to see how do i use it in my prog
0
Mayank SAssociate Director - Product EngineeringCommented:
That's how, create a class with a main () method and call these methods from that one.
0
jedistarAuthor Commented:
yeah cool
how abt parsing the data, i.e sending a post request
and decoding the return data
how do i do this?
0
hoomanvCommented:
> how abt parsing the data

use an an HTML parser
http://javaalmanac.com/egs/javax.swing.text.html/pkg.html
0
jedistarAuthor Commented:
(Question up to 500 points)

back to my original question.

How do i create the form exactly like in http://www.goldencasket.com/results/search.asp
using NetBeans..

How do i code the form to send/receive data, perform same function as
http://www.goldencasket.com/results/search.asp
0
hoomanvCommented:
you can create forms with GUI designer
here you can learn how to do that
http://www.netbeans.org/kb/50/quickstart-gui.html

0
jedistarAuthor Commented:
hoomanv : done that, i created the swing form like the web form.
done.

How do i code the form to send/receive data, perform same function as
http://www.goldencasket.com/results/search.asp
0
hoomanvCommented:
look at the page source code

<form name="draw_search" method="post" action="/results/search.asp">

you should POST data to http://www.goldencasket.com/results/search.asp

what data ?

any input filed between <form> and </form> like the values of all 7 option boxes and one textfiled

if you are not familiar with http connection and POST method you can start here
http://www.javaworld.com/javaworld/javatips/jw-javatip34.html
http://developers.sun.com/techtopics/mobility/midp/ttips/HTTPPost/
0
hoomanvCommented:
also this is good to learn the basics
http://www.devx.com/Java/Article/17679/1954?pf=true
0
jedistarAuthor Commented:
the data such as the fields on http://www.goldencasket.com/results/search.asp
i have seen the links, i still do not understand.. can someone show me samples
on how do i post the fields and parse the incoming data to display on my swing form
0
hoomanvCommented:
lets have an example
when a user visits that site, there is a form that is waiting to be filled by user
he selects the Game Type: Saturday Gold Lotto Results
and also types in the Draw number: 3

when he presses the search button, some data would be posted to the server (http://www.goldencasket.com/results/search.asp)

the post data is exactly like this

Game=SatGoldLotto&drawDate_fromDay=7&drawDate_fromMonth=11&drawDate_fromYear=2005&drawDate_toDay=7&drawDate_toMonth=5&drawDate_toYear=2006&draw_num=3&Searchs=Searchs

if you look at the source code of the page you'll find what are these [key=value] pairs meaning
your swing app should exactly do this, mean that it should get the form data and generate a query like the above and then post it to server

http://homel.vsb.cz/~dvo25/reily/books/javaenterprise/servlet/ch10_02.htm
in this link read HttpMessage code, I this is what you want
0
jedistarAuthor Commented:
which number is that in the url doc?
0
hoomanvCommented:
> which number is that in the url doc?
what ?
0
jedistarAuthor Commented:
which numbering in this url http://homel.vsb.cz/~dvo25/reily/books/javaenterprise/servlet/ch10_02.htm
that parses the key values etc?
0
hoomanvCommented:
I told you read the source code of HttpMessage there, it provides a general way for sending parameters as post data
what do you mean "which numbering"
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.