Good evening...

Thanks, exactly what I needed.

Schultz.

-----Original Message-----
From: Adam Hardy [mailto:[EMAIL PROTECTED]
Sent: November 10, 2003 7:18 AM
To: Struts Users Mailing List
Subject: Re: Dynamic page contentType


On 11/10/2003 04:48 AM Eric SCHULTZ wrote:
> Do use the method below in my Action object?  And then use different
> Forwards depending on whether the result is to be in HTML or XML?  Or do I
> check in the JSP what my content-type is set to and output the correct
> output?
> 


Hi Eric,
yes, exactly. I would execute a block of code conditionally in my Action 
depending on whether you want HTML or XML. In that block you can set the 
content type via the  snippet I gave you below and fetch the appropriate 
forward.

I wouldn't use the content-type setting as a switch signal to the JSP, 
since it's possible to set it in other ways, e.g. in the config, so you 
may get unpredicted results.

Adam

> -----Original Message-----
> From: Adam Hardy [mailto:[EMAIL PROTECTED]
> Sent: November 8, 2003 9:15 AM
> To: Struts Users Mailing List
> Subject: Re: Dynamic page contentType
> 
> 
> On 11/07/2003 10:16 PM Eric SCHULTZ wrote:
> 
>>I'm developing an application in Struts that outputs primarily XML; but in
>>some instances I need it to output HTML of the same ActionForms and
> 
> Actions.
> 
>>Is there a way I can change the page forwarded in the Forward depending on
>>some flag or property?!
>>
>>Or is there someway I can set the JSP to output text/html or text/xml
>>depending on some flag or property (and obviously generate the correct
>>section based on the flag)?
> 
> 
> response.setHeader("Content-type", "text/xml");
> 
> 
> Adam


-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to