Java / J2EE
Opening / Displaying Content of Text File in java
import java.io.BufferedInputStream; import java.io.DataInputStream;
Validate Input in Java using Regular Expression
import java.util.Scanner; import java.util.regex.Matcher;
Iterating Object Array in Hibernate
Hibernate queries sometimes return tuples of objects in which each tuple is returned as an array. This kind of results are considered scalar. This is how to iterate this kind of query result in hibernate.
Struts 2 Validation - Example Program
Example program showing how to validate input in struts 2 using xml configuration file.
AddEntry.java
Session Management in Struts 2
Store session variable in Action Class:
Map session = ActionContext.getContext().getSession();
session.put("variableName", "variableValue");Store session variable in View / JSP:
Designing Field Error Message in Struts 2
The struts 2 tag <s:fielderror /> will generate the following html tags when field error occur (my example if for age and birthDate field):
Invalid field value for field [fieldName] in Struts 2
The default field error message in struts 2 is Invalid field value for field "[fieldName]". This can be change by creating a property file with a file name pattern [ClassName].properties under the package of the Action class. Then add the example line below (Example for a birthDate field):
invalid.fieldvalue.birthDate = Birthdate is invalid




Recent comments
1 week 2 days ago
1 week 5 days ago
2 weeks 1 day ago
2 weeks 3 days ago
3 weeks 1 day ago
4 weeks 3 days ago
4 weeks 6 days ago
5 weeks 4 days ago
9 weeks 1 day ago
15 weeks 1 day ago