How to create a start up class for Enterprise application servers

This article discusses how to create a start up class for a Java Enterprise / Jakarta EE compliant application server such as WildFly. There is no concept of start up class for an application server however you can deploy an application which contains a component bound to the deployment life cycle. For example, the javax.servlet.ServletContextListener … Read more

HelloWorld Servlet example

In this tutorial we will learn how to code and deploy an HelloWorld Servlet on the latest version of WildFly. A Java Servlet is a Java object that responds to HTTP requests while running inside a Web container. In terms of process, the browser sends an HTTP request to the Java web server. The web … Read more

Using Servlet 4.0 on WildFly

Server push is one core improvements in HTTP/2 which is included in Servlet 4.0 This feature aims aims at improving the perceived performance of the web browsing experience. Server push push is enabled to improved perceived browser performance because servers are in a much better position than clients to know what additional assets (such as … Read more

Uploading a File with a Servlet

Since Java EE 6 it is now easier to upload a File without the need of third party API. This can be done by setting the @MultipartConfig annotation within a Servlet. Let’s see a full example starting from an HTML page which contains a form with a “file” type field: <form action=”MyUploadServlet” enctype=”multipart/form-data” method=”POST”> <input … Read more

Intra-Servlet Communication

Sometimes you may need that a Servlet hands off its job to another Servlet or JSP. Intra Servlet communication can be done by means of a Dispatcher or by Redirecting the initial request. Dispatching is done by means of Dispatcher object which allows to complete the request without actually redirecting to user to another site, … Read more

Saving Session state with Cookies

Cookies are text data sent by server to the client to mantain information. The data sent gets saved at the client local machine. When client send request to server, it passes the cookies stored by the server in request header as in the following example: Set-Cookie: LSID=HYEGYUGe…Eaem_vYg; Domain=mastertheboss.com; Path=/application; Expires=Wed, 11-Mar-2014 21:21:01 GMT; Secure; HttpOnly … Read more

Dynamic Servlet Registration

One of the cool features introduces by Java EE 6 is Dynamic Registration of Servlets and Filters at application startup. This can be really useful if you are building your own framework but I guess for developers too can benefit from it. In order to do that, you can use some new methods introduced in … Read more

Rewrite: a Java EE URL rewriting solution

This tutorial will discuss about a cool open-source project named Rewrite which is an URL-rewriting solution for Servlet, JSF, and Java EE. Rewrite offers powerful configuration, flexible extensions, and framework integration.  In order to experience a basic usage of Rewrite you need to add the rewrite-servlet dependency to your Maven projects. Since we will test … Read more

Servlet 3.0 tutorial

JBoss release 6.0.0 has been just released. One of the most interesting news is the integration of Servlet 3.0 specification in the Web Server container. Let’s see some of the most interesting news. The most important features introduced with the new Servlet specification can be divided into the following main areas: – Easier development with annotations: following … Read more

EJB injection in Servlet fixed in JBoss AS 5

This mini tutorial covers “The curious Case of EJB injection into Servlets”.  Why curious ? because this was the only JEE dependency injection which gave some troubles to developers…until  JBoss AS 5.0 finally fixed JBAS-5646 The EJB 3.0 Specification – JSR 220 – gives developers a lot of flexibility in where to specify resource dependencies and … Read more