tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lior Shliechkorn <liorshli...@yahoo.com>
Subject Re: [OFF-TOPIC] RE: RequestDispatcher include() Problem
Date Thu, 10 Apr 2003 18:44:16 GMT

Ok,
I chose the RequestDispatcher since I'm going to transfer control from one servlet to process
which report to generate to the servlet that is generating the report. I have this code segment
below:
     case 1: 

    url = "/servlet/Report1";
    rd = context.getRequestDispatcher(url);
    rd.forward(request, response);
    break;
  case 2:

    url = "/servlet/Report2";
    rd = context.getRequestDispatcher(url);
    rd.forward(request, response);
    break;
  case 3: 

    url = "/servlet/Report3";
    rd = context.getRequestDispatcher(url);
    rd.forward(request, response);
    break;
  default: break;

How would I incoporate the items that you have just given me in this system. Would they go
before the switch statement (header), and after the statement terminates (footer)?

Thank you very much,

Lior

 "Shapira, Yoav" <Yoav.Shapira@mpi.com> wrote:
Howdy,
There are many ways to do this, but from the subject of your message I
gather you're interested in the RequestDispatcher approach. Consider
the following setup:

- HeaderServlet is a servlet you wrote which generates the header, and
is mapped to /GetPageHeader in your web.xml
- FooterServlet is a servlet you wrote which generated the footer, and
is mapped to /GetPageFooter in your web.xml
- MainServlet is a servlet you wrote which generates the body, including
the header and footer.

In MainServlet's doGet() (or doPost, or whatever), which has
HttpServletRequrest req and HttpServletResponse res as parameters, you
would do:

RequestDispatcher rd =
getServletContext().getRequestDispatcher("/GetPageHeader");
rd.include(req, res);

// output the body here

rd = getServletContext().getRequesDispatcher("/GetPageFooter");
rd.include(res, res);

// That's it.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Lior Shliechkorn [mailto:liorshliech@yahoo.com]
>Sent: Thursday, April 10, 2003 2:24 PM
>To: Tomcat
>Subject: RequestDispatcher include() Problem
>
>
>Hi,
>
>I know this is off topic for this discussion forum, but I hope you who
are
>reading this would be able to help regarding this matter. I'm trying to
>include the header and footer of a page and pass them to a servlet. But
I'm
>not sure how this works, and how to get the data objects that are
included
>and sent to the servlet.
>
>Any help is greatly appreciated. If you can send me a code sample it
would
>be fantastic. I've looked around a lot and found nothing about the
matter.
>
>Thanks for your time,
>
>Lior
>
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! Tax Center - File online, calculators, forms, and more



This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged. This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender. Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message