Home » Enterprise Java » servlet

servlet

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. Table Of Contents 1. ...

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 »

Basics of Servlets Tutorial

In this article we will cover the basics of Servlets using Java 8, in a servlet 3.1 compliant container. We will demonstrate some of the basics of servlet usage in a Http context, via a simple web project that combines numerous simple example servlets all accessible via your favorite browser or via postman. Table Of Contents 1. Introduction 2. Technologies used ...

Read More »

Java Servlet File Upload Example

In this example, we will see how to use servlet to upload a file. We will be just uploading the file to a server folder. As a part of this example, we will create an HTML form that lets us choose a file in your local file system. The file will be uploaded to the server. We will use Eclipse ...

Read More »

JDBC Servlet Example

In this example, we will see how to make use of JDBC from a servlet to access database and read data from table. We will use MySQL as the database and MySQL Workbench as the client for database to prepare the data. However this example does not cover installation of MySQL and MySQL Workbench. We will be using Eclipse as ...

Read More »

Java Servlet Context Listener Example

In this tutorial, I will be demonstrating a simple example of how to use ServletContextListener to make some global initializations and configurations. We will be using WildFly application server and Eclipse to demonstrate the examples in this post. None database is required to run this example. 1. Introduction ServletContext is a configuration object which is created when application server starts and ...

Read More »

Java Servlet Authentication Example

In this example, I will explain how to perform authentication using a servlet running on WildFly application server and Eclipse. We will not be using any database to store user credentials. Table Of Contents 1. Introduction 2. Configure WildFly in Eclipse 3. Create New Dynamic Web Project 4. Create Authentication Helper Class 5. Home Servlet 6. Application Servlet 7. Login Html 8. ...

Read More »