Forums Register Login

URLConnection question, Posting

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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

+Pie Number of slices to send: Send
basically I used two forms on my page and it solved my problems. Never even thought of the simplest way....
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1570 times.
Similar Threads
closing streams
Servlets example
Accessing servlets using URLConnection
Streaming Video Through a Servlet (.wmp)
Connection in servlets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:25:50.