On Thursday, May 9, 2002, 5:44:47 AM, Luca Ventura wrote:
LV> Yes, I understand exactly what you say: Presentation in JSP and
LV> Business in Servlets.
LV> The problem is: let's suppose I want to implement a servlet for Business
LV> logic. How can I recall it in a JSP page?
Actually the business logic I think is best to left to classes not
even in the servlets. Reason being, you can use the business logic
elsewhere in another non-JSP application if you needed it. Plus,
it's easier for even other JSPs to reuse the business logic if
it's placed in just normal classes. So to answer your answer
question Luca on a very basic level...
Some JSP: has a form that submits to a servlet
Servlet: can call some business methods in another class like
SomeBusinessObject.getMeListOfEmployees() (maybe this would return
a List of Employee beans from the database ).
Then to answer your question you simply stick that object into the
request or session... like:
request.setAttribute("myList", listYouGotBack );
Then the the forward takes places to whatever other jsp and in the
new jsp you have access to this List. You can get it out with the
useBean tag or in a scriplet:
<% List myList = (List)request.getAttribute("myList"); %>
Now you have access to the list in your page.
I think you should really take a look at Chapter I of this Struts
book coming out. This chapter doesn't pertain to the Struts
framework per se, but gives a good overview of MVC
http://www.theserverside.com/resources/strutsreview.jsp
--
Rick
mailto:[EMAIL PROTECTED]
"I'd rather be rich than stupid"
-Jack Handey
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com