Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes How Code Resuability  easy in  servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How Code Resuability  easy in  servlet" Watch "How Code Resuability  easy in  servlet" New topic
Author

How Code Resuability easy in servlet

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
Hi friends am newbie to servlet. How code reusability easy in servlet. why not in jsp .
here reusabillity means only javabeans or any thing else.
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

Servlet was developed to execute the business logic. You can develop EJB, or Java Beans to process the business logic. So, you can reuse the same business logic in many different place. So, in servlet you can re-use the already developed business logic multiple times. Here the resuability means the re-use of business logic in the form of Java Beans/EJB etc.

JSP is developed to develop the view of the application. You are not supposed to write business processing logic in JSP.

Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

The main problems with reusability have to do with how dependent the code is on the environment in which it was originally used. If you put the actual business logic in a generic JavaBean and employ that JavaBean from the servlet, the business logic would tend to be more reusable than if you'd placed it directly in the servlet. This concept is known as "separation of concerns".


Customer surveys are for companies who didn't pay proper attention to begin with.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12788
    
    5
A further benefit - if you design your helper classes (beans or whatever) so that they can be tested outside the servlet environment you will find development much easier.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How Code Resuability easy in servlet