How to query an aspx page using JAVA post request?

I need to fetch some information from an aspx page http://www.buckeyetraffic.org/reporting/roadActivity/roadActivitySearch.aspx 
within my java code. For example, I need to get the page source  when I submit a query with the option "roadwork-planned" in the Category form selected.  I find some samples dealing with asp pages using post request but no one with aspx pages.  
rnicholusAsked:
Who is Participating?
 
CEHJCommented:
There should be no difference in terms of client code. See http://www.exampledepot.com/egs/java.net/Post.html
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
objectsCommented:
you would access it the same way you would access any page as you are just making a http request, how it (the page) is generated is irrelevant for your perspective.
For what you want you should look at httpclient as ysnky has suggested, or httpunit. These will allow you to easily make form selection and submission.
0
 
rnicholusAuthor Commented:
What I'm wondering is how to do this:

Let say I want everything from IR-270. Some people recommend I need to use the VIEWSTATE variable like below, but it doesn't work.

http://www.buckeyetraffic.org/reporting/roadActivity/roadActivitySearch.aspx?lstMacroRouteSelection=IR-270&__VIEWSTATE=/wEPDwUKMjAwMTU5NDg2NWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFEmxzdFN0YXR1c1NlbGVjdGlvbhNKS1N9Jwso6jLuGfB7Eez/3pv3
0
 
CEHJCommented:
You simply have to pass the parameters as a browser would, along with the cookies. I'd recommend using a proxy to view this, so you can ape it accurately
0
 
rnicholusAuthor Commented:
It doesn't work. Ideally I should be able to run this into browser and it will give me the result:

http://www.buckeyetraffic.org/reporting/roadActivity/roadActivitySearch.aspx?__EVENTTARGET=lstMacroRouteSelection&__EVENTARGUMENT=IR-270&__VIEWSTATE=/wEPDwUKMjAwMTU5NDg2NWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFEmxzdFN0YXR1c1NlbGVjdGlvbhNKS1N9Jwso6jLuGfB7Eez/3pv3

I found the solution below somewhere in experts-exchange. There is someone that wants to understandn how to go to second page of "View friends" list. And the solution works. But in my case, it doesn't work.
0
 
rnicholusAuthor Commented:
The "View friends" list that I'm talking about is for MySpace. Sorry I forgot to post it in my last post.
0
 
CEHJCommented:
If you do everything that the browser does, then it will work ;-)
0
 
CEHJCommented:
You can't just concoct your own URL + query string and expect it to work. You need to follow through what *does* make it work in a browser
0
 
rnicholusAuthor Commented:
That's what I'm trying to figure out right now. How to make it work in a browser first.
0
 
CEHJCommented:
You must use the browser as normal and monitor what it does as i mentioned
0
 
objectsCommented:
get to the page using a brower, then use httpunit or httpclient as mentioned above to repeat those steps. don't need to worry too much about the hows, just the steps, the api's will allow you to recreate your steps

0
 
rnicholusAuthor Commented:
The vaules of above VIEWSTATE and EVENTVALIDATION may change with time. Therefore we need to replace them with the current values.
0
 
CEHJCommented:
>>Therefore we need to replace them with the current values.

OK - so what is the problem there?
0
 
rnicholusAuthor Commented:
The problem has been solved by using above query string with real time VIEWSTATE and EVENTVALIDATION values. Thanks!
0
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.

All Courses

From novice to tech pro — start learning today.