Hi,
Along the lines of the last reply, I have found that applying OO concepts to
my servlets is very useful. For instance, I have a single 'Base' servlet
that extends HttpServlet. Then, my other (more custom) servlets all extend
that base servlet. The usefulness of this stems right from the basic
concepts of OO. For instance, the base servlet's code can perform session
validation based on a session id. The custom servlet's source is only
invoked if it is determined (in the base source) that the session is valid.
Other common service provided within the base servlet's code is error
logging/reporting. There are others, but you get the idea.
By keeping this common code in the base, the custom servlets that extend it
need only handle retrieving and analyzing the parameters related to their
custom service (an orderNumber in the case of an OrderEntryServlet), and
using these to generate the appropriate response page. Along these lines,
OO has come in handy again. Rather than having the servlet directly
generate the page, I use 'generator' classes to do this. This way, the
pages can be broken into components and different servlets can share the
generators for common code generation. Finally, the data retrieval and
updates are hidden within a data access layer. These are just a few
examples, but enough to say that I think objectivity is not only possible,
but beneficial to servlet development.
Just my 2 cents...
Good luck!
----- Original Message -----
From: Ernie V <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 13, 2000 7:51 AM
Subject: Re: Question on Servlet Subclassing
> I would have to disagree. The decision to extend a servlet is highly
dependent
> upon your architecture and ultimately on the specific requirements of the
system.
> I have designed systems with a single servlet as well as others with a few
> generalized servlets that include several specialized descendant servlets.
And
> each of these systems use variations on the MVC architectural theme.
>
> I would agree, that as a general rule, a designer should keep a servlet as
simple
> as possible. But that mentality can be extended to just about any Java
class. It
> is always desirable to design classes so that there interfaces with other
classes
> are well defined, unambiguous, and easily maintained. The only thing that
would
> make a servlet's design depart from this spirit of objectivity is the lack
of due
> diligence on the designer's part.
>
> -ernie
>
>
> Danny Rubis wrote:
>
> > Hey!
> >
> > I don't use Oracle but yes.
> >
> > The question is why would you want to do this? If you use the
> > Model View Control, you won't have much code in the servlet
> > anyway to make it worth while to extend the class. In my experiences,
> > I have not found it to be an advantage. Servlets are not very
> > object-oriented anyway.
> >
> > Sans adieu,
> > Danny Rubis
> >
> > kiran vattem wrote:
> >
> > > Hello Gurus,
> > > sorry about the previous email, I sent it inadvertently...
> > >
> > > I have a question on servlet subclassing
> > >
> > > If I have Servlet1 that extends HttpServlet
> > > Can I have a Servlet2 that extends Servlet1
> > >
> > > for example
> > >
> > > public class servlet2 extends Servlet1 {
> > >
> > > ....
> > >
> > > ...
> > > }
> > >
> > > Is it a correct way of re using code?
> > > I tried using this in Oracle's Jdeveloper,it would not work
> > > Got compilation errors..
> > >
> > > Thanks
> > > kiran
> > > ______________________________________________________
> > > Get Your Private, Free Email at http://www.hotmail.com
> > >
> > >
___________________________________________________________________________
> > > 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