Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fake a post request from java class

 
hura fly
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4517
280
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"hura no name", please check your private messages regarding an important administrative matter.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too many comments :(
 
Tushar Kapila
Ranch Hand
Posts: 35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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






 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic