Java / J2EE

Opening / Displaying Content of Text File in java

Tagged:  
import java.io.BufferedInputStream;
import java.io.DataInputStream;

Creating Text File in Java

Tagged:  
import java.io.File;
import java.io.IOException;

Append String to Text File in Java

Tagged:  
import java.io.File;
import java.io.FileWriter;

Validate Input in Java using Regular Expression

Tagged:  
import java.util.Scanner;
import java.util.regex.Matcher;

Iterating Object Array in Hibernate

Tagged:  

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

Tagged:  

Example program showing how to validate input in struts 2 using xml configuration file.

AddEntry.java

Session Management in Struts 2

Tagged:  

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

Tagged:  

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

Syndicate content