cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@dti.net>
Subject Re: Servlet to XSL possible?
Date Wed, 23 Jan 2002 17:44:52 GMT
OK.  I think I get it now.

Yes, Tomcat will always handle the servlets, and since your servlet is not a Cocoon generator
things won't work properly.  Servlets are designed to write directly to the http response
stream (which is what you are seeing).

Cocoon on the other hand is designed for you to process xml elements via pipeline transformations
and (eventually) serialize the output to the http response stream.

So ... how to do what you want?

Some ideas:

1) Kludgey:

Make your servlet act as a Cocoon generator as well.  Have it implement the appropriate interface
and generate the appropriate XML when called.

2) less kludgey:  

Avoid calling a servlet completely.

Refactor your servlet into 2 pieces:  one that does the actual servlet call/response stuff
("doGet", etc.) and a separate component of stand-alone code that really does the meat of
what you're trying to do (generate XML it sounds like).

(Or alternatively, just add a new method to the servlet that you can call to retrieve the
XML without going through all the HTTP stuff.)

Then use a custom written Generator (or maybe even an Action or XSP) to call the new component
directly and feed the results into the pipeline.


Haven't thought this all through too carefully so maybe this is tougher than it sounds, but
in theory I would think this should work.

Any help?


DR



At 11:16 AM 1/23/02 -0600, you wrote:
>     I think what is happening is that Tomcat4.0 is handling the servlet and
>not Cocoon2. ( I am not running an Apache server only tomcat )
>     If I run the Tomcat servlet examples ( found in
>?:\Tomcat\jakarta-tomcat-4.0.1\webapps\examples\WEB-INF\classes ) it is my
>understanding that Cocoon is never involved.  So for my servlet, no matter
>what I do in Cocoon sitemap.xmap Tomcat4.0 handles the servlet which outputs
>XML intended to be processed by an XSL processor.
>     If this understanding is correct then my statements dont seem
>contradictory, but I admit that I dont have the big picture.
>     If I modify my servlet to create a temp file with /XSP/ for example in
>the path and redirect to it then Cocoon2 gets it and processes it just fine.
>     What I want to do is not create a temp file and 'pipe' from the servlet
>to the transformer and to the requestor.
>     I have thought that I might have to create a transformer in my servlet
>and do the transformation there but it seems more elegant and generalized to
>have Cocoon do this for me.
>
>Bob Garvey
>
>
>----- Original Message -----
>From: "David Rosenstrauch" <darose@dti.net>
>To: <cocoon-users@xml.apache.org>
>Sent: Wednesday, January 23, 2002 10:56 AM
>Subject: Re: Servlet to XSL possible?
>
>
> > I don't understand.  First you say:
> >
> > "The problem appears to be that I cant get Cocoon to recognize servlets
> > at all."
> >
> > And then:
> >
> > "Regardless of how I do the <map:match pattern's > my Tomcat4.0 and
> > Cocoon2 combination act the same way which is to present me with the XML
> > created by the servlet."
> >
> > If you're getting presented with the XML created by the servlet, then
>Cocoon IS recognizing your servlet, no?
> >
> > Am I missing something?  What exactly is it that isn't working properly
>for you?
> >
> >
> > DR
> >
> >
> >
> > At 08:29 AM 1/23/02 -0600, you wrote:
> > >Vadim,
> > >     The problem appears to be that I cant get Cocoon to recognize
>servlets
> > >at all.
> > >     Regardless of how I do the <map:match pattern's > my Tomcat4.0 and
> > >Cocoon2 combination act the same way which is to present me with the XML
> > >created by the servlet.  If I create a temporary file and do a redirect
>in
> > >the servlet with /xsp/ in the tempfile name then it works.
> > >     How do I increase debugging/logging messages?
> > >     Can you see where I should start to get Cocoon to get the servlet in
>the
> > >pipeline.
> > >Bob Garvey
> > >
> > >----- Original Message -----
> > >From: "Vadim Gritsenko" <vadim.gritsenko@verizon.net>
> > >To: <cocoon-users@xml.apache.org>; "'Bob Garvey'" <bgarvey@wordgraph.com>
> > >Sent: Tuesday, January 22, 2002 12:14 PM
> > >Subject: RE: Servlet to XSL possible?
> > >
> > >
> > > > > From: Bob Garvey [mailto:bobgarvey2@home.com]
> > > > >
> > > > > I am missing the big picture.
> > > > > I want to generate data from servlet and have that output
>transformed
> > > > to
> > > > > html for a response.
> > > > > I have tried combinations on the order of:
> > > > >    <map:match pattern="servlet23/*">
> > > > >      <map:generate
> > > > src="http://cb:8080/examples/servlet/servlet23.{1}"/>
> > > > >      <map:transform src="stylesheets/servlet23/{1}.xsl"/>
> > > > >      <map:serialize/>
> > > > >    </map:match>
> > > > > where {1} would be the servlet name within the servlet23 package
and
> > > > would
> > > > > specify the stylesheet.
> > > > > Any quidence appreciated.
> > > >
> > > > This looks Ok.
> > > >
> > > > You must have servlet http://cb:8080/examples/servlet/servlet23.xxx,
>and
> > > > you should have an XSL file on the disk:
>stylesheets/servlet23/xxx.xsl,
> > > > when requesting "servlet23/xxx".
> > > >
> > > > What's the problem you are experiencing?
> > > >
> > > > Vadim
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > Please check that your question has not already been answered in the
> > > > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> > > >
> > > > To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> > > > For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> > > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >Please check that your question has not already been answered in the
> > >FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> > >
> > >To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> > >For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> > For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> >
>
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
>For additional commands, e-mail: <cocoon-users-help@xml.apache.org> 


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message