It's not a secret anymore!*
The moose likes Struts and the fly likes Send/Receive HTTP from Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Send/Receive HTTP from Action" Watch "Send/Receive HTTP from Action" New topic
Author

Send/Receive HTTP from Action

JD Thompson
Greenhorn

Joined: Jun 29, 2006
Posts: 21
Basic Project Flow:
1. User selects a report name (reportList.jsp)

2. ReportListAction then populates the ReportListForm with the appropriate parameters to be selected (optional) or filled out (mandatory)

3. reportList.jsp is redisplayed (tiles configuration)with a new visible section for the user to enter parameter choices, user submits

4. ReportListAction recognizes the submittal and is suppose to do the following:

-> create an URL to submit to the Crystal Reports Server
-> submit URL
-> receive report response(suppose to be in HTML)
-> pass response through to a NEW browser window for viewing

PROBLEM STATEMENT:
How do I, internal to the ReportListAction, submit the URL? What general order do I need to follow? For example, do I create a HTTPClient and have that handle the request submittal and receive the response? Or should I use HttpURLConnection? I have looked over the APIs (HTTPRequest, HTTPClient, HTTPServletRequest, HTTPSession, etc.) but am not familiar enough with HTTP to know which to try first. This is my first time attempting to use HTTP.

ENVIRONMENT:
Developing in RAD, J2EE.

DISCLAIMER:
I was unsure as to which forum to initially post (I/O, Java Advanced, Struts) as the problem seems to touch all areas. Please accept my apology if I posted incorrectly.

Thanks for your input and advice!

JD


New Developer<br />Happy to learn what I don't know<br />Happy to share what I do<br />
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi Thomson

See you should use the URLConnection to connect to your server and get the response. But you must be sure of how to communicate to the Crystal reports . As far as i know its not HTTP thus there is no ? of using HTTPURLConnection.

Its just the same as connecting from Simple java program , but here you can get the outputStream from crystal reports in to the ServletOutputStream of the response.

hope you got what i said

Regards
Sreenath
JD Thompson
Greenhorn

Joined: Jun 29, 2006
Posts: 21
Hi Sreenath!!

Thank you very much for your reply. I will look into the URLConnection class and see how that works.

I believe I understood your advice in that I really don't have to worry about HTTP. Instead, just a straight URL with parameters.

I think I also understood that once I receive the response, use a ServletOutletStream to send to a new browser window.

Again, thank very much for taking time to help!!

Best regards!

JD
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
We do something similar, except with an IBI server, rather than Crystal reports.

Here's what I'd recommend:

1- In the reportList.jsp, specify target="_blank" in the <html:form> tag. This will ensure that the output is sent to a new window.

2- In ReportListAction, code the following:



That's it. The request will be passed on to the Crystal Reports URL and the response will be passed back to the browser in a new window. It doesn't have to be any more complicated than this.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Send/Receive HTTP from Action
 
Similar Threads
Do I need a separate Web Client?
how to find http response time
lost session object in new window
http client + thread save conn manager + execute get request time problems
storing multiple attributes for one entity