|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
PrintWriter.println() statements, JSP technology abstracts this concept to a higher level. With JavaServer Pages, a Web developer can write static
HTML pages and simply add Java code in those sections of the page that need to be dynamically generated. While this flexibility
enables rapid development of simple Web applications, it can be abused, resulting in unnecessarily complex applications that
are difficult to maintain, reuse, and enhance. To avoid needlessly complex applications, follow the practices I present in this article:
These tips will help you write JSPs that are reusable and easy to maintain.
It can be tempting to throw all Java and HTML code necessary for a Webpage into a single JSP file. In simple system development, such an approach makes it easy for someone new to the system to locate all relevant code in one place and understand how it all interacts. However, this approach becomes burdensome and costly when the application grows more complex and more developers become involved.
Combining HTML and Java in the same source code can make the code significantly less readable. To enhance software readability, developers often use indentation; but mixing HTML and Java scriptlets in the same file can make useful indentation extremely difficult to maintain.
Many Web development methodologies and architectures now emphasize the separation of HTML from Java code so different developers can focus on their strengths. Properly separating Java and HTML, including HTML-like JSP tags and custom tags, allows Web designers and HTML coders to work on the HTML (presentation) aspects, while Java developers work on the application's Java (processing logic) portions. Java developers focus on business logic as they implement the behavior behind the custom tags; Web designers then use these custom tags just as they use ordinary HTML tags.
Applications with Java properly separated from HTML are more reusable because the Java components are not tied to a Web browser and can be used by other parts of the application. In addition, maintainability is enhanced because of the increased modularization that comes from Java/HTML separation.
Placing business logic in JavaBeans also promotes stronger applications. I'll explain how next.
Java code included directly inside a JSP is not as readily accessible to other JSPs as Java code contained within a JavaBean.
Common behavior and business logic placed in JavaBeans can not only be used by other JSPs but also by other portions of the
application. That is because JavaBeans are merely Java classes that satisfy some basic conventions (such as a constructor
with no arguments and public get/set methods for private data members) and can be used as any other Java class. Note that Enterprise JavaBeans (EJBs) are also
useful for storing behaviors and data common to all components of the application.