Re: HTTP response as XML

2003-04-04 Thread Konstantina Stamopoulou
Thank you David.
I think I will forward to xml directly from my Action class

Konstantina
- Original Message -
From: David Graham [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 6:06 PM
Subject: Re: HTTP response as XML


 It is possible.  It's commonly referred to as XML over HTTP.  HTTP is the
 protocol or language that clients and servers speak and XML, HTML, GIFs,
 JPEGs, etc. can be delivered over that protocol.  HTTP responses set a
 Content-Type header like Content-Type: text/html or Content-Type: text/xml
 in your case.  There are JSTL tags that generate XML in JSPs or you can
 generate the XML in an Action and send it back.

 David



 From: Konstantina Stamopoulou [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Subject: HTTP response as XML
 Date: Thu, 3 Apr 2003 17:25:09 +0300
 
 Hello everyone,
 I have been using STruts for a while and it has solved a lot of my
previous
 problems for example having long .jsps that included all the logic. Now I
 have been asked to use struts, which will receive the requst and will
 generate .xml   instead of html as a response. This .xml will be parsed
by
 another application. First of all is this possible? Make an http requset
 which will be handled by struts which will return xml code? If yes how is
 this possible? Do I have to implement my own custom tags? Has anyone
 implemented something similar?
 An xml file that I might generate will have the following form:
 
 ipg width=600 height=480 img=background.jpg
 
 navigation left=20 top=20 width=200 height=300
 button top=0  width=200 height=50 img=background.jpg txt=Live
TV
 action=TVCatalog target=displayarea/
 button top=100 width=200 height=50  img=background.jpg
 txt=E-mail action=showEmail target=displayarea/
 button top=200  width=200 height=50 img=background.jpg
txt=Music
 action=musicCatalog target=displayarea/
 /navigation
 img left=400 align=right img=background.jpg/
 banner top=400 width=640 font=verdana size=40pt color=white
 bgcolor=transparent href=http://www.news.com; /banner
 block left=250 top=200 width=260 height=200
 name=displayareaThis is a test. /block
 /ipg
 
 I could use any available help!
 
 Thank U in advance!
 Konstantina


 _
 STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
 http://join.msn.com/?page=features/junkmail


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




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



re: HTTP response as XML

2003-04-04 Thread Ted Husted
You might want to look at the digester for this. It is very good at 
converting JavaBeans to XML and back. See the RSS package for an example.

http://jakarta.apache.org/commons/digester/api/org/apache/commons/digester/rss/package-frame.html

You can then do your response up as a JavaBean, have the Digester 
convert that to XML, return XML as the response just as you would from a 
servlet (and return null to the Struts controller).

From what you said, there's little reason to get a page involved, since 
the output is going to another application.

-Ted.



--
Ted Husted,
Struts in Action http://husted.com/struts/book.html


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


Re: HTTP response as XML

2003-04-04 Thread Konstantina Stamopoulou
Hello Ted,


 You might want to look at the digester for this. It is very good at
 converting JavaBeans to XML and back. See the RSS package for an example.


http://jakarta.apache.org/commons/digester/api/org/apache/commons/digester/r
ss/package-frame.html

I'm aware of Digester but I haven't used it to lean in details its
functionality. I think it is time to do so.

 You can then do your response up as a JavaBean, have the Digester
 convert that to XML, return XML as the response just as you would from a
 servlet (and return null to the Struts controller).

You mean that in my Action class I will write  return (new
ActionForward(null)) and I will use the PrintWriter to send the response?
Shouldn't  I do the following -- return (new ActionForward(my.xml))
where .xml is the file constructed in the Action class.



  From what you said, there's little reason to get a page involved, since
 the output is going to another application.

Exactly!


 -Ted.

Thank you!


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



Re: HTTP response as XML

2003-04-04 Thread David Graham
You mean that in my Action class I will write  return (new
ActionForward(null)) and I will use the PrintWriter to send the 
response?
Shouldn't  I do the following -- return (new ActionForward(my.xml))
where .xml is the file constructed in the Action class.

You would say return null; at the end of your action and use the 
PrintWriter to write the response yourself.  Your XML output does not have 
to be saved to a file before you send it, you can write it directly to the 
client.

  From what you said, there's little reason to get a page involved, since
 the output is going to another application.
Well, you could use a JSP with JSTL tags to generate the XML but you don't 
have too.

David

_
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail

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


re: HTTP response as XML

2003-04-04 Thread Craig R. McClanahan


On Fri, 4 Apr 2003, Ted Husted wrote:

 Date: Fri, 04 Apr 2003 09:19:25 -0500
 From: Ted Husted [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: re: HTTP response as XML

 You might want to look at the digester for this. It is very good at
 converting JavaBeans to XML and back. See the RSS package for an example.

 http://jakarta.apache.org/commons/digester/api/org/apache/commons/digester/rss/package-frame.html

 You can then do your response up as a JavaBean, have the Digester
 convert that to XML, return XML as the response just as you would from a
 servlet (and return null to the Struts controller).


Digester is pretty good at XML-Java, but doesn't really help do
Java-XML.  However, a sibling Commons project called betwixt does a
pretty nice job of that.

  From what you said, there's little reason to get a page involved, since
 the output is going to another application.


The discussed solutions for generating XML directly from your Action are
all viable.  However, if you are doing the XML in a fixed output format
and just need to insert dynamic data, one thing to consider is to use a
JSP page that outputs XML, and use the usual Struts tags for the dynamic
stuff -- say, something like this to generate a customer list:

  %@ page contentType=text/xml %
  %@ taglib prefix=bean uri=... %
  %@ taglib prefix=logic uri=... %
  customers
logic:iterate id=customer name=customerList
  account-number
bean:write name=customer property=accontId/
  /account-number
  namebean:write name=customer property=name//name
  ...
/logic:iterate
  /customers

This works best for simple RPC type environments where the output format
is relatively uncomplicated -- for something like a SOAP response, I'd
definitely use software that knows how to do all the headers and envelope
things.

 -Ted.


Craig

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



Re: HTTP response as XML

2003-04-03 Thread David Graham
It is possible.  It's commonly referred to as XML over HTTP.  HTTP is the 
protocol or language that clients and servers speak and XML, HTML, GIFs, 
JPEGs, etc. can be delivered over that protocol.  HTTP responses set a 
Content-Type header like Content-Type: text/html or Content-Type: text/xml 
in your case.  There are JSTL tags that generate XML in JSPs or you can 
generate the XML in an Action and send it back.

David



From: Konstantina Stamopoulou [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: HTTP response as XML
Date: Thu, 3 Apr 2003 17:25:09 +0300
Hello everyone,
I have been using STruts for a while and it has solved a lot of my previous 
problems for example having long .jsps that included all the logic. Now I 
have been asked to use struts, which will receive the requst and will 
generate .xml   instead of html as a response. This .xml will be parsed by 
another application. First of all is this possible? Make an http requset 
which will be handled by struts which will return xml code? If yes how is 
this possible? Do I have to implement my own custom tags? Has anyone 
implemented something similar?
An xml file that I might generate will have the following form:

ipg width=600 height=480 img=background.jpg

navigation left=20 top=20 width=200 height=300
button top=0  width=200 height=50 img=background.jpg txt=Live TV 
action=TVCatalog target=displayarea/
button top=100 width=200 height=50  img=background.jpg 
txt=E-mail action=showEmail target=displayarea/
button top=200  width=200 height=50 img=background.jpg txt=Music 
action=musicCatalog target=displayarea/
/navigation
img left=400 align=right img=background.jpg/
banner top=400 width=640 font=verdana size=40pt color=white 
bgcolor=transparent href=http://www.news.com; /banner
block left=250 top=200 width=260 height=200 
name=displayareaThis is a test. /block
/ipg

I could use any available help!

Thank U in advance!
Konstantina


_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

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