473,668 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Struts for multiple output types

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
2 3066
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="te xt/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.spammarshal l.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
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******@Hotpo p.com> wrote in message
news:3F******** ******@Hotpop.c om...
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="te xt/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.spammarshal l.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="te xt/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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1385
by: Alessandro 'Aronnax' Rossini | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, my name is Alessandro Rossini and I want to let you know the launch of a new project called ZNF. The goal of this project is to provide an open source framework for building PHP5 enterprise web applications. It's based on the Apache Struts project of the Apache Software Foundation, available at http://struts.apache.org/. This is not the first attempt to rewrite the Struts implementation,...
1
3605
by: Glen | last post by:
I have a list of beans that I retrieved from a database. These beans are all of the same class. Now I want to display these beans in a struts form so that the user can modify the data in the beans and save it back to the database. Can anyone help with this problem? Is there any sample code out there that would show how to do this? Thanks
0
1800
by: James | last post by:
Hi everyone, I wanna put serveral multiple text boxes on page by logic:iterate in struts, and then get values of these multiple text boxes. But that makes me headache, Could anyone give me a hand?
9
6502
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key" labelProperty="value"/> In this case "key" is what I mean by "ID", and "value" is what I mean by "Value" -- the "Value" is shown to the user, but the "ID" is what I plan to keep, to be saved to a database (as a reference in a table to a common table as a part of...
4
10666
by: randy.p.ho | last post by:
Using JDBC, is there a way to call a stored procedure with multiple return values? Thanks.
1
3067
by: pxm4 | last post by:
I'm working on a Content Management Server project developing a MVC based on a dynamic place holder control. One thing that I have some questions about is session management. What I would like to do is mimic the behaviour found in the helper bean in Stuts, BUT make it more generic. I would like to create a class that stores mulitple collections or strings based on a generic add method. Can generics do this? This way I can add collections...
5
5391
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in separate files for ease of maintainability. These schemas are all part of the same namespace. When defining a web service that access more than one of these entities, the wsdl file generated by BEA contains multiple schema elements with the same...
1
2787
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader delegate: false repositories:
1
11525
by: NamelessNumberheadMan | last post by:
I can't seem to get Struts 2 validations to work. I have been converting from Strust 1 to Struts 2. So far I've refactored all the code (for this particular module) on the back end, rewrote the jsp using Struts 2 notations, and wired up the xml (aside from the abc-validation.xml). Everything runs just fine. If there is an error not generated by user input (i.e. file format problem) I can get that message to come out, so I know my error messages...
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.