Struts 2, Spring 4, Hibernate 4 and Maven Integration

In this tutorial I will show you how to integrate Struts 2, Spring 4, Hibernate 4 and Maven. In the previous example Integrate Spring 3, Struts 2 and Hibernate 3 , I have shown how to integrate Struts 2, Spring 3 and Hibernate 3 but I have not used maven there.

For this tutorial we will create maven based web project in Eclipse.

If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse.

Prerequisites

The following configurations are required in order to run the application

Eclipse Kepler
JDK 1.8
Tomcat 8
Have maven installed and configured
Struts 2, Spring 4, Hibernate 4 dependencies in pom.xml

Now we will see the below steps how to create a maven based project in Eclipse Continue reading “Struts 2, Spring 4, Hibernate 4 and Maven Integration”

Google Chart using Struts 2

We know that Google chart basically displays different statistical data on different chart types such as column chart, bar chart, line chart, pie chart etc. You can have a look at the URL https://developers.google.com/chart/ for more information.

You can integrate Google chart with any server side technology but here I will show you how to integrate Google chart using Struts 2. This tutorial shows step by step so that we can understand how it happens. It displays the data for area-wise top seven countries in pie chart. You can also use other charts for other purposes. In this example I have used static sample data and the actual data should come from database or other sources. You can change the source of data as per your requirements.

If you have any query please feel free to leave a comment. Continue reading “Google Chart using Struts 2”

Sending Email with attachment using Struts2

This tutorial shows how do we send email with attachment. This tutorial uses one input form where a user gives input for ‘Email To Address’ where the intended email will be sent, ‘Email Subject’, ‘Email Message’ and uploads one file which will be sent as an attachment with the email. This email sending example uses only gmail smtp server to send the mail. If you need only file upload example then you can search in the search box you will get file upload examples in Struts2, JSF2, Codeigniter2.

For testing purpose you can also send the email to yourself and after sending open your mailbox, you will find an email has arrived.

Continue reading “Sending Email with attachment using Struts2”

Upload multiple files using single browse button in Struts2

This tutorial shows how to upload multiple files using single browse button in Struts2. There is another tutorial on Multiple Files Upload in Struts2 which uses multiple browse buttons for multiple file upload but this tutorial uses only one button for uploading multiple file upload in Struts2. We need to use just attribute multiple=”multiple” with <s:file/> tag for uploading multiple files using the single browse button.

I won’t explain much details in this tutorial but if you need more explaination then you can go through another tutorial Multiple Files Upload in Struts2.

Continue reading “Upload multiple files using single browse button in Struts2”

Single file upload example in struts 2

File Upload is one of the common tasks of a web application and Struts 2 provides built-in feature for single file upload through FileUploadInterceptor. Interceptors are cross cutting concerns or common concerns like Logging; for more information on Interceptors please refer to Interceptors in struts2

FileUploadInterceptor(for more information go to File Upload Interceptors) is configured in the struts-default package that we usually extend in Struts 2 package configuration. FileUploadInterceptor also provide options to set the maximum file size limit, allowed file types and extensions that can be uploaded to the server. Struts 2 provide option to configure the maximum file size limit through struts.multipart.maxSize variable. This comes handy to set the limit to upload files incase of multiple files uploading in a single request. Continue reading “Single file upload example in struts 2”

Multiple File Upload example in Struts 2

File Upload is one of the common tasks of a web application and Struts 2 provides built-in feature for multiple files upload through FileUploadInterceptor. Interceptors are cross cutting concerns or common concerns like Logging; for more information on Interceptors please refer to Struts2 Interceptors

FileUploadInterceptor(for more information go to File upload interceptors) is configured in the struts-default package that we usually extend in Struts 2 package configuration. FileUploadInterceptor also provide options to set the maximum file size limit, allowed file types and extensions that can be uploaded to the server. Struts 2 provide option to configure the maximum file size limit through struts.multipart.maxSize variable. This comes handy to set the limit to upload files incase of multiple files uploading in a single request. Continue reading “Multiple File Upload example in Struts 2”

Integrate struts 2 in Liferay portlet

Liferay is a Open Source Content Management System and it’s popularity increasing day by day¬† but there are no much tutorials on this. Sometimes we find some examples but it may not work exactly the way have been written in the websites. Sometimes the tutorial steps have not been started from the scratch and it results confusion. I am going to give an example here step by step on how to integrate struts2 with liferay portlet or plugin project. I have extracted it from the Original Tutorial.

There are two modes in the original post but I have only worked with “edit” mode. I also had many confusions when I first read the original post and it did not work for me so I decided to jot down here. Continue reading “Integrate struts 2 in Liferay portlet”

Integrate Spring 3, Struts 2 and Hibernate 3

This tutorial shows how to integrate Spring 3, Struts2 and Hibernate 3 in the following example. You can see also Struts 2, Spring 4, Hibernate 4 and Maven Integration

Download the required jars for Spring from https://spring.io, Struts from http://struts.apache.org/download.cgi#struts2316 and Hibernate from http://hibernate.org/orm/downloads/

Create web application using Eclipse or any Java based IDE. Continue reading “Integrate Spring 3, Struts 2 and Hibernate 3”