Archive for October, 2006

[ Team LiB ] 2.2 JSP Errors As

Sunday, October 29th, 2006

[ Team LiB ] 2.2 JSP Errors As smart as the JSP engine is, it is also very literal minded. Like any other program ever written, the best it can manage is to do what we say, which is not always the same thing as to do what we want. When a JSP page does not specify what to do in exactly the right way, the JSP engine sometimes has no alternative but to give up, return an error page, and ask for help. One common error is leaving out a closing tag. This might happen if a page author tries to close a JSP comment as if it were an HTML comment, as in <%-- our first JSP -->. A user who tries to access this page will receive a rather unsettling page giving a great deal of information about the cause and nature of the error. The exact format of this message varies between JSP engines; Tomcat generates a page such as the one shown in Figure 2.1. Figure 2.1. The Tomcat error page. [View full size image] The most significant part of this message is the first exception line, which contains the following: /error1.jsp(1.4) Unterminated <%-- tag This line concisely specifies what the problem is, along with the name of the file in which the error occurred. The numbers in parentheses are the line number and the number of characters within the line where the problematic tag starts. A variation of this problem is even more insidious. Consider the following JSP snippet: <%-- This is a comment --> Hello, world. <%-- This is another comment --%> When a browser requests this page, the content will be missing, but no error will be generated. The reason is that this time, the comment tag is closed; it just happens to be Page 24
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services

[ Team LiB ] 2.1 Removing Text from

Saturday, October 28th, 2006

[ Team LiB ] 2.1 Removing Text from a JSP All it takes is a small change to Listing 2.1 in order to start exploring some of the things the JSP engine can do. Note that the HTML comment, “Our first JavaServer Page,” has turned into a program instruction that sends the comment to the user. To people building and maintaining pages, these kinds of comments are often useful because they can clarify what a block of otherwise indecipherable HTML is meant to be. However, because it is a regular part of the document, this comment will show up in the “view source” function of a user’s browser. This is typically not a problem, although it is possible for these comments to contain implementation details that might be confidential. Or maybe a page author was having a bad day and used some comment space to rant about his or her boss or relationship or the state of the world. These comments can be quite embarrassing if anyone happens to see them. So, here is a dilemma. Comments are useful to authors but useless, or worse, for readers. JSP has a solution to this. The preceding HTML comment could be replaced with a JSP comment, like so: <%-- Our first JavaServer Page --%> When it sees this tag, the page compiler will recognize it as a comment and will not put it into the servlet that it builds. Hence, this comment will never be sent to the user and will not show up when the user does a view source. Again, this effect is subtle and, frankly, not that exciting. However, it does begin to show that what goes into a JSP file can and will be different from what comes out. Further, this adds a third rule to the JSP programming language: Text enclosed between comment tags (<%--and --%>) does not turn into an instruction at all but is simply ignored. [ Team LiB ] Page 23
Note: If you are looking for good and high quality web space to host and run your java application check Vision java hosting services

[ Team LiB ] Page 22

Saturday, October 28th, 2006

[ Team LiB ] Page 22
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

[ Team LiB ] Chapter 2. Simple JSPs

Saturday, October 28th, 2006

