• 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

Read Return URL From URLConnection

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "return URL"?
 
Tim Hagerty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic