aspose file tools*
The moose likes Struts and the fly likes How to include the result of another URL into an Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to include the result of another URL into an Action" Watch "How to include the result of another URL into an Action" New topic
Author

How to include the result of another URL into an Action

Xiaoyang Du
Greenhorn

Joined: Dec 20, 2010
Posts: 3
I'm writting an Action and it needs to use the response from another URL (outside the site where the action resides). The URL I'm requesting returns a JSON string and I'm going to parse it and render my page based on its value. Could anyone tell me how to get the response from the URL outside my site? It seems that a RequestDispatcher cannot work since it cannot go outside the current context. Does Struts2 has a mechanism to do such job? Thanks in advance.

Plus: I'm not integrate the requested JSON into JSP using AJAX, I need to get it in Action, so any AJAX method seems not work for my case.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

URLConnection?


[How To Ask Questions On JavaRanch]
Xiaoyang Du
Greenhorn

Joined: Dec 20, 2010
Posts: 3
Yes, URLConnection can work. I still wonder whether struts2 has a simple method to accomplish this.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

Struts2 is an implementation of the FrontController pattern. It has no functionality for downloading data from other sites.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to include the result of another URL into an Action