[ Team LiB ] Chapter 2. Simple JSPs Chapter 1 presented the case for dynamic sites and surveyed a number of techniques for building such sites, focusing on the strengths of JavaServer Pages technology. With these preliminaries out of the way, everything is in place to start creating some pages! This chapter begins by introducing some of the simpler features of JSPs. It is a time-honored tradition for computer blogs to start with an example that allows the system being studied to introduce itself. This blog is no exception, so without further delay, Listing 2.1 contains our first JSP. Listing 2.1 A simple JSP Hello, world! This may look like a plain old chunk of HTML, not a very interesting one at that. However, when saved in a file called index.jsp and given to a JSP engine such as Tomcat, this chunk of HTML becomes much more than a static block. In fact, this is a program very similar to the programs in Listings 1.2 and 1.3. As a program, this file contains a series of instructions that the JSP engine will follow. Written out in English, these instructions are equivalent to the following:[1] [1] This isn’t quite true. For the sake of efficiency, most JSP engines send out contiguous chunks of HTML all at once. However, it is often helpful to think of JSPs as being processed one line at a time. 1. Send the text to the user. 2. Send the text to the user. 3. Send the text to the user. 4. Send the text Hello, world! to the user. 5. Send the text to the user. 6. Send the text to the user. More technically, a program called the page compiler converts the original file into another little Java program, a servlet as discussed in Section 1.3. This servlet is what gets run. Servlets are an important technology, and they are covered in more detail in Chapter 11. For the time being, these details are unimportant, and it is perfectly reasonable to think of the JSP file itself as the program. At this point, three different things are all going by the name index.jsp. One is the original file, sitting in a directory from where it can be edited like any other file. Second is the servlet, which is managed by the JSP engine and is generally not meant to be seen directly. Third is the URL and the corresponding page as seen in a browser. To avoid confusion, the specific meaning will always be indicated when it is not clear from the context. In this particular case, all the extra work of creating and running a program has not accomplished anything. However, the translation has not been pointless, as it has created a program from HTML. This is why JSP authors generally do not need to do much programming Page 21

Note: If you are looking for good and affordable webspace to host and run your servlet application check Virtualwebstudio servlet hosting services

[ Team LiB ] 1.5 Trying the Examples

Saturday, October 28th, 2006

[ Team LiB ] 1.5 Trying the Examples All the examples in this blog have been included on the companion CD-ROM, so readers can see them in action and experiment with changes. The CD-ROM also includes Tomcat, the high-performance JSP engine provided for free by the Apache project, at http://jakarta.apache.org. The version included is 5.0, the first implementation of the JSP 2.0 and servlet 1.3 specifications. The CD-ROM also includes a number of third-party libraries that provide useful utilities. These libraries include HypersonicSQL, a file-based database written in Java; Jaxen, a set of Java classes for working with XML; and the Canetoad utilities, which provide a number of utilities for working with beans. Instructions for installing and running the examples can be found in the index.html file on the CD-ROM. Most users can simply double-click this file to get started. [ Team LiB ] Page 20
Note: If you are looking for good and quality webspace to host and run your java application check Actions java hosting services

[ Team LiB ] 1.4 Welcome to Java

Saturday, October 28th, 2006

[ Team LiB ] 1.4 Welcome to Java News Today Throughout this blog, we will be following the evolution of a fictional Web site called Java News Today. JNT is a start-up company of Java enthusiasts who want to create a compelling, up-to-the-minute site covering all things Java. Because it wants to attract and maintain an audience, JNT will make its site as dynamic as possible. In addition to updating the content frequently, the site is to have games, polls, search functionality, and other interactive features. JNT also considers it very important to allow users to customize and adjust the site to fit their own needs. The folks at JNT hope that lots of users will make JNT their home page and that no users will move into a home they cannot decorate themselves. Everyone at JNT will openly admit to being a fan of the Slashdot site, at http://www.slashdot.org, and the Java Lobby, at http://www.javalobby.org. Readers familiar with those sites may notice some similarities in the features that JNT is trying to build. But then, imitation is the sincerest form of flattery. [ Team LiB ] Page 19

Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Virtualwebstudio tomcat web hosting provider

[ Team LiB ] Page 18

Friday, October 27th, 2006

[ Team LiB ] Page 18

Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Virtualwebstudio tomcat web hosting provider

Page 17

Friday, October 27th, 2006

Page 17
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

Page 16

Friday, October 27th, 2006

Page 16
Note: If you are looking for cheap and reliable provider to host and run your servlet application check Vision servlet hosting services

Page 15

Thursday, October 26th, 2006

Page 15
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services