Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Read Return URL From URLConnection  RSS feed

 
Tim Hagerty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have researched this but I can't seem to find an answer. So I must turn to the Guru's.
Does anyone know how to read a return URL after

//example - actual url has params and all.
URL u=new URL("http://www.msn.com");
URLConnection uc=u.openConnection(); is made.
I have an app that does credit card processing and I need to send a url with the customers info and then I get a return url telling me if the transaction is compete or not.
I can read the content of the page just fine but I need to be able to parse the return url.
Any help would be much appreciated.
Thanks,
Tim
 
Chris Smith
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "return URL"?
 
Tim Hagerty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the term "return url" I am referring to the url or query string the credit card processing company will be returning to me.
For example:
I will send:
https://www.creditcard.com?cardnum=41111111111&name=John User&amt=57.00
and after the credit card processing company processes this request they will send back:
https://www.mysite.com?status=approved&message=data match
I hope this explains it clearly enough.
Thanks for your response,
Tim
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in case i understand your question right...
request.getRequestURL().toString() will give you the url from which the request was made...
but still, i didn't really understand what do you want to do
[ March 25, 2003: Message edited by: Asher Tarnopolski ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Requests don't return URL's, they return responses. Are you saying that when you hit the URL of the cc company that they return a response that contains a URL as its body?
also confused,
bear
 
Tim Hagerty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really sorry for the confusion, it's not a usual process so here's an example of what happens:
Customer enters their credit card info thru my site and clicks the submit button.
I am using struts in my app so this form post is sent to it's ActionForm then to the Action object that it's tied to. This is where I call the URL object and send a "Get" thru the URL object using URLConnection to my creditcard processing company with the info the customer gave me.
example:
URL u=new URL("https://creditcardprocessing.com?c_info=Card Name&C_number=4111111111111111&C_exp=012005&T_code=02&T_amt=1.00");
URLConnection uc=u.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setUseCaches(false);

The creditcard processing company then sends a response back to me with codes in the return url - or querystring - whatever you like to call it - URI if that helps - that tells me if the transaction succeeded or failed. There is no content in the body in the return from the creditcard company, all of the information I need is contained in the return url seperated out by params: approved=no&message=OverLimit... basicly the ccprocessing company manipulates the url before it sends it's response back to me.
The trick is, Since I am initiating this post is this manner I need to be able to read the response url. This is where I'm stumped.
I can do it just fine in asp or jsp or even php but I want to stick with my paradigm and handle the communication from the action object.
Any help or feedback is welcome, I want to learn.
Tim
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does this "return URL" look like?
Normally when you send a request with a URL you get back a response that you can read as an InputStream - see the JavaDocs for URLConnection.
Like

Bill
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what he's trying to get at is that the processor does some work, then does a sendRedirect. He can read the response page (because that's the end result with follow redirect enabled) but he doesn't know the final URL that he was redirected to.
I would check the response message using getResponseMessage()
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!