Struts 2 - Using Message Resource Files To Display Text and Enable Internationalization

Introduction

In this tutorial we'll explore using Struts 2 message resource capabilities (also called resource bundles). Message resources provide a simple way to put text in a view page that is the same throughout your application, to create form field labels, and to change text to a specific language based on the user's locale (i18n).

[More]

Struts 2 Global Exception Handling With Logging

Introduction

One of the perks of my current job is I work with a pretty smart group of Java developers. Jeff Day, one of the programmers here at KU, showed me how to enable logging when using Struts 2's global exception handling mechanism.

[More]

Using JUnit To Test A Struts 2 Action Class In An Application That Also Uses Spring

Introduction

In my Struts 2 web applications, I'm now using Spring to manage class relationships. Creating unit tests for a Struts 2 ActionSupport class in an application that also uses Spring can be difficult. Fortunately, there is a Struts 2 plugin available that makes it easier to write unit tests for ActionSupport class.

[More]

A Struts 2, Spring, and Hibernate Example Application

Introduction

I was learning Hibernate as another methodology for storing my Java objects' state in a data repository. I wanted to experiment with integrating Hibernate into a Struts 2 and Spring application so I created an example of using the three technologies together. The combination of these three frameworks enables Java developers to create powerful web applications with a minimum of code.

[More]

Using Spring 3.0 To Create An Embedded In-Memory Database In Your Java Application

Introduction

At a Spring training conference, I learned about a new feature in Spring 3.0 that makes it very easy to create an embedded database to run in your Java application. The Spring 3.0 documentation provides a good summary of why developers may want to use an embedded database:

An embedded database is useful during the development phase of a project because of its lightweight nature. Benefits include ease of configuration, quick startup time, testability, and the ability to rapidly evolve SQL during development. [Reference 1, section 12.8.1]

[More]

Loading Multiple Java Property Files Using Spring

Introduction

I had to load properties from two different property files in a Java Spring project.  Since I had not done that before and I'm a Spring newbie, I did some research in the Spring documentation.  I found out that Spring provides a very easy to use methodology to load properties from multiple property files and then inject the property values into your Spring managed beans.  This article will explain what I learned and provide an example Spring Java application you can download.

[More]

Using Spring JDBC To Interact With A Database

Introduction

For a new project I'm working on I'm using Spring JDBC (http://static.springsource.org/spring/docs/2.5.x/reference/jdbc.html) to interact with the database. 

Spring JDBC provide numerous benefits over using traditional JDBC.  Once you learn the methodology of using Spring JDBC, development time is greatly reduced.  Spring JDBC has numerous methods that make it simple to store, retrieve, and update your Java objects in the database. 

[More]

Unit Testing Jersey RESTful Web Services That Also Use The Spring Framework

Introduction

In a previous blog article I described how you can integrate Jersey RESTful web services and the Spring framework. I ended that article with a note that I needed to do further research into how to write unit tests for the web services that depend on the Spring framework for dependency injection.

Fortunately, I ran across an article on Naresh's blog, Jersey Test Framework re-visited, where he explains the new version (1.1.2-ea) of the Jersey test framework. In his article he provides a link to the code for the spring-annotations sample test (provided as part of the Jersey project), which is an example of unit testing a web service that uses Spring. So using Naresh's article and the Spring annotations example code I was able to design a demo application that uses Jersey and Spring and that includes some simple unit tests.

[More]

Using Jersey (RESTful Web Services) and Spring (Dependency Injection) Together

Introduction

I worked on a project that uses Jersey RESTful web services that depend on other classes to do the actual work.  For example a web service that uses a data access object to get information out of a data repository.  Since I like to use Spring to manage dependencies between classes, I needed to learn how to integrate Spring and Jersey.

[More]

Unit Testing A Struts 2 Action Class - Struts 2 JUnit Plugin

Introduction

In my previous article on unit testing Struts 2 Action classes I discussed and demonstrated how to write unit tests that used classes provided by some other developers. After researching unit testing Struts 2 further, I found out that the 2.1.8 release of Struts 2 will include a new version of the JUnit plugin that will make it even easier to write unit tests for your Action classes.

You don't have to wait for the next release to take advantage of the code written for the improved JUnit plugin. First you'll want to read the information about the plugin (see: http://cwiki.apache.org/confluence/pages/viewpage.action?pageId=2853342). (NOTE: Struts 2.1.8 is now available and you can download the Struts 2.1.8 JUnit Plugin as part of the Struts 2 download on http://struts.apache.org. The plugin is also available in the Maven repository.) Second you can check out the code used for the plugin from the Struts 2 Subversion repository (http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/junit).

[More]

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner