I would agree with Erik and add that you could accomplish much the same
effect with a few lines of JavaScript in your source page. By making your
"submit" button a "type=button" JavaScript button instead, you could execute
a function to evaluate your source page conditions and issue a location.href
command to the appropriate JSP page.

The number 1 drawback to this approach is that you must assume your clients
have JavaScript enabled. One alternative would be to go ahead with your
"Submit" button and attempt to use an "onsubmit" event to execute your
JavaScript function to call the JSP page. If JavaScript isn't enabled the
normal submit action will take over.

Just throwing out another alternative; not suggesting it is the right one. I
have used this approach mainly in defining such functions as "Help" or
"Options" buttons on a page.

----- Original Message -----
From: Erik Sahl <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 09, 1999 4:30 PM
Subject: Re: JSP vs Servlets - How about this ....


> How about creating a bean (in its simplist form, a Java class with a
default
> constructor defined) setting up a Vector and/or Hashtable variable,
putting
> some setters and getters for these two items, and then sticking this bean
> into the session before forwarding to the JSP page?   The JSP page can
then
> utilize this bean and you simply make calls to the getters of the bean to
> get back the various collections.
>
> Is there something I'm missing here?
>
>
>                                                                 Erik Sahl
>
[EMAIL PROTECTED]
>
> > -----Original Message-----
> > From: A mailing list for discussion about Sun Microsystem's Java Servlet
> > API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
> > Pankaj Malviya
> > Sent: Tuesday, November 09, 1999 2:33 PM
> > To: [EMAIL PROTECTED]
> > Subject: JSP vs Servlets - How about this ....
> >
> >
> > 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
> >
>
>
___________________________________________________________________________
> 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