Have you ever wanted to develop JSP Web applications? This article will help you get all the tools you need installed on your computer, and walk you through the process of writing a simple application. It is excerpted from the book Beginning JSP 2 From Novice to Professional, written by Peter den Haan et al (Apress, 2004; ISBN: 1590593391).
Creating Your First JSP Page - The Java Community (Page 7 of 7 )
In fact, the multiplicity of servlet containers is another example of the biggest strength of the Java family of technology: choice. All the Java technologies are controlled by a community of developers and corporations who together form the Java Community Process (JCP). The JCP system enables anyone to contribute to the future of Java by participating in expert committees that shape new features of the language or simply by issuing feedback to Java’s architects.
Through the JCP and the documents it publishes into the public domain, anybody can develop Java extensions and features as defined by the JCP. The JCP’s main purpose is to prevent the Java language from degenerating into a chaos of incompatible, duplicated, and redundant functionality by setting standards. However, because of the freedom to create Java technology based on these standards, Java developers have a great deal of choice of development tools offered by a variety of competing vendors.
This philosophy is often referred to as “agree on standards, compete on implementation.” It’s in direct contradiction to Microsoft’s philosophy embodied in such technologies as its .NET platform. Microsoft controls the standards used in .NET, and it creates most of the development tools associated with .NET. Considering the benefits and pitfalls of each model—Java’s community-driven approach versus Microsoft’s benevolent dictatorship approach—is a complex and often emotionally charged issue that we’ll leave out of this book.
To create a Web application of any significant utility, a developer usually creates many different JSP pages and/or servlets. Additionally, the developer may have a number of images and HTML pages they want to associate with the JSP pages and servlets, and there may be code libraries and other files that form part of the same application.
Keeping track of all of these files can be a bit difficult, and configuring a servlet container to know where to find them all can seem quite a nightmare. Hang on—actually, it’s really rather easy. It turns out that there’s a standard directory layout for Web applications. Furthermore, a standard configuration file for Web applications tells servlet containers how the Web application works. Both of these are regulated by the JCP as described previously.
By following this standard layout, Java developers don’t have to worry about how to configure different servlet containers; it all happens automatically. Chapter 2 discusses this standard directory layout in greater detail.
Servlet containers are only part of the Java story. Since the development of servlet and JSP technology, many additional Java technologies have been created that ease the development of large and complex business applications, either for use on the Internet or for use on private intranets. Examples of these technologies include Enterprise JavaBeans, which aims to make it easier for developers to distribute Java code onto many different servers (as opposed to having all of the code for an application on one server), and the Java Connector Architecture, which helps developers include older, pre-Java applications and data sources in their applications. These advanced technologies geared toward large businesses make up the J2EE standard, which was briefly mentioned at the start of this chapter.
A servlet container alone isn’t sufficient to power J2EE applications. Instead, an application server is required. This supports all of the J2EE technologies, is usually much more feature-rich than a servlet container such as Tomcat, and often includes features that enable it to service many more users than a typical servlet container. However, because JSP and servlets compose a key part of the J2EE platform, application servers also must support the same features that a servlet container does—and often, an application server simply integrates with one of the existing servlet containers.
Although application servers can set you back tens of thousands of dollars, some free application servers are available, such as jBoss (http://www.jboss.org).
In this chapter, we’ve tried to get you up and running as a budding Web developer. You’ve done the following:
Installed the basic tools you need to create Java Web applications
Created your first simple Web application
In subsequent chapters, you’ll build on this foundation to create increasingly complex and useful Web applications, and you’ll also learn more details about how the Java language works.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.