Mark Hayes wrote:
> Your views are valuable on this, thanks for sharing them. I was further
> about the problem of passing information from the "logic" servlet to the JSP
> file to which it forwards. If the servlet processes the business logic,
> many times data will result from that processing which then should be used
> in the presentation of the following JSP page. Since there is no way to
> pass arguments when forwarding (right?), I assume you must use a session
> variable. It seems that there are two cases; one case where the data being
> passed is meant to remain in the session, and another case where the data is
> only meant for the next page. In the latter case, the JSP page should
> therefore delete the session data after it uses it. I was wondering if you
> had run into this, and if a particular technique came in handy for you.
>
> thanks!
> mark
You most definitely pass arguments to JSP's from a servlet (if you're using
the JSDK 2.1 or higher). That's what the RequestDispatcher allows you to
do. You do something like the following within the servlets
service/doGet/doPost method (of course you can stuff any object request with
setAttribute()):
String myVar = "Testing";
request.setAttribute("myString", myVar);
rd =getServletContext().getRequestDispatcher("yourjsp.jsp");
rd.forward(request, response);
Mike
===========================================================================
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