Justin Wong
Justin Wong

Reputation: 1497

Returning XML from a JSP page in Struts

I'm developing an enterprise application whose main purpose is data retrieval. The user enters a URL ".../GetData.do" and the application returns an XML based on a schema containing the data.

Where is the best place to write the XML that would allow my to validate against the schema? In the Action class, the .jsp file, or somewhere else?

I'm using Struts 1 as my web application framework.

Thanks.

Upvotes: 0

Views: 455

Answers (1)

Bozho
Bozho

Reputation: 597422

You can do it in both places, depending on your preference.

For JSP there is the <x: prefix in JSTL. You just have to set the <%@ page contentType="text/xml" %>. I have never done it this way though

You can do it in the action, by writing the xml to the response writer (and again setting the content type).

However this is better done via some framework that can turn objects to xml (like JAXB or XStream).

Upvotes: 1

Related Questions