• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLConnection question, Posting

 
B Wiley Snyder
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm using the code below to post to an address using URLConnection.

But I need it to show up in the address area. I can't send a doGet request and I was wondering if there was a work around or something that would just change the URL to the actual URL it is posting to.



Thanks in advance
 
B Wiley Snyder
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I cannot seem to get an answer for this question. Is it a stupid question? If so, if you could explain why it is that would be great.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand this part of your problem:
But I need it to show up in the address area.


It looks like you want the servlet to handle a GET request by opening a connection to another site and doing a POST. Is that right?
If so, what is actually happening when you try it?

On the other hand, if you are trying to send the user's browser to another URL, that is the response sendRedirect method, which can only do a GET.
Bill
 
B Wiley Snyder
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
I don't understand this part of your problem:


It looks like you want the servlet to handle a GET request by opening a connection to another site and doing a POST. Is that right?
If so, what is actually happening when you try it?

On the other hand, if you are trying to send the user's browser to another URL, that is the response sendRedirect method, which can only do a GET.
Bill


I just want this url URL theUrl = new URL("https://foo.foo.com/getPost");
in the address area. That is where it is going anyway but it is stuck in the servlet calling post. So, when I go to localhost:8080/ThisServlet(ThisServlet being the code above. It posts and gets a response from foo.foo.com but the address stays localhost:8080/ThisServlet like it is supposed to do. I want to put foo.foo.com in the address area without posting it. Can I re-write it somehow or am I just stuck with get, I'm sure I probably have to do it with get.

The reason I am doing this:
I have site A, not secure(http) posts info to site B(https). I wanted https to show up in the URL so it does not look like it is not a secure site. I wanted to use post becuase I wanted to pass a session variable to site B. Which I cannot pass a session variable from one domain to another in my situation.

I'm sure I'll just use doGet() and load the variables that way instead of post, I just thought it might be possible to do it the other way....

thanks

 
B Wiley Snyder
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
basically I used two forms on my page and it solved my problems. Never even thought of the simplest way....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic