By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,496 Members | 1,268 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,496 IT Pros & Developers. It's quick & easy.

Struts for multiple output types

P: n/a
Good afternoon...

I'm new to struts so I hope I'm not asking an obvious question, but so
far I haven't found my answer in any book, web site, or google search.

I need to develop an application that outputs primarily in XML (for
another application), but also in HTML. I'd like to use the same
logic (Actions and Forms) but how do I set my forwards to forward to
the correct JSP for the output type?

Or do I do that in my JSP? Can I set the Page Directive's contentType
to be a bean value or some other variable? And then put logic
sections in my JSP to output one or the other format?

Thanks.

Eric Schultz.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Eric,
I had to do a similar thing and ended up putting the contentType
directive in JSP. All of my processing is still done in Strut's Action
but the JSP displays the actual data.

Here is what I did
<%@ page contentType="text/xml" %><%
%>
Make sure you don't put any spaces between the contentType tag and the
body tag. Your XML parser might get confused with extra CRLF characters.

Pete
--

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account for free
<http://www.spammarshall.com>

Eric Schultz wrote:
Good afternoon...

I'm new to struts so I hope I'm not asking an obvious question, but so
far I haven't found my answer in any book, web site, or google search.

I need to develop an application that outputs primarily in XML (for
another application), but also in HTML. I'd like to use the same
logic (Actions and Forms) but how do I set my forwards to forward to
the correct JSP for the output type?

Or do I do that in my JSP? Can I set the Page Directive's contentType
to be a bean value or some other variable? And then put logic
sections in my JSP to output one or the other format?

Thanks.

Eric Schultz.

Jul 17 '05 #2

P: n/a
I worked on an app where all the business logic was in the struts action
classes. I know it was a misuse, but the struts pattern falls short as it
invites and allows such a travesty. Struts adds yet another layer of
complexity and buys you a framework which may or may not be of any use.
"Petarian" <pe******@Hotpop.com> wrote in message
news:3F**************@Hotpop.com...
Eric,
I had to do a similar thing and ended up putting the contentType
directive in JSP. All of my processing is still done in Strut's Action
but the JSP displays the actual data.

Here is what I did
<%@ page contentType="text/xml" %><%
%>
Make sure you don't put any spaces between the contentType tag and the
body tag. Your XML parser might get confused with extra CRLF characters.

Pete
--

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account for free
<http://www.spammarshall.com>

Eric Schultz wrote:
Good afternoon...

I'm new to struts so I hope I'm not asking an obvious question, but so
far I haven't found my answer in any book, web site, or google search.

I need to develop an application that outputs primarily in XML (for
another application), but also in HTML. I'd like to use the same
logic (Actions and Forms) but how do I set my forwards to forward to
the correct JSP for the output type?

Or do I do that in my JSP? Can I set the Page Directive's contentType
to be a bean value or some other variable? And then put logic
sections in my JSP to output one or the other format?

Thanks.

Eric Schultz.

----------------------------------------------------------------------------
----

Eric,
I had to do a similar thing and ended up putting the contentType directive in JSP. All of my processing is still done in Strut's Action but the JSP
displays the actual data.
Here is what I did
<%@ page contentType="text/xml" %><%
%>
Make sure you don't put any spaces between the contentType tag and the body tag. Your XML parser might get confused with extra CRLF characters.
Pete

--

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account for free


Eric Schultz wrote:

Good afternoon...

I'm new to struts so I hope I'm not asking an obvious question, but so
far I haven't found my answer in any book, web site, or google search.

I need to develop an application that outputs primarily in XML (for
another application), but also in HTML. I'd like to use the same
logic (Actions and Forms) but how do I set my forwards to forward to
the correct JSP for the output type?

Or do I do that in my JSP? Can I set the Page Directive's contentType
to be a bean value or some other variable? And then put logic
sections in my JSP to output one or the other format?

Thanks.

Eric Schultz.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.