JavaSercer Pages The poll.jsp page also includes a (Mysql webhost)

December 30, 2006 on 10:13 pm | In Java |

JavaSercer Pages The poll.jsp page also includes a question, linked to a page with background information for the question, and a group of radio buttons representing the different answers, as well as a Submit button. Clicking on the Submit button invokes the calculate.jsp page, where the vote is validated. If it’s valid, it’s added to the global poll result. The request is then forwarded to the result.jsp page, which displays the poll statistics with all numbers formatted according to the selected locale. If it’s not valid, the request is forwarded back to the poll.jsp page. Both the poll.jsp page and the result.jsp page are designed to show text, numbers, and dates according to the selected locale using custom actions based on the Java classes described in the previous section. This approach is perfect when the amount of text is small; only one page has to be maintained. But if a page needs to contain a great deal of text, typing it into a properties file and escaping all line breaks may not be the best approach. Some pages also need to use different layouts, colors, images, and general appearances based on the locale. In this case, it’s easier to use a separate page per locale. This approach is illustrated by the pages providing more detailed information about the question in this example. The link on the poll.jsp page leads to different JSP pages depending on the selected language, named according to the same naming convention as ResourceBundle properties files: details.jsp, details_de.jsp, and details_sv.jsp for English (the default), German, and Swedish pages, respectively. Let’s look at the one-page and the multipage approaches separately. 11.2.1 Using One Page for Multiple Locales Example 11.1 shows the poll.jsp page. That’s where the magic of locale selection happens, and the selection is then used to produce text in the corresponding language throughout the page. Example 11.1. Language Selection and Vote Page (poll.jsp) <%@ page language="java" contentType="text/html" %> <%@ taglib uri="/orataglib" prefix="ora" %>

:

> <%= locale.getText("poll.english") %>
> <%= locale.getText("poll.swedish") %>
> <%= locale.getText("poll.german") %>

“>

“>



“>

page 153

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

No Comments yet

TrackBack URI

Sorry, the comment form is closed at this time.