<form name="localeForm" action="index.jsp" method="post"> <c:set var="selectedLocaleString" value="${param.locale}" /> <c:set var="selectedFlag" value="${!empty selectedLocaleString}" /> <b>Locale:</b> <select name=locale> <c:forEach var="localeString" items="${locales.localeNames}" > <c:choose> <c:when test="${selectedFlag}"> <c:choose> <c:when test="${f:equals(selectedLocaleString, localeString)}" > <option selected>${localeString}</option> </c:when> <c:otherwise> <option>${localeString}</option> </c:otherwise> </c:choose> </c:when> <c:otherwise> <option>${localeString}</option> </c:otherwise> </c:choose> </c:forEach> </select> <input type="submit" name="Submit" value="Get Date"> </form> <c:if test="${selectedFlag}" > <jsp:setProperty name="locales" property="selectedLocaleString" value="${selectedLocaleString}" /> <jsp:useBean id="date" class="mypkg.MyDate"/> <jsp:setProperty name="date" property="locale" value="${locales.selectedLocale}"/> <b>Date: </b>${date.date}</c:if> </body> </html>
To deploy the date application with NetBeans IDE, follow these steps:
Start the Application Server.
In NetBeans IDE, select File→Open Project.
In the Open Project dialog, navigate to:
tut-install/javaeetutorial5/examples/web/
Select the date folder.
Select the Open as Main Project check box.
Click Open Project.
In the Projects tab, right-click the date project, and select Undeploy and Deploy.
To deploy the date application with the Ant tool, follow these steps:
In a terminal window, go to tut-install/javaeetutorial5/examples/web/date/.
Type ant. This command will spawn any necessary compilations, copy files to the tut-install/javaeetutorial5/examples/web/date/build/ directory, and create a WAR file.
Start the Application Server.
Type ant deploy.
To run the example, do the following:
Set the character encoding in your browser to UTF-8.
Open your browser to http://localhost:8080/date.
You will see a combo box whose entries are locales. Select a locale and click Get Date. You will see the date expressed in a manner appropriate for that locale.
Some of the characters might not display properly if you don’t have the appropriate language files installed on your machine. Consult the user guide or online help for your operating system to determine how you can install these language files.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices