JavaServer Pages, conclusion - Summary (Page 7 of 7 ) In this chapter, we've taken a tour of many of the basic features of JSP pages. With the information in this chapter, you should be able to easily begin creating JSP web applications of your own. After completing this chapter you should have learned: - JSP pages consist of HTML data, also known as template data, and Java code.
- You can specify an error page for a JSP using %@page errorPage=""% . Error pages are used to provide a meaningful error page to a user when something bad happens to the web application.
- You can import Java packages for the page using <% pageimport="" %>.
- Java code is included in the page using a declaration <%!declaration %>, a scriptlet <% scriptlet %>, or an expression <%= expression %>. These elements allow you to mix Java code with the template data in the page.
- JavaBean instances can be created using the <jsp:useBean> standard action; properties of the bean can be set using <jsp:setProperty>; and the value of a beans properties can be obtained using <jsp:getProperty>. JavaBeans are one way to encapsulate business or domain logic so that JSP pages can be used primarily for presentation.
- Various implicit objects such as request, response, out, session, and so on, are always available to the JSP to help process a request. The session object is particularly useful because it enables the web application to keep track of user information. One example of the usefulness of this is an e-commerce application that needs to keep track of a users shopping cart.
- Servers translate and compile JSPs into Java classes that behave like servlets.
- You can specify error handlers for the entire application using the <error-page> element in the deployment descriptor.
- A JSP can include the output of other JSPs or servlets in the response to clients. This is done through the <jsp:include> standard action.
- A JSP can forward a request to another JSP or servlet for processing. This is done through the <jsp:forward> standard action.
Thats quite a lot. All these features put together allow application developers to create dynamic and powerful web applications that can be used for many purposes from chat rooms to e-commerce, from virtual communities to business applications. However, you may have noticed that as the examples in this chapter became more dynamic, more featured, they also tended to have more and more Java code interspersed in the JSP pages. This tends to be a problem because web page developers are often not Java developers. What would be ideal is a way to create JSP pages that hide the Java code from the page developers. This would allow the page developer to concentrate on the format and structure of the markup, and leave Java developers free to work on only the Java code. There are several ways to do this, and we will see some of them in the next chapter, where we explore some of the new JSP features introduced in the latest version of the JSP specification. | 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. |
| This article is excerpted from chapter three of Beginning J2EE 1.4 From Novice to Professional, written by James L. Weaver, Kevin Mukhar, and Jim Crume (Apress, 2004; ISBN: 1590593413). Check it out at your favorite bookstore today. Buy this book now.
|
| |