Archive for November, 2006

[ Team LiB ] 5.7 The Article Page

Monday, November 20th, 2006

[ Team LiB ] 5.7 The Article Page The article page consists of two pieces: the contents of the article and the comment region, which allows users to comment on stories and read others’ comments. The first portion is even simpler than the section page, as it need only display the contents of a few properties from the ArticleBean, as shown in Listing 5.8. Listing 5.8 The article page

Posted by at

Note the use of the fmt:formatDate tag from the previous chapter to format the date. The comment portion appears below the article contents and shows the list of available comments, along with a form to add an additional one, as shown in Listing 5.9. Listing 5.9 The comment section



Comments

Posted by at



Comment on this article

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

[ Team LiB ] Page 101

Sunday, November 19th, 2006

[ Team LiB ] Page 101
Note: If you are looking for good and quality webspace to host and run your java application check Actions java hosting services

[ Team LiB ] 5.6 The Section Page

Sunday, November 19th, 2006

[ Team LiB ] 5.6 The Section Page Listing 5.3 showed how the section page will be called from the list of available sections and how this page will be passed a sectionId as if a form had sent it. This means that it will be possible to use a bean and a jsp:setProperty to tell that bean which section was selected, just as was done in the section list to place an asterisk in front of the current section. If the section bean is designed to load up all the stories in a section when the sectionId property is set, all that is necessary to build the section page is to iterate the available articles with a c:forEach tag. That is exactly what Listing 5.7 does. Listing 5.7 The section page

“>

If this looks very similar to the section list from Listing 5.3, it should! They both do essentially the same thing; the only significant difference is that the items in this example are in a definition list instead of an unordered list. In particular, the c:url tag is used in both. Figure 5.3 shows how the section page looks in a browser. Figure 5.3. The JNT section page. [View full size image] Page 100
Note: If you are looking for cheap and reliable provider to host and run your servlet application check Vision servlet hosting services

[ Team LiB ] 5.5 The Quiz Result

Sunday, November 19th, 2006

[ Team LiB ] 5.5 The Quiz Result Page Chapter 3 introduced the daily quiz that Java News Today will use to liven up its site. The quiz consists of a serialized bean that holds the questions and correct answer, along with a form from which the user can guess, as shown in Listing 3.13. At that point, there was no way to check whether the user was correct, but that’s easily remedied now that we have the standard tag library at our disposal. The quiz result page, shown in Listing 5.6, it is very straightforward. Listing 5.6 The quiz result page <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> That’s right!

Sorry, that’s incorrect; the right answer is

This is another example of setting bean properties from a form and then checking a condition with a c:choose tag. [ Team LiB ] Page 99
Note: If you are looking for good and quality webspace to host and run your java application check Actions java hosting services

Page 98

Saturday, November 18th, 2006

Page 98
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

[ Team LiB ] 5.4 The Login Page

Saturday, November 18th, 2006

[ Team LiB ] 5.4 The Login Page Now that a form has been provided so users can log themselves in on the system, there needs to be a page that will perform the necessary actions. The page that does this is shown in Listing 5.5. Listing 5.5 The login handler <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> You have sucessfully logged into Java News Today!

Click here to proceed to your custom edition. We’re sorry, we were unable to log you in. Perhaps you mistyped your username or password; use the form on the left to try again. This page begins with the usual things, including loading the UserInfoBean. The bean’s properties are then set: the username and password from the login form in Listing 5.2. Part of the UserInfoBean’s job as the model of users is to provide a mechanism that logs a user in on the system, given the username and password. This mechanism is triggered by setting the login property of the bean, which will cause the bean to check these values against a list of all users in the system; if a match is found, the isLoggedIn property will be set to true. This setting of properties has to be done before the page top is included. If it were done afterward, the user’s isLoggedIn property would still be false during processing of the header and navigation, and consequently the name would not be shown and the login form would. The rest of the page is pretty anticlimactic: another c:choose tag used to determine whether the login succeeded and to display an appropriate message in either case. [ Team LiB ] Page 97
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services

[ Team LiB ] Page 96

Saturday, November 18th, 2006

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

Page 95

Saturday, November 18th, 2006

Page 95
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services

Page 94

Friday, November 17th, 2006

Page 94
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services

[ Team LiB ] 5.3 The Left-Hand Navigation

Friday, November 17th, 2006

[ Team LiB ] 5.3 The Left-Hand Navigation The left side of the page has thus far contained only the daily quiz, which was developed in Listing 3.13, and a link to the customization page. This will now be enhanced by the addition of a login box from which the user can log in. This will also be a simple form, but in the interest of encapsulation, it will be placed in its own file and included with a jsp:include. Listing 5.2 shows the new login form. Listing 5.2 The login form
Username:

Password:

This file contains no beans, scripts, or special tags, which should come as no surprise. There have already been many examples of forms that provide values to beans, and in all these cases, the forms themselves need not know anything about the beans, as all the action happens on the receiving page, where the form values are loaded into a bean with the jsp:setProperty tag. The only requirement for this to work is that the bean’s properties must be called username and password. Because these names were chosen in the data-modeling phase, both the author of this form and the author of the UserInfoBean will know to use those names. The implementation of the UserInfoBean used in this chapter knows about one user whose username and password are both “test”, so those are the values to enter into the login form when exploring the examples on the CD-ROM. The other necessary element of the left-hand navigation is the list of sections available in the current edition. The designer for the site would like an asterisk next to the current section so that the user will always know where in the site he or she currently is. The section list will also be placed in a separate file for easy manipulation; this file is shown in Listing 5.3. Listing 5.3 The list of sections <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> Page 93

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