> -----Original Message-----
> From: James Strachan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 28, 2002 2:33 AM
> To: Jakarta Commons Users List
> Subject: Re: [Jelly] Invoking a Jelly script from a Java app
> 
> 
> ----- Original Message -----
> From: "Martin Cooper" <[EMAIL PROTECTED]>
> > I'm trying to invoke a Jelly script from within an app (actually, a
> > servlet), and am running into problems. The error I am getting is:
> >
> > Aug 27, 2002 11:07:53 PM 
> org.apache.commons.jelly.impl.Embedded execute
> > SEVERE: This tag does not understand the attribute 'j' 
> File: null At tag
> > <j:jelly>: line: 3 column: 0
> > This tag does not understand the attribute 'j' File: null At tag
> <j:jelly>:
> > line: 3 column: 0
> 
> This error sounds like the namespace xmlns:j="jelly:core" is being
> interpreted as j="jelly:core" which is wierd. This could be a 
> SAX parser
> issue. Which SAX parser is on your classpath? Could it be a 
> wierd, or old
> SAX parser I wonder?

Well, I don't think the parser is particularly old or weird - it's the one
that ships with the latest version of Resin - but that was indeed the
problem. I dropped in the version of Xerces from my Jelly lib, and told
Resin to use that instead, and now everything works. Yeah!

> 
> 
> > My Jelly script at this point is trivial, and is based on 
> stuff I saw in
> the
> > various samples. It looks like this:
> >
> > <?xml version="1.0"?>
> >
> > <j:jelly xmlns:j="jelly:core">
> >   <j:set var="p1-plus-p2" value="${p1}${p2}" />
> > </j:jelly>
> >
> > My Java code is almost the same as the example in the Javadoc for
> Embedded.
> > It looks like this:
> >
> >     Embedded embedded = new Embedded();
> >     embedded.setOutputStream(os);
> >     embedded.setVariable("p1", "succ");
> >     embedded.setVariable("p2", "ess");
> >     embedded.setScript(is);
> >     boolean bStatus = embedded.execute();
> >     if (bStatus) {
> >         String result =
> > (String)embedded.getContext().getVariable("p1-plus-p2");
> >         // Do stuff with result
> >     }
> >
> > Any ideas what I'm doing wrong? Also, I'm assuming that 
> Embedded is the
> > right class to be using in this situation. Is that correct?
> 
> If you like. I tend to just use JellyContext directly...
> 
> JellyContext context = new JellyContext();
> context.setVaraible("a", whatever);
> ...
> XMLOutput output = new XMLOutput( myOutputStream );
> context.runScript( "foo.jelly", output );

OK, I tried that, and that works too. The differences I noticed were:

 - I had to add dom4j to my compile classpath.
 - You can't pass an InputStream to runScript.
 - Using JellyContext as you describe causes two instances of JellyContext
to be created, while using Embedded seems to get away with only one.

Just curious - what is the intended usage for Embedded versus using
JellyContext directly?

Thanks!

--
Martin Cooper


> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



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

Reply via email to