aspose file tools*
The moose likes Struts and the fly likes Forwarding to external URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Forwarding to external URL" Watch "Forwarding to external URL" New topic
Author

Forwarding to external URL

Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Hi All,

I have a requirement, where I'm supposed to use pdf reports generated on an
external reports server. Now the problem is, how do I fire a forward to an
external url? By external url I mean a fully qualified url like

http://xyz.com/repsrver/reports=myrep?param1=val

I could have easily embeded a static link, but for generating reports, some
parameters are supposed to be gathered from request and some other
business processing is also required. Hence this operation, IMHO, is best
suited through an action.

I also thought of firing a sendRedirect and returning null, but that
exposes the url, reveleaing some of the sensitive parameter.

Please throw some light on this. I'm in bad need of this.

Thanks and regards,
Kinjal Sonpal
[ May 20, 2004: Message edited by: Kinjal Sonpal ]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
I think, you can use hyperlink for solve this problem. like this



SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Well, I thought of using hyperlink in a jsp as the first choise. But the problems is that I have a flow like this.

Form submit -> validate -> process -> fetch more data from other layers -> process -> forward to report server

Though it may be done in a jsp page, I would want to avoid it.
[ May 21, 2004: Message edited by: Kinjal Sonpal ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Kinjal Sonpal:
I also thought of firing a sendRedirect and returning null, but that
exposes the url, reveleaing some of the sensitive parameter.

If you're worried about exposing the URL, would it be possible to "proxy" the request i.e. make a new HTTP request to the report server, wait for the response, and then produce the final response to the end-user?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
If you think you will submit some data each time, will you consider to store those parameters inside an ActionForm?



Thus, inside your JSP, you can always do this:


Then, when the user clicks the submit button, you can use JavaScript to set the corresponding parameters to the form before submit:

Then, the query string will not be shown in the browser.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Originally posted by Lasse Koskela:

If you're worried about exposing the URL, would it be possible to "proxy" the request i.e. make a new HTTP request to the report server, wait for the response, and then produce the final response to the end-user?

Can you please elaborate this idea more clearly? The idea seems to suit my needs since I would also want the reports to be logically modal in nature, rather than having no control over it's output.

Nick, as you have shown in the sample code, it would have been my first choice; but I also need some more data from other layers, being fetched based on the form submitted by the user. So, yes I can put all that processing inside the jsp page, but I think it may not be a very welcome idea from design and maintainance point of view.

Thanks and regards,
Kinjal Sonpal
[ May 21, 2004: Message edited by: Kinjal Sonpal ]
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
The proxy pattern is that, you have an object, say X, which knows how to redirect the request to the server, on receiving the client's request.

For example, what the client need to do is, catpuring all data needed, and the sends them to object X. Object X then processes the data, and generate the connection URI, and then finally forward the request to the server.

Thus, the client only needs to cater for the data, without knowing how the request to be fired to the server end.

If you need other processing, then Struts' ActionForm may not be that suitable for you, as every time, you need to store the data in the Form, until you submit the data to the server.

Nick
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Nick,

Thanks a lot for that explanation. At the time of posting, I was looking for some code based illustrations. But anyway, I think it's always better to implement things by self (whenever possible), than look out for help. Sometimes, I tend to become a little lazy. I'm working on it and will soon post my experience about this.

Thanks and regards,
Kinjal Sonpal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forwarding to external URL