Well, that does not cove what I need, since it can only include JSP or
servlet outputs from the server where Struts is running, and I need to be
able to access other pages.

Actually, what I need is to implement some kind of tunneling, so some
request from the browser to the front server will be redirected to the back
server. The idea is to have a separate mapping for that, so -let's say- any
request that starts with http://myfrontserver/myapp/myblog/* will be taken
from http://mybackserver/myblog/*. I don't mean redirected, I need my front
app to get the request page from the backserver, and send it back to the
browser, so it will be operating as a tunnel.

This is somehow different from the 'normal' situation in which there is a
front server (Apache, for example) that servers static content and a
application server(in this case WebLogic 10.3) that servers the
application's pages. In this case I also have a web server in the back, and
I need to provide access to it through my application server, since the
access to that server needs to be granted only to users logged into the
application.

So far I've created an Action that uses Apache HttpComponents to get the
requested resource from the back server and sends it back to the client
through a stream result.It also checks the content-type of the resouce, and
if it's a text resource, looks for any references to http://mybackserver, in
order to change it to http://myfrontserver/myapp before sending it to the
browser. It works fine, but needs some fine tuning to cover both GET and
POST, arguments, etc. I also think it can be refactored as a result, so it
could be generalized, and in that case I think it could be a nice feature to
add to Struts2, so I will be glad to share it.

Maybe there are other approaches to do this, so I'd appreciate any
suggestion you may have.

Thanks

Jose Luis



2011/8/27 Jeff Black <jeffrey.bl...@yahoo.com>

> JL,
>
> Have a look at the <s:include/> tag:
> http://struts.apache.org/2.2.3/docs/include.html
>
> From your post it sounds to me like it might do what you're looking for.
>  The following is an excerpt from *Struts 2 In Action:*
>
> *The include tag*
>
> Whereas JSP has its own include tag, <jsp:include>, Struts 2 provides a
> version that
>
> integrates with Struts 2 better and provides more advanced features. In
> short, this tag
>
> allows you to execute a Servlet API–style include. This means you can
> include the output
>
> of another web resource in the currently rendering page. One good thing
> about
>
> the Struts 2 include tag is that it allows you to pass along request
> parameters to the
>
> included resource.
>
>
> This differs from the previously seen action tag, in that the include tag
> can reference
>
> any servlet resource, while the action tag can include only another Struts
> 2
>
> action within the same Struts 2 application. This inclusion of an action
> stays completely
>
> within the Struts 2 architecture. The include tag can go outside of the
> Struts 2
>
> architecture to retrieve any resource available to the web application in
> which the
>
> Struts 2 application is deployed. This generally means grabbing other
> servlets or JSPs.
>
>
> Best,
>
> jb
> /
>
> ------------------------------
> *From:* "jlm...@gmail.com" <jlm...@gmail.com>
> *To:* Dave Newton <davelnew...@gmail.com>; Struts Users Mailing List <
> user@struts.apache.org>
> *Sent:* Friday, August 26, 2011 6:00 PM
>
> *Subject:* Re: Struts2 dispatch request to another application
>
> Well, I suppouse that's the only way, it's only that I thought somebody
> would have come with this problem early, and I wanted to know how, if so,
> they solved it.
>
> JL
> Sent via BlackBerry from T-Mobile
>
> -----Original Message-----
> From: Dave Newton <davelnew...@gmail.com>
> Date: Fri, 26 Aug 2011 18:54:18
> To: Struts Users Mailing List<user@struts.apache.org>; <jlm...@gmail.com>
> Subject: Re: Struts2 dispatch request to another application
>
> On Fri, Aug 26, 2011 at 6:51 PM, <jlm...@gmail.com> wrote:
>
> > I thought of that, but it doesn't work because the other server is not
> > available through Internet, only the first one. So I need to 'tunnelize'
> the
> > request from the browser to the other server thorugh my application.
> >
>
> If you're trying to make it look like the request is being served by your
> app, but coming from another one, then you'll basically need to use
> something like HttpClient to make the underlying request and stream its
> results back to the client of your app.
>
> Dave
>
>
>
>

Reply via email to