SERVLET / NOTES</>↗Servlet22 Apr 2025
To serve static files (e.g., HTML, CSS, JavaScript, images) using a Jakarta Servlet, you can follow these steps. Jakarta Servlets provide a way to read files from a directory (or resources) and serve them as HTTP responses. Here’s a guide on how to achieve it: 1. Directory Structure Your project structure should look something like […]
BASIC / NOTES</>↗Basic22 Apr 2025
Java 17 introduced text blocks to simplify the use of multiline strings, making it much easier to include and manage multiline text in your Java applications. Text blocks were actually introduced in Java 15 but were further refined and are fully supported in Java 17. What Are Text Blocks? A text block is a multiline […]
SERVLET / NOTES</>↗Servlet21 Apr 2025
In Java Servlets, you can share data between servlets using the ServletContext object. The ServletContext is an application-wide object that all servlets in a web application can access. It allows servlets to share information. Here’s how you can use it: Steps to Share Data Using ServletContext: Set Attribute in ServletContext: A servlet can store an […]
BASIC / NOTES</>↗Basic21 Apr 2025
To install and set up Java 17 on your system, follow the steps below. The process may vary slightly depending on your operating system. On Windows Download Java 17 Go to the official Oracle JDK download page or OpenJDK 17 Downloads if you prefer an open-source version. Select the appropriate installer for your Windows version […]
SERVLET / NOTES</>↗Servlet20 Apr 2025
You can initialize servlet parameters in a Java Servlet by using the ServletConfig object. The ServletConfig object contains initialization parameters and configuration data for a specific servlet. These parameters are specified in the web application’s deployment descriptor (web.xml file). Here’s a step-by-step guide to using ServletConfig for initializing servlet parameters: 1. Define Initialization Parameters in […]
SERVLET / NOTES</>↗Servlet20 Apr 2025
Creating a servlet filter using the Filter interface and FilterChain is straightforward in Jakarta EE (or Java EE). A filter is used to perform filtering tasks like logging, authentication, authorization, etc., on requests or responses. Here’s how you can create a servlet filter step by step: Steps to Create a Servlet Filter Implement the Filter […]