All the discussion that is going on about JSP vs Servlet doesn't answer
following questions:

Many a times in business logic the target page is dependent on the contents
of source page. In these scenario a submit button cannot point to a fixed
JSP page. What may happen is that submit button may point to a servlet where
decision about the target page is taken and then the page is chained using
requestDispatcher method.

The submit servlet may use the submitted data to prepare the data for target
page ( It may talk to some application server , pass the request and get the
response data along with name of the target JSP page). Now servlet will
chain the JSP page to present that data. My question is how the servlet can
pass the prepared data which may be in a Hashtable or Vector to the JSP page
for presentation. This strategy effectively separates the presentation and
business logic. It also reduces the lines of java code written in JSP page.


below is the code for chanining

import javax.servlet.*;
import javax.servlet.http.*;

public class servletToJsp extends HttpServlet {

    public void doGet (HttpServletRequest request,
                       HttpServletResponse response) {

        try {

getServletConfig().getServletContext().getRequestDispatcher("/jsp/jsptoserv/
target.jsp").forward(request, response);
        } catch (Exception ex) {
            ex.printStackTrace ();
        }
    }
}

Pankaj

___________________________________________________________________________
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