Use Model View Controller framework

Most web applications use a Model-View-Controller framework. In particular, they usually use what is called the "Model 2" style, which has these components:

See Also :
Refactor large Controllers
JSPs should contain only presentation logic
Model Objects