Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to include the result of another URL into an Action

 
Xiaoyang Du
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9280
10
Linux Mac OS X Windows
 
Xiaoyang Du
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, URLConnection can work. I still wonder whether struts2 has a simple method to accomplish this.
 
Joe Ess
Bartender
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts2 is an implementation of the FrontController pattern. It has no functionality for downloading data from other sites.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic