Java Reference
In-Depth Information
Servlet Development
Although the application developed in the previous section was fairly easy to
develop, the resulting code isn't very maintainable. One of the JSPs has both business
logic and presentation logic embedded in it. It is considered a best practice for JSPs to
have only presentation logic, and keep the business logic elsewhere.
One common way to approach this problem is to use the Model-View-Controller
(MVC) design pattern. This pattern provides a clean separation of concerns,
providing artifacts that solely act as data (model), while other artifacts are solely
responsible for displaying the data (view) and another artifact (or artifacts)
is responsible for manipulating the data and transferring control to the view
(controller). In Java web applications, JSPs typically act as the view, servlets act as
controllers, and custom JavaBeans act as the model.
In this section we will modify the application we developed previously so that it
follows this pattern.
Adding a Servlet to Our Application
NetBeans provides functionality that allows us to easily create a servlet. In order to
create our servlet, we need to go to File | New . Choose Web from the Categories
list, then Servlet from the File Types list.
 
Search WWH ::




Custom Search