JSP pages are compiled into servlets, so theoretically you could write servlets to support your web-based applications. However, JSP technology was designed to simplify the process of creating pages by separating web presentation from web content. In many applications, the response sent to the client is a combination of template data and dynamically-generated data. In this situation, it is much easier to work with JSP pages than to do everything with servlets.
Wednesday, 30 May 2012
Tuesday, 29 May 2012
Create a drive menu for My Computer
Windows XP makes it easy for you to configure My Computer so it works like a menu, with
each drive listed as a menu item. Here's how. Right-click the Start button, and select Properties.Click Customize, which is adjacent to the Start Menu radio button, and select Advanced. Scroll through the Start Menu Items list box until you see My Computer. Select Display As A Menu, and click OK twice. Now, when you select My Computer from the Start menu, you'll see a menu of individual drives. To access the contents of that drive, just select the drive letter from the menu
Formatting date with fmt:formatDate Action
Date and time are important matters in internationalized web applications. Different country has it own way to present date and time in different format. JSP has an action called to allow you to format date and time based on a specificlocale. Here is a table of action attributes. As you can see only value attribute isrequired for action.
Date and time are important matters in internationalized web applications. Different country has it own way to present date and time in different format. JSP has an action called to allow you to format date and time based on a specificlocale. Here is a table of action attributes. As you can see only value attribute is required for action.
| Name | Mandatory | Meaning | ||
|---|---|---|---|---|
| value | yes | Date and/or time value to be formatted. | ||
| type | no | Accept date or/and time to be used to format | ||
| dateStyle | no | Specify predefined formatted style for date only if date value is used for formatting. | ||
| timeStyle | no | Specify predefined formatted style for time only if time value is used for formatting. | ||
| pattern | no | Specify standard customized pattern for formating date and/or time | ||
| timeZone | no | If the time value is used to format, this attribute specify time zone for that time value. | ||
| var | no | This attribute is for exporting scoped variable which stores the formatted date and/or time as a string | ||
| scope | no | specify the scope of var. | ||
First we use the useBean tag to initialize a scoped variable called now and store current date value into this variable. Then we set the locale to different locales: US and FR and print out the current date in now variable by using action.
Formatting Date and/or Time
By default format and print only date. If you want to print time or bothdate and time you can use the type attribute. The type attribute accepts date, time and both to allow you to print such a this information in a specific locale. Let's take a look at an example:
Formatting Date Time with predefined styles and custom patterns
You cannot only format and print date & time with predefined styles provided by JSTL but also with a custom pattern. The timeStyle and dateStyle attributes of specify the predefined styles you want to format. Patterns attribute enables you to define your own style. In this case, you need the date & time code table bellow to find exactly what you want to format.
| Code | Meaning |
|---|---|
| G | The era (A.D., B.C., and so on) |
| y | The year (yy for two-digit years, yyyy for four digits) |
| M | The month (MM for numeric month, MMM or longer for month names orabbreviations) |
| w | The week of the year (ww for two digits) |
| W | The week of the month |
| D | The day of the year (DDD for three digits) |
| d | The day of the month (dd for two digits) |
| F | The numeric day of the week |
| E | The text day of the week (EEEE or longer for full name) |
| a | AMa.m./PMp.m. indicator |
| H | Hour of the day (0–23) |
| k | Hour of the day (1–24) |
| K | Hour in a.m./p.m. (0–11) |
| h | Hour in a.m./p.m. (1–12) |
| m | Minutes in hour |
| s | Seconds in minute |
| S | Milliseconds in second |
| z | Full time zone name |
| Z | RFC 822 time zone (for example, 0500) |


