Topics in This Chapter
Understanding the benefits of JSP
Invoking Java code with JSP expressions, scriptlets, and declarations
Structuring the servlet that results from a JSP page
Including files and applets in JSP documents
Using JavaBeans with JSP
Creating custom JSP tag libraries
Combining servlets and JSP: the Model View Controller (Model 2) architecture
JavaServer Pages (JSP) technology enables you to mix regular, static HTML with dynamically generated content. You simply write the regular HTML in the normal manner, using familiar Web-page-building tools. You then enclose the code for the dynamic parts in special tags, most of which start with <% and end with %>. For example, here is a section of a JSP page that results in “Thanks for ordering Core Web Programming” for a URL of http://host/OrderConfirmation.jsp?title=Core+Web+Programming:
Thanks for ordering <I><%= request.getParameter("title") %></I>
Separating the static HTML from the dynamic content provides a number of benefits over servlets alone, and the approach used in JavaServer Pages offers several advantages over competing technologies such as ASP, PHP, or ColdFusion. Section 3.2 gives some details on these advantages, but they basically boil down to two facts: JSP is widely supported and thus doesn’t lock you into a particular operating system or Web server; and JSP gives you full access to the Java programming language and Java servlet technology for the dynamic part, rather than requiring you to use an unfamiliar and weaker special-purpose language.
52.14.172.93