Author Archives: afsinka

RESTFul Web Service Example with Jersey 2 and Tomcat 8

Jersey RESTful Web Services framework is open source, production quality, framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation.

Let’s make an RESTFul web service example with Jersey 2 and Tomcat 8. Our web service is taking a word as parameter, reverse it and return that reversed word as response.

Click to read more…

Dockerize Apache Tomcat on Windows

This stackoverflow post [1] explains how it is possible to build and run an image for Java Web Application on Tomcat, via Docker, but if you are working on Windows, probably it is not going to work for you, because you may face with

cannot enable tty mode on non tty input. [2]

Let’s try something to get over this.

Click to read more…

AngularJS & Java Servlet POST Request Example

I tried simple POST request with AngularJS but it didn’t work properly, then looked for solution in stackoverflow and found answer in here [1]. According to that explanation I wrote simple snippet.

Click to read more…

Communication Between Java Applications (3) – ActiveMQ

ActiveMQ is a popular library to use messaging via JMS.

There is a very good “Hello World” tutorial exists in offical site, I must say.

So I’m going to write another “Hello World” example with ActiveMQ, but I also show you how you can get statistics (enqueue/dequeue count etc.) in your code.

ActiveMQ architecture simply consist of a producer which sends messages to a broker and a consumer which listens that broker to receive messages. We will create a Queue on this broker to keep messages.

Click to read more…


Using Google Guava For Cache With Timeout – Java

If you need a list to keep your objects for a while and then automatically delete/expire them, you can use caches from Google Guava.

The Guava project contains several of Google’s core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth.

The latest release is 18.0, released August 25, 2014.

First, let’s write a class based on LoadingCache.

Click to read more…


Communication Between Java Applications (2) – JGroups

JGroups is a library which may serve some APIs to communicate between java applications. Unfortunately it is a little bit complex and has some advanced configurations, so I just show quick and simple example to introducing.

Project Explorer is going to looks like this:

Click to read more…


Communication Between Java Applications (1) – Socket Programming

There are too many ways to send a message from one java application to another. Most known method is using a socket.

Let’s assume that we have a server which receive a message from a client and reverse that message text and then send it back.

Click to read more…


JSP Hello World on Jetty 9

Running a JSP file on Jetty is quite simple. There is only a trick officially reported to add JSP support to Jetty.

Let’s make an example.

Click to read more…


Ehcache with Hibernate

Simple application that just get some records via Hibernate from database and add these records to cache which supplied by EhCache.

There is “Contact” table in database which includes ID, NAME and ADDRESS values.

“Contact” class for mapping this table:

Click to read more…

Video Playlist for Flowplayer with Javascript

Even Flowplayer gives you some plugin for playlist attribute, maybe you just want a simple playlist with just javascript.

For this purpose we can use “playlist” option.
Click to read more…