"A direct attribute can be specified for template:put; if direct is set to true, the content associated with the tag is not included by template:get, but is printed directly to the implicit out variable. In Example 2.b, for example, the title content -- JSP Templates -- is used for the window title."
"The Struts package, which is part of the open source Jakarta project, provides a well-thought-out MVC (model-view-controller) framework that many projects would do well in adapting at the start of their Website development. The custom tags represent the view part of that framework, but it is perfectly feasible to use the tags without the model and controller part."
"The first group of rows in Table 1, up to Authors, should be fairly self-explanatory. The subsequent rows indicate the version or level of coverage that the books offer for each category. Here are some things to note:"
"In this article, I will examine the handling of a user registration form using JSP. One of the basic programming tenets of JSP is to delegate as much processing as possible to JavaBean components. My JSP form-handling implementation will demonstrate some interesting features. It will not only provide basic data validation for the registration information input by a user, but will also exhibit stateful behavior. This lets you pre-fill the form's input elements with validated data as the user loops through the submission cycle and finally enters the correct data for all of the input elements. So, without further ado, let's dive into the example."
"The Model 2 architecture, shown in Figure 2, is a hybrid approach for serving dynamic content, since it combines the use of both servlets and JSP. It takes advantage of the predominant strengths of both technologies, using JSP to generate the presentation layer and servlets to perform process-intensive tasks. Here, the servlet acts as the controller and is in charge of the request processing and the creation of any beans or objects used by the JSP, as well as deciding, depending on the user's actions, which JSP page to forward the request to. Note particularly that there is no processing logic within the JSP page itself; it is simply responsible for retrieving any objects or beans that may have been previously created by the servlet, and extracting the dynamic content from that servlet for insertion within static templates. In my opinion, this approach typically results in the cleanest separation of presentation from content, leading to clear delineation of the roles and responsibilities of the developers and page designers on your programming team. In fact, the more complex your application, the greater the benefits of using the Model 2 architecture should be."
"JavaBeans are reusable software components. It's true that there are JSP tags that let you use JavaBeans within your pages. The only ability those tags allow you, however, is to bind named, scoped instances, and then get/set those instances' properties. If you need to call methods on your JavaBeans, you need to embed the appropriate Java code inside a scriptlet."
"JSP 2.0 uses the deployment descriptor (web.xml) file format defined by the servlet specification, just as in earlier versions of the JSP spec. There are, however, two important changes for JSP 2.0: the rules for the web.xml file are now defined by an XML Schema, and most of the JSP-specific configuration items have been moved to a new XML element, which is under the control of the JSP specification (to minimize the coupling between the servlet and JSP specifications)."
"While Web application developers all over the world have been busy developing new applications based on JSP 1.1, the JSP 1.2 specification has been taking shape within the Java Community Process group called JSR-053. Members of this group include authors, application server developers from big and small commercial vendors as well as the open source community, and servlet and JSP developers."
"Content caching is one of the most common optimization techniques used in web applications, and it can be implemented easily. For example, you can use a custom JSP tag--let's call it <jc:cache>--to wrap every page fragment that must be cached between <jc:cache> and </jc:cache>. Any custom tag can control when its body (i.e. the wrapped page fragment) is executed, and the dynamic output can be captured. The <jc:cache> tag lets the JSP container (e.g. Tomcat) generate the content only once, storing each cached fragment as a JSP variable in the application scope. Every time the JSP page is executed, the custom tag inserts the cached page fragment without re-executing the JSP code that generated the output. A tag library developed as part of the Jakarta project uses this technique, and it works fine when the cached content doesn't need to be customized for each user or request."
"JSP tags are especially suited for repetitive tasks such as looping over an array, doing browser checking, and validation. Creating hyperlinks is another such repetitive task. Below, I will describe a custom tag for generating multi-destination hyperlinks."
"Prior to JSP 2.0, a JSP Document had to have a <jsp:root> root element, to tell the container what type of JSP page it was. JSP 2.0 removes this limitation by defining new ways to identify a file as a JSP Document. A file is processed as a JSP Document by a JSP 2.0 container if one of these conditions is true:"
"JSP is all about generating dynamic content: content that differs based on user input, time of day, the state of an external system, or any other runtime conditions. JSP provides you with lots of tools for generating this content. In this book, you will learn about all of them--standard actions, custom actions, JavaBeans, and scripting elements. Before we do that, however, let's start with a few simple examples to get a feel for how the basic JSP elements work."
"Adding JSP to the puzzle lets you solve these problems by separating the request processing and business logic code from the presentation, as illustrated in Figure 3-1. Instead of embedding HTML in the code, you place all static HTML in a JSP page, just as in a regular web page, and add a few JSP elements to generate the dynamic parts of the page. The request processing can remain the domain of the servlet, and the business logic can be handled by JavaBeans and EJB components."
"While having similar concepts to Java Server Pages (JSP), there are a number of differences present in XSP. We will look at both technologies to see how they stack up against each other. This article assumes you have at least some understanding of XML and its terminology."
"JSP Overview, Part 1 In part one of two book excerpts on JSP Overview from JavaServer Pages, 2nd Edition, understand the problem with Servlets as well as the anatomy of a JSP page."
"The latest version of the JSP specification, JSP 1.2, was released on September 17, 2001. In part one of this article, I described a number of new features that have been added to the specification. In this article, I focus on the details concerning the custom tag handler API."
"A Web application that is accessible via several URLs is susceptible to URL-probing attacks. You may intend that your users access the individual application URLs in a way that makes sense for your application. However, some users (and most hackers) may not comply. Instead, they'll jump straight to the middle of your application and request URLs that are carefully calculated to circumvent your application's security features."
"Some of these issues arise from the nature of the current JSP usage patterns, rather than the JSP itself. I would like to present here a concept called "Transparent Data Pipelines" (TDP), which borrows elements from the following proven metaphors:"
"The next big shake-up in the industry is wireless. The benefit of wireless applications, however, becomes useful for organizations when their employees can access critical business data efficiently from anywhere they go. Therefore, the interaction between wireless applications (such as MIDlets) and external enterprise systems is important, but how can this be done?"
"In this final part of the "JSP 2.0: The New Deal" series, we look at two new features that make it much easier to develop custom tag libraries: tag files and the new simplified tag-handler Java API."
"How you would accomplish this in JSP is left to the reader. If you imagine a more complex dynamic HTML page than the one I have presented, there is a lot that can go wrong in the JSP document, especially if the customer is new to JSP. In theory, the packaging of the application should make it so that no Java knowledge is required whatsoever. Only HTML skills are necessary. In the XMLC example, all they need to know is "don't change the ID attribute name"."
"JavaServer Pages, together with the Java Servlet, provide the dynamic web content presentation layer for the Java 2 Enterprise Edition. JSPs and Servlets integrate tightly to enable scalable and portable applications, and are widely supported. This book targets the next generation of these technologies, JSP 1.2 and Servlets 2.3, which are nearing completion under the Java Community Process and provide major enhancements to Java's web programming model."
"JSP developers will notice similarities between the syntax of JSTL and ColdFusion tags. Unlike JSTL, ColdFusion contains a much larger set of tags and almost 300 functions for string processing, date and time manipulation, encryption, XML, and more. Although you can use Java classes or libraries directly, using the built-in ColdFusion tags such as CFFILE, CFDOCUMENT, CFHTTP, CFTP, and CFMAIL make light work of many things such as creating PDF documents, retrieving remote files via FTP, and sending emails."
"There are thousands of news sites and blogs out there with feeds available in this format. Just think -- instead of doing the normal morning check on Slashdot, Freshmeat, or wherever, what if their content was delivered straight to your own personal portal, or RSS aggregate service? Implementing such a solution is very simple -- in the rest of the article we'll look at how we can process this data and display it on our JSP pages."
"JavaServer PagesTM (JSP) technology provides an easy way to create dynamic web pages that simplify the task of building web applications. JSP works with a wide variety of web servers, application servers, browsers and development tools, and keeps content generation separate from business logic."
"For context, this article starts with a brief introduction to the JavaServer Pages technologies, so you can better understand how to use them to approach internationalization issues. I then discuss several core problems intrinsic to the development of multilingual web applications, and describe how to solve them using JavaServer Pages technologies: locale determination and localization, character encodings, and formatting and parsing."
"JSP technology is being used everywhere on the Web including airline reservation systems, banking systems, and shopping. The new release, Version 2.0, is an upgrade to JSP 1.2 with several interesting new features. The objective of JSP 2.0 is to make the task of developing dynamic Web pages easier than ever without having to learn the Java programming language."
"JavaServer Pages(JSP) technology provides an easy way to create dynamic web pages and simplify the task of building web applications that work with a wide variety of web servers, application servers, browsers and development tools. This article provides an overview of JSP from a developer's perspective, and includes examples of JSP in action."
"HTML form button elements -- such as radio buttons and checkboxes -- are used in most of the forms currently on the web. In many cases, these forms are created by JavaServer Pages (JSP) on the server side. Often, it's necessary for buttons to be selected in advance-- for instance, the first time the form is displayed, or when the form is redisplayed after the user makes an unacceptable entry somewhere. In these cases, the dynamic information required to determine which buttons to select -- that is, the state of these buttons -- must be transported into the JSP pages, so that the checked attribute can be dynamically included in the <input> tag."
"Have you ever created a web page with a lot of detailed information and wanted an easy way for your readers to parse and filter page entries based on user-specified keywords? This article explains how to use an HTML form and JavaServer Pages (JSP) technology to do exactly that. And even if you have never wanted to do this, you might find the example demonstration and code walkthrough useful because they cover how to retrieve request values and compare them to values in lines read from a static file."
"Use iFrames as a means of submitting and receiving values from the Web server. Used with JavaScript and JSP code, iFrames elegantly resolve the "hang" issue."
"Much has already been written about JSF, and based on the high number of posts to Sun's JSF Developer Forum, many are already kicking its tires and use JSF for both prototypes and real applications. But as with any new specification, JSF 1.0 has some rough spots. In this article, I focus on one specific area of the JSF specification that I feel is riddled with problems: namely, the use of JavaServer Pages (JSP) for creating JSF views. I also discuss alternatives to JSP that you can develop today and that I hope will make it into a future version of the specification."
"The next step in writing a custom JSP tag is to implement the Java code for the tag. In this article, the tag imagesizer is implemented in the tags.ImageSizerTag Java class. Most of the J2EE custom tag support is located in the javax.servlet.jsp.tagext package. The imagesizer class extends the standard TagSupport, which implements tags without bodies. Its descendant class is BodyTagSupport, which also implements tags with bodies. Both classes implement the Tag interface, of which the methods doStartTag and doEndTag are called when the tag is first read and again after the tag is fully read by the Web container. The ImageSizer tag only implements the doEndTag because it needs to act once all attribute information is available."
"Ben Forta, Sams, 2000 $49.99, 416 pp., ISBN 0-6723-1939-X According to the introduction of JavaServer Pages Application Development, this book will teach you JSP technology "even if you have no Java experience whatsoever." If the target audience of the book is the HTML developer, as the introduction claims, the book is an utter failure when compared to the other books in this review that target that same audience."
"In the last installment of JSP best practices, you learned a scriptlet-based technique for adding last-modification time stamps to your JavaServer Pages (JSP) files. Unfortunately, scriptlets introduce more long-term complexity to your pages than they offer in terms of short-term benefit. They interweave all sorts of HTML with Java code, which makes debugging and authoring tricky. They aren't reusable, which often leads developers to cut-and-paste between JSP pages, which in turn leads to multiple versions of the same piece of code. And they make error reporting difficult, since JSP pages have no clean-cut way to spit out script errors."
"Time stamps are typically used on simple Web sites, like personal sites or content-driven ones, letting users see when the page was last updated. As a result, it is easy to overlook their essential usefulness, particularly for e-commerce sites. In this tip, I'll show you how adding time stamps to your JSP pages can lead to a more easeful experience for users, as well as opening the door to personalization on your site."
"Up to this point in our discussion of JSP custom tags, we've managed to sidestep the important detail of error handling. Many of the best practices that we addressed in the first half of the series dealt with functionality provided by your JSP container, such as the param, out, and import tags. In these cases, error handling was the domain of the JSP specification and Web server implementation, which means that even if we wanted to do something about it we couldn't."
"You need to be aware of unique requirements when you design internationalized JSP applications. Your applications must be prepared to support multiple concurrent access by users with differing locale requirements. This article has presented two solutions to the problem of displaying locale-specific language text for internationalized JSP applications. But I've only scratched the surface of the fascinating art of creating internationalization-ready server-side applications. Other important issues include working with different date and currency formats, managing GUI layouts, and dealing with specialized Input Method Editors (IMEs, utility software for entering foreign characters). See Resources for information that can help you explore internationalization further."
"So far in this series we've kept our custom taglibs in a local filesystem, where we could easily access and manipulate them. While local access is great for in-house development and testing, it's not a good permanent solution. The whole point of custom taglibs is that they should be widely accessible, which means they must be distributed in a standardized way that also allows for some essential security measures. In this installment of JSP best practices, you'll learn how to package your custom taglibs in a JAR file for safe and easy distribution."
"This concludes an introduction to combining the JavaServer Pages, JavaBeans, and JDBC technologies to generate dynamic content through relational databases. We started with the most obvious approach for the new JSP programmer: scriptlets. We saw how the uncontrolled use of scriptlets intertwines logic and presentation, making both of them hard to maintain. We also saw that tag libraries don't necessarily improve MVC separation, and that the pages using them may not be understandable to page designers if the tags are expressed in programming terms. Finally, we looked at more complex examples that illustrate a few ways to separate database access from the presentation of content."
"As with any technology platform, JSP does have limitations. One such limitation is that most containers still require Java as the JSP scripting language. Another is the fact that most tag libraries to date do not address the needs of Web page designers. But the solution isn't investment in alternative architectures. I believe we're better off encouraging vendors to invest resources in enhancing the common platform. For example, the JSP specification has accommodated multiple scripting languages since v1.0. This feature is implemented in IBM WebSphere. Since IBM has released the underlying Bean Scripting Framework as open source (see Resources), we should expect that BSF eventually will be integrated into the JSP container reference implementation, which is part of Jakarta, as well as other commercial JSP containers."
"Custom JSP tags give those front-end developers the means to control how data is processed in back-end Java components without requiring any Java code in the JSP page."
"SSIs are a workable solution for including different types of content in your Web site or Web application, but they're not the best choice for Java developers. Not only does JavaServer Pages technology provide an all-Java alternative to SSIs, but the two technologies aren't easily combined. JSP pages end in the extension .jsp, which means that for SSI directives to work you have to either change your SSI configuration to also parse JSP files (adding overhead to every JSP page parse), or change your JSP configuration to treat the .shtml extension as a JSP page (which is a bad idea). JSP technology is the best content management solution for Java developers, and fortunately its include mechanism is a snap to learn."
"While include works very well for incorporating static content into your Web pages, it doesn't work so well for dynamic content. We discovered this in the last installment when we attempted to reload a cached file. Unlike most header and footer files, dynamic content changes frequently and must always be up to date. We'll start out with a quick recap of the limitations of the include directive, then I'll show you how to extend the JSP inclusion capability with the jsp:include tag."
"The first thing we need is some sort of object to store the data being passed around. It just so happens (not by accident) that JavaBeans components are both suitable for this purpose and a perfect match for JSP technology. The bean simply needs to have accessor and mutator methods to handle the data. As you may know from your other Java programming experience, get() is an accessor method, because it accesses data, and set() is a mutator method, because it mutates, or changes, data."
"The last installment of JSP best practices was a crash-course introduction to the JSTL. I showed you how to load JSTL on your Web container and convert a JSP file to use JSTL tags. While we were at it, I briefly introduced the c:import tag. Like jsp:include, c:import uses parameters to intelligently move content around on your Web site. But unlike the include directive, c:import doesn't limit its reach to local files."
"This tutorial introduces the fundamentals of JavaServer Pages (JSP) technology 2.0 and provides an update to the original tutorial written by Noel J. Bergman that discussed JSP 1.2. This tutorial provides a solid grasp of JSP basics to enable you to start writing your own JSP solutions. This tutorial will discuss the fundamental elements that define JSP, identify and exemplify each element, use topical examples to illustrate each element and clearly illuminate important issues related to that element."
"Presentation technology was designed to transform plain ol' raw Web content into content wrapped in an attractive presentation layer. JavaServer Pages (JSP) technology, Sun's presentation model and part of the J2EE platform, has received significant attention. There are both advantages and disadvantages to using JSP technology, and Web developers should be aware of the good and the bad -- and know that they don't have to be limited to this single technology. In fact, these days a number of presentation technologies are available. This article begins by defining the problems presentation technologies were designed to solve. It then examines the specific strengths and weaknesses of the JSP model. Finally, it introduces some viable alternatives to Sun's presentation technology."
"When Sun introduced JavaServer Pages, some were quick to claim that servlets had been replaced as the preferred request handling mechanism in Web-enabled enterprise architectures. Although JSP is a key component of the Java 2 Platform Enterprise Edition (J2EE) specification, serving as the preferred request handler and response mechanism, we must investigate further to understand its relationship with servlets."
"In the sections that follow, you'll learn, step-by-step, how to meet these requirements and incorporate custom tags into your JSP pages. Here are the five steps between you and a successful JSP custom tag implementation:"
"The last installment of JSP best practices introduced the basics of using custom tag libraries in your JSP pages. You learned how to define a simple tag and then make it available through a tag library descriptor (TLD) to other JSP authors. This week, we'll build on what you already know about custom tags. The example tag we worked with last time was quite simple, almost to a fault. So we'll extend its functionality by incorporating custom attributes."
"With JSP, fragments of Java code embedded into special HTML tags are presented to a JSP engine. The JSP engine automatically creates, compiles, and executes servlets to implement the behavior of the combined HTML and embedded Java code."
"Generating dynamic content in Web applications is important when the content must reflect the most current and available data and personalized information. One of the main advantages of JavaServer Pages is the ability to generate dynamic content. JSPs generate dynamic HTML pages by using Java control structures like for loops and if statements. As a result, forms can be generated dynamically following some specified logical layout."
"Because of the breadth of the JavaBean component aspect of JSP, I have broken this topic into several lessons. The previous lesson (see JavaServer Pages and JavaBean Components, Part I ) taught you how to"
"Making the leap from the world of desktop applications to web-based applications usually means a sacrifice in terms of functionality. Components such as tabbed panes, context-sensitive menus, and tree menus are thick client standards, but it is difficult to duplicate these objects in a web environment. The last project we will look at, pragmaticObjects, provides a number of web components, made available through a set of JSP tags, to rival the look and capability of desktop components. Almost every Web application requires some sort of navigation between pages. Typically, accomplished with the standard HTML hyperlink, there is significant room for improvement in this area. The current set of components that pragmaticObjects provides include an outlookBar similar to what you might see in Microsoft Outlook, a controlPanel that mimics a Windows control panel, and a tree capable of providing context-sensitive menus for each of its nodes."
"This encoding is clearly unsuitable for transferring security sensitive information, since the full URL and the request string normally travel in clear text over the communication channels and get logged on all intermediate routers as well as on the server. When valuable information needs to be transmitted as part of the client request, the POST method should be used, with a suitable encryption mechanism (e.g. over an SSL connection). From the point of view of the JSP engine, which method is used is largely irrelevant -- both methods are handled identically."
"Many Web sites depend on the ability to generate tables dynamically, which consists of controlling the TR and TD tags within a TABLE. The online stock portfolio mentioned earlier is a good example where dynamic tables are useful."
"Because of the breadth of the JavaBean component aspect of JSP, I have broken this topic into several lessons. The previous lesson: JavaServer Pages and JavaBean Components, Part II taught you how to use the <jsp:setProperties...> tag and the <jsp:getProperties...> tag to set and get the property values for a Bean that adheres to design patterns."
"Database connectivity seems to be an important piece in most Web applications. We are also seeing an increasing number of applications that treat a database as an abstract "data source"which may or may not be a relational database. Other viable data sources include XML documents, Web sites, and legacy/proprietary systems. Looking at JSP, it is easy to get engulfed with the intermixing of HTML and Java and wondering how databases would fit the model. It should be noted, however, that the JSP page consisting of Java and HTML will actually be translated into a Java servlet code, compiled and executed as a servlet. Therefore, the problem of database (data source in abstract terms) connectivity, boils down to how servlets utilize databases. Most of the issues such as connection pools, session objects to keep state, and request/response model of HTTP are well documented as servlets have matured."
"When the HTML page containing the Java code fragments is presented to a JSP engine, the JSP engine automatically creates, compiles, and executes servlets to implement the behavior of the HTML and the embedded Java code."
"The BodyTagSupport class provides a method called getBodyContent() which is what you use to get a BodyContent object. Access to the tag body provides additional flexibility to a JSP programmer. Users familiar with HTML can insert specific data inside the JSP page (using custom tags). By accessing the tag body, your custom tags can extract and transform that data into a suitable format. For example, raw numerical data can be transformed into an HTML table. By providing various attributes for the tag, you can further customize the behavior of the tag."
"The JSP engine returns the comment as part of the HTML output that it sends to the client. The browser doesn't render HTML comments in the standard browser window. Therefore, you must view the HTML source via your browser to see the comment and the output from any embedded expressions."
"Of necessity, this lesson can provide little more than an overview of the subject of JavaBean components. You are encouraged to review the tutorial lessons on JavaBean components mentioned above to learn more about the details."
"With JSP, fragments of Java code embedded into special HTML tags are presented to a JSP engine. The JSP engine automatically creates, compiles, and executes servlets to implement the behavior of the combined HTML and embedded Java code."
"Welcome to JavaServer Pages (JSP)! Over the next 21 days, you'll get an in-depth guided tour of the ins and outs of JSP. From the most basic aspects to the most advanced, we're going to become masters of JSP in this book. You've come to the right place."
"This article pick up where our earlier article, Dissecting Java Page Flows ended. In the following sections, we'll talk about the basic architecture and components that make up Java Page Flows and the NetUI tags."
"The first two page directives specify values for the import attribute. You will recognize the values of these attributes as being very similar to the import directives in a Java program."
"Since its introduction just a few months ago, Java Server Pages (JSP) technology has captured the attention of Java and Web developers. JSP offers a unique environment to create highly dynamic Web applications. In this part of our article, we'll introduce JSP and help you set up an environment where you can experiment with some examples. We'll also cover some advanced features of JSP and what makes it a unique and dynamic framework for development of Web applications."