cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Engelhart <>
Subject Re: Dynamic XML generation
Date Tue, 18 Jul 2000 15:01:44 GMT
on 7/18/00 9:36 AM, Patrick Roemer at wrote:

> Hi,
> I'm a Cocoon beginner and I'm sure you have read this question before,
> but I haven't been able to find a consistent answer in all the mailing
> list archives I've searched, so please help me out.
> I have a servlet that checks access authorization by username and
> password, send a database request and outputs the result in HTML.
> Authorization and database access are handled by separate classes, so
> the servlet itself is quite lightweight.
Just use a RequestDispatcher in your servlet and send it to either an XSP
(if you need the output to be dynamic) or to an .xml file.

So in your servlet you'd have something like:

RequestDispatcher rd = request.getRequestDispatcher("/xml/login.xml");
// if you want you can put objects into the request
// and pull them out again in an XSP or else just forward the request object
// this example puts a simple error string into the request object via
// setAttribute() and then the XSP adds it to the XML document on the fly
rd.setAtttribute("error", "The user name and password you selected were
rd.forward(request, response);

then in say an XSP, you can do this:

<?xml version="1.0"?>

<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>

<?xml-stylesheet href="error.xsl" type="text/xsl"?>

<xsp:page language="java" xmlns:xsp="">
  <error><xsp:expr>(String) request.getAttribute("error")</xsp:expr></error>


View raw message