Nanduri Amarnath wrote:

> Hi everybody,
>      I am trying out a solution where the business logic takes place inside the
> Servlet and the output from the servlet goes to a JSP page (where i have  all my
> HTML and form fields).
>
> 1)  Is there anyway i can set some values inside the Servlet and out put the
> values into theJSP page ?

The simplest way is to pass a request attribute like this:

    request.setAttribute("name", myBean);

this will show up in your JSP page as a bean with "request" scope.  You can also
pass things in the user's session if they need to last longer than just the current
request.

>
> 2)  Can i do some sort of chaining (i.e servlet-jsp) ? I know that i can do a
> servlet-servlet chaining.
>

Forwarding from servlet to JSP works just like forwarding servlet to servlet:

    RequestDispatcher rd =
      getServletContext().getRequestDispatcher("/mypage.jsp");
    rd.forward(request, response);

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to