I don't have much experience with programming but I did implement servlet chaining for 
a project.  The way I understand it
is that if servlet A chains to servlet B, then instead of the output of A going to the 
client, the output goes straight as
the input of B.  B does its thing, and the output of B goes to the client.

I divided up 2 types of tasks in 2 servlets for an entry point for a user (1 for data 
gathering, 2 for HTML page
generation) so I found servlet chaining for this case useful.  Someone with more depth 
on the topic will certainly warn you
(and me!) of the dangers that it may present...

Hope this helps,

Jean

"Nottebrok, Guido" wrote:

> Hallo,
> I'm new in Java and servlets and have read in this and other lists that chaining 
>servlets is no good programming style.
>
> My question is: what exactly is servlet-chaining?
>
> Here is some code of the Sun's bookstore example.
>
> public class BookStoreServlet extends HttpServlet {
>
>     public void service (HttpServletRequest request,
>                          HttpServletResponse response)
>         throws ServletException, IOException
>     {
>
>         [snip]
>
>         //Left cell -- the "book of choice"
>         out.println("<td valign=\"TOP\" width=\"55%\">" +
>                     "<h3>What We're Reading</h3>" +
>                     "<p>" +
>                     "In <em><a href=\"" +
>                     response.encodeUrl("/servlet/bookdetails?bookId=203")
>         [snip]
>
> In the last two lines the servlet BookDetails can be called from the site generated 
>by the BookStoreServlet
> Is this meant by chaining servlets???
>
> Or is it something like this (also from the Sun example):
>
> public class BookDetailServlet extends HttpServlet {
>
>     public void doGet (HttpServletRequest request,
>                        HttpServletResponse response)
>         throws ServletException, IOException
>     {
>
>         [snip]
>
>         //Get the identifier of the book to display
>         String bookId = request.getParameter("bookId");
>         if (bookId != null) {
>
>             // and the information about the book
>             BookDBServlet database = (BookDBServlet)
>                 getServletConfig().getServletContext().getServlet("bookdb");
>                        BookDetails bd = database.getBookDetails(bookId);
>          [snip]
>
> In the last lines the servlet BookDetailServlet calls a method of the BookDBServlet.
>
> Or is it something totally different.
>
> Can anyone please explain what servlet-chaining is and why I shouln't use it.
> Thanks
>
> Guido
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to