SERVLET / CATATAN</>↗Servlet23 Apr 2025
Securing servlets with declarative security in the web.xml deployment descriptor is an essential practice in Java web applications. It allows you to define security constraints without writing specific code, instead leveraging the standard configuration mechanism in web.xml. Here’s how you can do it step-by-step: 1. Define a Security Constraint The <security-constraint> element is used to […]
SERVLET / CATATAN</>↗Servlet23 Apr 2025
In Jakarta Servlet 6.0+, file uploads can be handled efficiently using the native APIs provided by the servlet specifications. Here’s a step-by-step guide: 1. Enable Multipart Config for the Servlet To handle file uploads, the servlet must be annotated with @MultipartConfig, which enables support for handling multipart/form-data requests. You can configure parameters such as maximum […]
SERVLET / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 […]