You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Martin Lilienthal <li...@webdesign4free.de> on 2000/01/29 22:37:25 UTC

Three-tier-application?

Hi,

i want to build a so called "Three-tier webapplication". A servlet creates a xml-page, that should be converted to html by cocoon. 

What to do?

Here`s some servlet code:

package test;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class testServlet extends HttpServlet {

  file://Initialize global variables
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
  }

  file://Process the HTTP Get request
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = new PrintWriter (response.getOutputStream());
    out.println("<?xml version=\"1.0\"?>");
    out.println("<?xml-stylesheet href=\"/hello.xsl\" type=\"text/xsl\"?>");
    out.println("<?cocoon-process type=\"xslt\"?>");
    out.println("<page>");
    out.println("<title>Testpage!</title>");
    out.println("<content>");
    out.println("<paragraph>package test;</paragraph>");
    out.println("</content>");
    out.println("</page>");
}



  file://Get Servlet information
  public String getServletInfo() {
    return "testServlet Information";
  }

 
  }



 How can I transform the output to HTML?



thanks in advance


Martin Lilienthal

Re: Three-tier-application?

Posted by Ross Burton <bu...@dcs.kcl.ac.uk>.
> 1. Install cocoon.
> 2. Transform this servlet into a cocoon XML producer (read examples).
> (You can practice with static XML files first if you like).
> 3. Create the XSL to apply to XML produced and make sure that you place
> appropriate XSL PIs in the XML produced.
> 4. Test it out

Definitly that way - no not mention "servlet chaining" or Stefano will kill
you.  :-)

Ross

"Thirty days with a crew of viral masochists and a ship that thinks it's a
cuddly toy."
 - Diziet Embless Sma, 'Use of Weapons' - Iain M. Banks

Slipstream: http://come.to/slipstream
The Culture: http://come.to/theculture
ICQ: 5167146



Re: Three-tier-application?

Posted by Ted <te...@gs2admin1.e-meet.com>.
1. Install cocoon.
2. Transform this servlet into a cocoon XML producer (read examples).
(You can practice with static XML files first if you like).
3. Create the XSL to apply to XML produced and make sure that you place
appropriate XSL PIs in the XML produced.
4. Test it out.

Ted

> Martin Lilienthal wrote:
> 
> Hi,
> 
> i want to build a so called "Three-tier webapplication". A servlet
> creates a xml-page, that should be converted to html by cocoon.
> 
> What to do?
> 
> Here`s some servlet code:
> 
> package test;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
> 
> public class testServlet extends HttpServlet {
> 
>   file://Initialize global variables
>   public void init(ServletConfig config) throws ServletException {
>     super.init(config);
>   }
> 
>   file://Process the HTTP Get request
>   public void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
>     response.setContentType("text/html");
>     PrintWriter out = new PrintWriter (response.getOutputStream());
>     out.println("<?xml version=\"1.0\"?>");
>     out.println("<?xml-stylesheet href=\"/hello.xsl\"
> type=\"text/xsl\"?>");
>     out.println("<?cocoon-process type=\"xslt\"?>");
>     out.println("<page>");
>     out.println("<title>Testpage!</title>");
>     out.println("<content>");
>     out.println("<paragraph>package test;</paragraph>");
>     out.println("</content>");
>     out.println("</page>");
> }
> 
> 
>   file://Get Servlet information
>   public String getServletInfo() {
>     return "testServlet Information";
>   }
> 
> 
>   }
> 
> 
> 
>  How can I transform the output to HTML?
> 
> 
> 
> thanks in advance
> 
> 
> Martin Lilienthal