• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fake a post request from java class

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm a new comer here, nice to meet you all. I have a problem and need your help.
I send a post request from my java class but the target page doesn't process my request.
This is my source code, I think there's no problem in my source:


and the url I use is:
http://noip.gov.vn/noip/feedback.nsf/frmFeedbackv3?OpenForm&Language=English
 
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"hura no name", please check your private messages regarding an important administrative matter.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a lot of code. What, exactly, happens if you run it? "doesn't process" gives us nothing to work with. Have you used an HTTP monitoring tool (like the Firefox extension LiveHttpHeaders) to observe how the HTTP sent by browser is different from the HTTP sent by your code?
 
hura fly
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:That's a lot of code. What, exactly, happens if you run it? "doesn't process" gives us nothing to work with. Have you used an HTTP monitoring tool (like the Firefox extension LiveHttpHeaders) to observe how the HTTP sent by browser is different from the HTTP sent by your code?


Sry for not very clear explaination.

When I run that code, the content of the response I get is the same as the page that contains the form.Let's say, I have a form A, I submit it with parameter then it should return me "Submit success" or "Submit failed". But what I receive is still the form A.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK.

Ulf Dittmer wrote:Have you used an HTTP monitoring tool (like the Firefox extension LiveHttpHeaders) to observe how the HTTP sent by the browser is different from the HTTP sent by your code?

 
hura fly
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:OK.

Ulf Dittmer wrote:Have you used an HTTP monitoring tool (like the Firefox extension LiveHttpHeaders) to observe how the HTTP sent by the browser is different from the HTTP sent by your code?



I've just install LiveHttp headers add-on.
When I submit form from firefox, I can see the sent data that I input the form. Then I clear the content of LiveHttp and run my java source -> nothing happens, the LiveHttp is empty.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Then I clear the content of LiveHttp and run my java source -> nothing happens, the LiveHttp is empty.


Of course it is. It's a browser plugin, so it can be used to monitor browser traffic, not any HTTP traffic originating from your machine. But you can use its output to compare it to your Java source code, to see whether that would generate the same output.

If you want to monitor all HTTP traffic, use an HTTP proxy.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too many comments :(
 
Ranch Hand
Posts: 36
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one of the problems is that you need to append the GET params (the name-value pairs after the ? mark in the target URL) in the post string too (see code lines 229 to 231 below) ...

good advice - if you have the time is to use: apache http client http://hc.apache.org/ . will be better in the long run ... more robust and covers more cases including file upload, authorization etc

if you do not want something so heavy can use this code






reply
    Bookmark Topic Watch Topic
  • New Topic