Articles Tagged ‘servlet’

Transforming JSON Structures with Java and JOLT

Sunday, January 29th, 2017

When it comes to web-services (especially RESTful web-services), configuration files or other data-descriptors, the JavaScript Object Notation, short: JSON is often used as format of choice.

As the task arises to transform these JSON structures, I have seen a variety of different approaches from converting JSON into XML using JAX-B, applying XSLT,  transforming into JSON again on the one hand to loading JSON structures into Hash-maps of Hash-maps (..) and manually removing single elements from these collections on the other hand.

JOLT is a library to make this task easier for us: It allows us to note down different types of transformations in a specification file in JSON syntax and to apply this specification to given JSON structures with ease.

In the following short tutorial I’d like to demonstrate how to use this library by transforming JSON structures programmatically with a few lines of code, by filtering a RESTful web-service using JOLT and a servlet filter and finally by adding a short example using the Apache Camel framework.

(more…)

Embedding Jetty or Tomcat in your Java Application

Tuesday, July 9th, 2013

Recently I needed to control an embedded web container from a Java application and I wanted to see how this could be achieved using an embedded instance of either Tomcat or Jetty here.

In the following short examples I would like to show how to embed both servers in an application in no  time using Gradle or Maven as build tool.

(more…)

Handling Feature Flags in a Java EE Application using Togglz

Wednesday, June 26th, 2013

Feature flags are a common technique, often combined with continuous deployment and delivery and they allow us to rollback a specific feature, to create A/B tests or to rollout a specific feature for a specific test group, a specific amount of users or dedicated systems.

In the following short examples I’d like you to demonstrate how easy it is to implement feature flags with the Togglz framework with a few steps in a Java EE environment.

(more…)

HTML5 Server Send Events using Node.js or Jetty

Sunday, October 21st, 2012

The HTML5 working draft describes different techniques to push information from a server to the client and the one described in this tutorial are Server-Send Events (SSE).

Using Server-Send-Events eliminates the need to poll a server periodically for information using AJAX and is really easy to implement because of the simple specification and the fact that nearly all modern browsers already implement this specification.

(more…)

Maven Tomcat Plugin: Adding Authentication to an Embedded Tomcat

Wednesday, October 12th, 2011

The Tomcat Maven Plugin not only allows us to deploy our mavenized application to an existing Tomcat server but also to run our web application with an embedded instance from our project’s directory. Recently I needed to add basic authentication to such an instance and wanted to share the steps necessary here

(more…)

Java EE 6 Development using the Maven Embedded GlassFish Plugin

Tuesday, September 20th, 2011

Today we’re going to take a look at the Maven Embedded GlassFish Plugin and how it allows us quick creation of GlassFish server instances in no time and Java EE 6 application deployment.

With a few lines of configuration in your Maven’s pom.xml we’ve got a running GlassFish instance and are able to  redeploy our application fast by pressing enter in our console.

In the following tutorial we’re going to build a Java EE 6 Web Application with a stateless session bean and a web servlet and finally deploy – and redeploy the application using the Maven GlassFish Plugin.

(more…)

Java EE 6, GlassFish and the Interceptor API

Wednesday, August 17th, 2011

Aspect oriented programming and the definition of cross-cutting-concerns is made easy in Java EE 6 using interceptors.

In the following tutorial we’re going to take a look at the different possibilities to apply interceptors to your EJBs at class or method level and how to setup a GlassFish instance to run the examples.

(more…)

How to create a simple OSGi Web Application using Maven

Sunday, July 25th, 2010

In this tutorial we will take a look at the development of a simple OSGi Web Application and what tools can save us some time.

The Maven Bundle Plugin makes our life much easier here as does the OSGi Bundle Repository that offers some nice bundles – in our case the servlet API and an embedded Jetty web server.

So lets develop some bundles ..

(more…)

Java Server Faces/JSF 2 Tutorial – Step 1: Project setup, Maven and the first Facelet

Saturday, June 5th, 2010

In this short tutorial we are going to build a Java Server Faces Web-Application using JSF2.0, Facelets, Maven and Hibernate as ORM Mapper.

The goals for this first step are: Setting up the project structure using Maven, defining a frame template/decorator and a registration facelet, creating a managed bean and mapping it’s values to the facelet, adding some basic validation, displaying validation errors and finally adding a navigation structure.

In step2 of this tutorial we are going to add persistence using Hibernate, add some security, create a custom UI component and add some AJAX.

The Mojarra JSF implementation is used for this tutorial – perhaps I’m going to post more about the MyFaces implementation in another tutorial.

(more…)

Search
Tags
Categories