Solved

How to query an aspx page using JAVA post request?

Posted on 2007-12-06
17
942 Views
Last Modified: 2008-02-16
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.  
0
Comment
Question by:rnicholus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 2
  • +1
17 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 20422264
There should be no difference in terms of client code. See http://www.exampledepot.com/egs/java.net/Post.html
0
 
LVL 9

Expert Comment

by:ysnky
ID: 20423661
0
 
LVL 92

Expert Comment

by:objects
ID: 20423826
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
Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

 

Author Comment

by:rnicholus
ID: 20451964
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 20452020
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
 

Author Comment

by:rnicholus
ID: 20465365
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
 

Author Comment

by:rnicholus
ID: 20465408
The "View friends" list that I'm talking about is for MySpace. Sorry I forgot to post it in my last post.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20465418
If you do everything that the browser does, then it will work ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20465542
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
 

Author Comment

by:rnicholus
ID: 20465648
That's what I'm trying to figure out right now. How to make it work in a browser first.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20465764
You must use the browser as normal and monitor what it does as i mentioned
0
 
LVL 92

Expert Comment

by:objects
ID: 20468708
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
 

Accepted Solution

by:
rnicholus earned 0 total points
ID: 20663931
0
 

Author Comment

by:rnicholus
ID: 20665456
The vaules of above VIEWSTATE and EVENTVALIDATION may change with time. Therefore we need to replace them with the current values.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20666931
>>Therefore we need to replace them with the current values.

OK - so what is the problem there?
0
 

Author Comment

by:rnicholus
ID: 20725627
The problem has been solved by using above query string with real time VIEWSTATE and EVENTVALIDATION values. Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question