Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7030433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:40:12+00:00 2026-05-28T00:40:12+00:00

I want to create a small java application in order to communicate with an

  • 0

I want to create a small java application in order to communicate with an HTML server: I need to POST a form and GET results, in HTML
Using Wireshark, I caught the content of the package I should send. It’s something like this:

__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwU[..]
[...]__EVENTVALIDATION=%2FwEWJAK9%2Fu[...]
TxTNumeroPalina=3329&ListaLocalit%C3%A0=NAPOLI&TxTViaInteresse=&TxTCAP=&BtnInviaDati=Invia+Dati

Where dots stand for other random chars.
I should receive back a page containing some timelines for buses. I tried this way.

String eventTarget = "__EVENTTARGET" + "=" + "&";
String eventArgument = "__EVENTARGUMENT" + "=" + "&";
String viewState = "__VIEWSTATE" + "=" + "%2FwEPDwUJMj[...]";
String eventValidation = "__EVENTVALIDATION" + "=" + "%2FwEWJ[...]";

String eventObjects = eventTarget + eventArgument + viewState + eventValidation;

//form parameters
String numeroPalina = "TxtNumeroPalina" + "=" + "3329" + "&";
String listaLocalita = "Listalocalit%C3%A0" + "=" + "NAPOLI" + "&";
String viaInteresse = "TxtViaInteresse" + "=" + "" + "&";
String cap = "TxtCAP" + "=" + "";
String sendButton = "BtnInviaDati" + "=" + "Invia+Dati";
String locatorObjects = numeroPalina + listaLocalita + viaInteresse + cap;
String newData = URLEncoder.encode(eventTarget + eventArgument + viewState + eventValidation + locatorObjects, "UTF-8");

URL infoclickUrl = new URL("http://www.anm.it/Default.aspx");
HttpURLConnection connection = (HttpURLConnection)infoclickUrl.openConnection();
connection.setDoOutput(true);
HttpURLConnection.setFollowRedirects(true);
connection.setRequestMethod("POST");

OutputStreamWriter streamWriter = new OutputStreamWriter(connection.getOutputStream());
streamWriter.write(newData);
streamWriter.flush();
BufferedReader streamReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
String page="";
while ((line = streamReader.readLine()) != null) {
page += line;
}

streamReader.close();
streamWriter.close();

I can never get a correct result from it! What’s wrong with it?

—> Edit:
In http://www.anm.it/Default.aspx you can compile a form with a certain bus stop, send it and get in return the timetable of the selected bus stop (arriving buses). So, I should receive an html page with the result of my query in it (if I send the form via browser, it works). With the code I wrote, I get back just an html page containing the initial page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:40:13+00:00Added an answer on May 28, 2026 at 12:40 am

    You are not handling cookies in your java code. Try using firefox’s live http header addon and see what all data is exchanged between the browser and server. Try sending the below given cookie from your java code.

    Cookie: ISAWPLB{6DC6CE50-2F43-4F96-92BC-840EFF24E706}={23855B49-8C3B-43BA-B5FB-41A85FDD9F3C}

    I still believe you should use Apache HttpClient for your aplpication.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a Java application bundle for Mac without using Mac. According
I want to create a small java application to copy some wiki content from
i want to create functions what get the folder size. I write small function:
I want to globalize my application. I have created a small form which asks
I want to create a simplest remote desktop application using p2p communication. I did
I want to create a browser based 3D game using LWJGL with the Java
I'm writing a small demo application in Java using Spring, that needs to have
I'm working on a client-side Java application for which I want to create a
I have created a small web application in java. And now I want to
I am trying to create an HTML GUI for an application using Qt's WebKit...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.