Pankaj Malviya wrote:
> 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 approach you've suggested is the approach I take in my JSP+Servlet apps.
The biggest desgin issue I've run into with this style is the need for the
servlet (C in the MVC) to know the URL of the appropriate JSP page (V in MVC),
depending on the context, which should be displayed next. The J2EE example
application takes a pretty useful approach to this problem, because it uses a
property file to translate between logical view names (say, "Customer List")
and the actual URL to be forwarded to (say, "/customer/list.jsp"). This helps
you maintain a little separation between controller and view, although -- as
others have pointed out -- these often get combined to some degree.
>
> 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
> [snip]
I would suggest that you call this "forwarding" rather than "chaining".
Historically, the concept of "chaining" in the servlet world has been the idea
that you'd call one servlet, and then post-process it's output with another
servlet, based on the MIME type or some other criteria. This design approach
was present in early versions of JWS, but has not been universally implemented.
Craig McClanahan
___________________________________________________________________________
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