Home » Enterprise Java » servlet (page 3)

servlet

Java Servlet AsyncListener Example

Async Servlet was introduced in Servlet 3.0. In this section, you will learn about registering AsyncListener with the recently created AsyncContext with an example. The AsyncListener will be notified when an asynchronous event occurs. 1. Introduction AsyncEvent contains the details of the event occurred by the Asynchronous processes. These events include the successful completion of the asynchronous cycle, times out, ...

Read More »

Java Servlet SendRedirect Example

Communication between the Servlets is an important task to the programmer. sendRedirect() can be used to communicate between two servlets present in the different servers. The output will be the same as the Request Dispatcher Forward example but the URL of the page will be changed to the redirected page. In this tutorial, we will see how the sendRedirect() method ...

Read More »

Java Servlet Annotations Example

Communication between the Servlets is an important task to the programmer. In this tutorial, we will see how the Servlet annotations can replace the equivalent XML configuration in the web deployment descriptor file (web.xml). 1. Introduction The Servlet API 3.0 introduces a new package called javax.servlet.annotation which provides the annotation types which can be used for annotating a Servlet class. ...

Read More »

Java Servlet Life Cycle Example

Servlets are modules of the Java code that run on a server application to answer the client requests. They are not tied to a specific client-server protocol but are most commonly used with HTTP and the word “Servlet” is often used in the meaning of “HTTP Servlet“. In this tutorial, we will explain the Servlet Lifecycle. 1. Introduction Servlet is ...

Read More »

Java Servlet Filter Example

Servlets are modules of the Java code that run in a server application to answer the client requests. In this tutorial, we will explain how to implement the Servlet Filter API to handle the client requests. 1. Introduction Servlet is a Java program which exists and executes in the J2EE servers and is used to receive the HTTP protocol request, ...

Read More »

Java Servlet RequestDispatcher Tutorial

Communication between the Servlets is an important task to the programmer. Request Dispatcher is an interface whose implementation defines an object which can dispatch the request to any resources on the server. In this tutorial, we will see how the javax.servlet.RequestDispatcher interface is used to forward or include the response of a resource in a Servlet.         ...

Read More »

Java Servlet Application for Login Page

Servlets are modules of the Java code that run in a server application to answer the client requests. They are not tied to a specific client-server protocol but are most commonly used with HTTP. The word “Servlet” is often used in the meaning of “HTTP Servlet“. In this tutorial, we will explain how to handle the Servlet HTTP POST Request ...

Read More »

Java Servlet Websocket Example

In this article we illustrate a simple chat program using a Websocket endpoint. The Java API for websocket provides both client and server api’s and can be found in the javax.websocket javax.websocket.server packages accordingly. The example article will do a brief dive into the mechanics of Websockets from a Java perspective and then it will demonstrate some of it’s mechanics via a ...

Read More »

Java Servlet Url Parameters Example

Servlets are modules of the Java code that run in a server application to answer the client requests. They are not tied to a specific client-server protocol but are most commonly used with HTTP. The word “Servlet” is often used in the meaning of “HTTP Servlet” . In this tutorial, we will explain how to handle parameters of the Servlet ...

Read More »

Java Servlet Generate Zip File Example

In this article we illustrate how to generate a zip (compressed) file via a GET request to a custom servlet. The servlet will serve said file (configurable via a WebInitParam) to the browser and the browser will then prompt the user with a download prompt to save said file to the file system. The file will be served asynchronously using FileChannels transferTo(...). ...

Read More »