Struts 2.0 allows the use of Custom validators through the @CustomValidator annotation. The @CustomValidator annotation takes two mandatory parameters, type and message type: Refers to the “name” given to the validator in the validators.xml file. message: Message to be displayed when this validator fails. A custom validator can be implemented by extending the FieldValidatorSupport, or [...]
Archive | September, 2008
Many-to-One Relationship in Hibernate Mappings – Example
September 28, 2008
This example program demonstrates how to write the many-to-one accociations using the hibernate mapping files. Book.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 package hibernate; import java.io.Serializable; public class Book implements Serializable{ [...]
Difference between hibernate’s save,update and saveOrUpdate() methods
September 27, 2008
Difference between hibernate’s save,update and saveOrUpdate() methods Hibetnate has set of methods for saving and updating the values in the database. The methods look like same and difficult to differentiate between them if you are not understanding them clearly. If you understand the hibernate mechanism clearly, it doesn’t execute the SQL statements directly to manipulate [...]
How to enable SSL on JBoss application server?
September 25, 2008
To enable SSL on JBoss add the following segment to JBOSS_HOME/server/default/deploy/jbossweb-tomcatxx.sar/server.xml as a child of the jboss.web Service element. 1 2 3 4 5 maxThreads="100" strategy="ms" maxHttpHeaderSize="8192" emptySessionPath="true" scheme="https" secure="true" clientAuth="false" keystoreFile="${jboss.server.home.dir}/tmp/wso2wsas/conf/wso2wsas.jks" keystorePass="wso2wsas" sslProtocol = "TLS" /> NOTE: You can use any keystoreFile of your preference instead of the wso2wsas.jks which is shipped with WSO2 [...]
Sample code for SimpleDateFormat
September 25, 2008
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 import [...]
Sample code for Listing file names in a directory
September 25, 2008
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 public String[] getFileNames(String DirPath) { String directoryName; File directory; String[] files; directory = new File(DirPath); if (directory.isDirectory() == false) { if (directory.exists() == false) { System.out.println("There is no such directory!"); return null; } [...]
What is Shale Web Framework?
September 25, 2008
Apache Shale is a Java Server Faces based Web Application Framework from the Apache software foundation. Shale is talked of as the “heir” Apache struts framework. We all know that struts is the most used Java Web Framework so far. While shale is the successor of Struts, there is a significant departure of architecture from [...]
EJB Webservices in JBoss application server sample code
September 25, 2008
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 Employee Service.java ———————- package [...]
How to delete a cookie on server in a J2EE application
September 25, 2008
There is no direct method offered by servlet API to delete a cookie on server side. This is how you can go about doing it. 1) Loop through the cookies in the request object to locate the one that you want to delete. 1 2 3 4 5 for (Cookie cookie: request.getCookies()) { if (USER_COOKIE_NAME.equals(cookie.getName())) [...]
Advantages and Disadvantages – JSF
September 24, 2008
JSF is becoming more popular framework for user interface layer development, many architects and companies assuming that Struts is becoming outdated and JSF is catching up the market. I am not sure whether it is true at this point of time. However I would like express my critic on the advantages and disadvantages of JSF. [...]






September 29, 2008
1 Comment