File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

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.

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

Joined: Jun 25, 2001
Posts: 17410

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".

An IDE is no substitute for an Intelligent Developer.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
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.

I agree. Here's the link:
subject: How Code Resuability easy in servlet
It's not a secret anymore!