Thursday, 29 March 2012

CRON EXPRESSION

CRON Expression:
A CRON expression is a string comprising 5 or 6 fields separated by white space that represents a set of times, normally as a schedule to execute some routine.

Field name Mandatory? Allowed values Allowed special characters
Minutes Yes 0-59 * / , -
Hours Yes 0-23 * / , -
Day of month Yes 1-31 * / , - ? L W
Month Yes 1-12 or JAN-DEC * / , -
Day of week Yes 0-6 or SAT-FRI * / , - ? L #
Year No 1970–2099 * / , -

Special characters

Asterisk ( * )
The asterisk indicates that the cron expression will match for all values of the field; e.g., using an asterisk in the 4th field (month) would indicate every month.
Slash ( / )
Slashes are used to describe increments of ranges. For example 3-59/15 in the 1st field (minutes) would indicate the 3rd minute of the hour and every 15 minutes thereafter. The form "*/..." is equivalent to the form "first-last/...", that is, an increment over the largest possible range of the field.
Percent ( % )
Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
Comma ( , )
Commas are used to separate items of a list. For example, using "MON,WED,FRI" in the 5th field (day of week) would mean Mondays, Wednesdays and Fridays.
Hyphen ( - )
Hyphens are used to define ranges. For example, 2000-2010 would indicate every year between 2000 and 2010 CE inclusive.
L
'L' stands for "last". When used in the day-of-week field, it allows you to specify constructs such as "the last Friday" ("5L") of a given month. In the day-of-month field, it specifies the last day of the month.
W
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.
Hash ( # )
'#' is allowed for the day-of-week field, and must be followed by a number between one and five. It allows you to specify constructs such as "the second Friday" of a given month.
Question mark ( ? )
Note: Question mark is a non-standard character and exists only in some cron implementations. It is used instead of '*' for leaving either day-of-month or day-of-week blank.

Examples

Every minute

* * * * *

Every 1 minute

*/1 * * * *

or

0 0/1 * * * ?

23:00:00 every weekday night

0 23 ? * MON-FRI

In 2003 on the 11th to 26th of each month from January to June every third minute starting from 2 past 1am, 9am and 10pm

2-59/3 1,9,22 11-26 1-6 ? 2003

Minutes Hours Day of month Month Weekday Year
Every 2 hours at :30 30 0/2 or */2 * *  ? *
Every day at 11:45PM 45 23 * *  ? *
Every Sunday at 1:00AM 0 1  ? * 0 *
Every last day of month
at 10:00AM and 10:00PM
0 10,22 L *  ? *

Wednesday, 28 March 2012

Prevent user from going back, after logout

How to restrict spacebar in textbox using Javascript?

Ex:


Simple jsp page





 

Char codes for all keyboard keys.

Code
Key Name
8 Backspace
9 Tab
13 Enter
16 Shift
17 Ctrl
18 Alt
19 Pause
20 Caps Lock
27 Escape
33 Page Up
34 Page Down
35 End
36 Home
37 Arrow Left
38 Arrow Up
39 Arrow Right
40 Arrow Down
45 Insert
46 Delete
48 0
49 1
50 2
51 3
52 4
53 5
54 6
55 7
56 8
57 9
65 A
66 B
67 C
68 D
Code
Key Name
69 E
70 F
71 G
72 H
73 I
74 J
75 K
76 L
77 M
78 N
79 O
80 P
81 Q
82 R
83 S
84 T
85 U
86 V
87 W
88 X
89 Y
90 Z
91 Left Windows
92 Right Windows
93 Context Menu
96 NumPad 0
97 NumPad 1
98 NumPad 2
99 NumPad 3
100 NumPad 4
101 NumPad 5
102 NumPad 6
103 NumPad 7
Code
Key Name
104 NumPad 8
105 NumPad 9
106 NumPad *
107 NumPad +
109 NumPad -
110 NumPad .
111 NumPad /
112 F1
113 F2
114 F3
115 F4
116 F5
117 F6
118 F7
119 F8
120 F9
121 F10
122 F11
123 F12
144 Num Lock
145 Scroll Lock
186 ;
187 =
188 ,
189 -
190 .
191 /
192 `
219 [
220 \
221 ]
222 '

Monday, 26 March 2012

How to get value from properties file in java class using spring?

To get property key-value from .properties file,

1) Declare <context:property-placeholder> tag in spring xml.
2) Declare a variable with required type and annotate the variable with @value.

 Ex:
env.properties
--------------

user.name=prabha
user.has.phone=true

in java class
------------

@value("${useer.name}")
private String name;

@value("${user.has.phone}")
private boolean hasPhone;

//setters and getters

How to restrict ctrl+v in textbox?

The simplest way to restrict ctrl+v in textbox is,
declare onpaste, oncopy, oncontextmenu attributes in body.
Ex:
<body onpaste="return false" oncopy="return false" oncontextmenu="return false">
........
</body>

the above will restrict ctrl+v, ctrl+c, right click in all textbox's.

To restrict ctrl+v in individual textbox,

<input type="text" onpaste="return false" oncopy="return false" oncontextmenu="return false">

onpaste : restricts ctrl+v
oncopy : restricts ctrl+c
oncontextmenu : restricts right click in textbox
Hi....
Welcome to Java Cane!!