简体   繁体   中英

HTTPURLConnection result in struts2

I want to return HttpURLConnection result as a Struts 2 result type.

Can you suggest how to do?

Actually I want to fetch JSP Page from other server using HttpURLConnection , then that page need to display.

How to do?

Based on your comments, you simply want to pass-through the already rendered content from the remote server when your Struts2 action returns.

Since the JSP has already been rendered, all you need to do is to set your Struts2 action result type to use stream and simply return the content of the rendered JSP you obtained from your HTTPUrlConnection appropriately.

<action name="yourAction" class="com.yourcompany.YourAction">
  <result type="stream">
    <param name="contentType">text/html</param>
    <param name="inputName">jspResponse</param>
  </result>
</action>

Then your action simply needs to expose your InputStream with a getter getJspResponse() since we've specified the property to get as jspResponse .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM