Means, Garann R. wrote:

> I apologize, I am dancing around my main questions here.
>
> What would be best - to try and work this all from the jsp page (sounds like
> no, because I do need multiple people to use this application at once), or
> to put it in a separate servlet? Or a Java Bean?


You're defintely on the right track.

> I understand what people have said about how to use the methods inside the
> page, but my question has become more philosophical at this point. My
> understanding is that functionality reused within a page should be a
> servlet, classes reused throughout the app should be Java Beans, and things
> called by multiple applications would be EJB's. Is that right?


Close, but it's not 100% correct. There are many ways to split up
the functionality of a Java web application and assign it to different
types of components. In general, complex logic is better implemented
as a pure Java class than within scriptlets in a JSP page. So far so
good. But there are at least two ways to do it, using two different
Java component types:
* Use a servlet to process the request and use JSP pages only to
   display the result (with none or at least very little Java code
   in the page). This approach is in line with the famous MVC
   pattern and supported by frameworks like the Apache Struts
   framework: <http://jakarta.apache.org/struts/>
* Use only JSP pages, but encapsulate all complex logic in custom
   actions (aka "custom tags") and/or JavaBeans components. This
   approach may not be as maintainable as the MVC model, but for a
   simple (or even somewhat complex) application it's usually
   easier to develop, especially if you don't have a lot of server-side
   Java development experience. You can find custom actions for a
   lot of common tasks, as both open source and as commercial software.
   I recommend that you take a look at Early Access release of the
   upcoming JSP Standard Tag Library (JSTL) first of all:
   <http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html>

Enterprise JavaBeans (EJB) is an interesting technology, suitable
for some types of applications. But it's not the right thing for
all web applications, and it comes at a higher cost in terms of
training, installation and configuration, maintenance and
administration than an application that uses only servlet and JSP.

Before you go further, I strongly recommend that you read up a
bit on all of this so you can make an informed decision about
which technology to use when. There are tons of books about servlets,
JSP and EJB, as well as a lot of articles, tutorials, and white
papers online. Try Sun's Java web site, or search on Google.

Going at this in a trial and error fashion, only asking a few
questions on a mailing list, is almost as hard and likely to
fail as programming with your monitor turned off! Any technology
as complex as the web application technologies are requires quite
a bit of study in order to make the right decisions, and compromises,
for your specific application. There's no silver bullet, I'm
afraid.

Hans

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com

===========================================================================
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

Reply via email to