# Can this be done?

**URL:** <https://www.ruby-forum.com/t/can-this-be-done/99213>\
**Category:** Rails\
**Created:** [July 21, 2006, 12:48am UTC](https://www.ruby-forum.com/t/can-this-be-done/99213 "2006-07-21T00:48:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 21, 2006, 12:48am UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/1 "2006-07-21T00:48:06Z")

</div>

What I want: I get a normal http request containing a URL from a remote  
server.

Instead of redirecting to that URL, I want to load it into an iframe on  
an existing page.

I’ve tried a number of approaches with no success.

Can anybody suggest a good way to do this? Alternatively, if you can say  
“this is bloody impossible, because…”, that would be helpful, too.

–Al Evans

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 21, 2006, 3:55am UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/2 "2006-07-21T03:55:10Z")

</div>

Al Evans wrote:

> What I want: I get a normal http request containing a URL from a remote  
> server.
> 
> Instead of redirecting to that URL, I want to load it into an iframe on  
> an existing page.
> 
> I’ve tried a number of approaches with no success.
> 
> Can anybody suggest a good way to do this? Alternatively, if you can say  
> “this is bloody impossible, because…”, that would be helpful, too.
> 
> –Al Evans

Are you talking about a Websphere IFRAME? Or just using that  
terminology. I am not being able to understand what you mean by “want  
to load it into an iframe on an existing page”.

Please give details.

aj

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 21, 2006, 4:17am UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/3 "2006-07-21T04:17:24Z")

</div>

On 7/20/06, Ajaya A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > What I want: I get a normal http request containing a URL from a remote  
> > server.

in “I get” are you the browser or server?

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 21, 2006, 5:58am UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/4 "2006-07-21T05:58:16Z")

</div>

If you receive a request to \<[http://example.com/display/](http://example.com/display/)  
[remoteserver.com/remote](http://remoteserver.com/remote) page\>

then you can use:

map.connect ‘display/:remote\_url’, :controller =\>  
‘display’, :action =\> ‘index’

And in the rhtml do something like:

 

In reality, you’d want a function in the controller to make sure that  
the remote url is legal.

```
        - dan

```

–  
Dan K. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.dankohn.com/](http://www.dankohn.com/)tel:+1-415-233-1000

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 21, 2006, 11:27pm UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/5 "2006-07-21T23:27:54Z")

</div>

Dan K. wrote:

> If you receive a request to \<[http://example.com/display/](http://example.com/display/)  
> [remoteserver.com/remote](http://remoteserver.com/remote) page\>
> 
> then you can use:
> 
> map.connect ‘display/:remote\_url’, :controller =\>  
> ‘display’, :action =\> ‘index’
> 
> And in the rhtml do something like:
> 
>  
> 
> In reality, you’d want a function in the controller to make sure that  
> the remote url is legal.

Thanks, that works, as far as it goes. But I don’t seem to have been  
quite clear on what I’m trying to do. Here’s the sequence:

1. The user fills in a form and submits it.

2. The app processes the data from that form, and a URL is built.

3. The app does a redirect to that URL.

4. The remote server send back a normal http request. The parameters may  
signify correct completion, failure, or a need for more data from the  
user.

5. If the remote system needs more data, it sends along a URL for a form  
in which the user can provide that data. After he has done so, goto step

1. 

I am trying to make this look seamless, by handling the remote server’s  
request for more data in an iframe. But so far, I haven’t been able to  
master the flow of control, and keep everything happening on one (RJS  
updated) page. In particular, I can’t figure out how to respond with an  
RJS update when the remote server sends a normal http request.

I’m beginning to think I’m going about it all wrong, and it’s time for  
some serious redesign. I have no control over the remote server or its  
actions.

–Al Evans

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 22, 2006, 9:55am UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/6 "2006-07-22T09:55:55Z")

</div>

There may be some level of Javascript magic to do what you want, but  
I believe you are making this far harder than it should be.  
Fundamentally, the web architecture was not designed to allow a  
client to have asynchronous communications with two servers  
simultaneously.

My first choice would be to simply redirect the user to the remote  
server, and have them redirect them back to my server when they’re  
done. This is, for example, how PayPal works.

If that’s unacceptable, I would consider having your server act as a  
proxy between the client and the remote server. So, you pass through  
the clients request to the remote server, and then parse that remote  
server’s response and present it to the client. You can make  
everything AJAXy for the user, but our server has direct control over  
both sides.

In 4, I assume you meant to say: “The remote server send back a  
normal http response.” You’d need to be more specific if you want  
extra help.

```
        - dan

```

–  
Dan K. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.dankohn.com/](http://www.dankohn.com/)tel:+1-415-233-1000

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 21, 2006, 3:20pm UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/7 "2006-07-21T15:20:05Z")

</div>

You might find  
[http://javathehutt.blogspot.com/2006/07/rails-realities-part-15-ajax-modal.htmlvery](http://javathehutt.blogspot.com/2006/07/rails-realities-part-15-ajax-modal.htmlvery)  
useful.

On 7/21/06, Dan K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Dan K. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> > Instead of redirecting to that URL, I want to load it into an
> 
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
rm -rf / 2\>/dev/null - [http://null.in](http://null.in)

“Things do not happen. Things are made to happen.” - JFK

---

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [July 23, 2006, 2:46pm UTC](https://www.ruby-forum.com/t/can-this-be-done/99213/8 "2006-07-23T14:46:32Z")

</div>

Dan K. wrote:

> There may be some level of Javascript magic to do what you want, but  
> I believe you are making this far harder than it should be.  
> Fundamentally, the web architecture was not designed to allow a  
> client to have asynchronous communications with two servers  
> simultaneously.

You’re right. I can do it with Javascript, or by doing some ugly major  
surgery on ActionController, but I haven’t found any other way.

> My first choice would be to simply redirect the user to the remote  
> server, and have them redirect them back to my server when they’re  
> done. This is, for example, how PayPal works.

That’s my current plan. All I have to do is figure out how to make it  
_look_ seamless.

> In 4, I assume you meant to say: “The remote server send back a  
> normal http response.”

No, actually, it’s a normal GET. That’s the problem:-)

–Al Evans
