• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How use OOPs in Servlet

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How we are using OOP consept in Servlet code design. Where is inheritance and Polyformisam.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlet is the best example of OOP. Your web application is usually a number of screens, most of screens have something in common, some screens look similar to others. So you do the following:
1. define a base servlet taking care of common content and behavior of all screens
2. inherit servlets from the base to serve particular screens
3. build more complex hierarchy for servlets servicing similar screens, like reports, form processor and so on.
Using OOP reduces amount of developed code drastically. You need just override a few functions of base servlet and get completely different behavior. It's very powerful approach.

Maybe I should write a book about that, who knows?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The actual servlet spec and classes are a small part of an application. You can apply OO Design Principles to your systems whether you start from a servlet framework or not. Read up on those principles and see the kinds of things we tend to care about.

If those make good sense, google for "MVC model 2" which is recipe for separating the responsibilities of servlets, JSP pages and a Plain Old Java Object business model.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wish to add this.

By overriding the service method itself you are doing dyanamic polymorphism.
Of course, this is achieved by none other than polymorphism.

Learning the OOPs concepts thoroughly and analysing how it is implemented in different Java technology will help you a lot
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic