File upload is one of those features that sounds simple until you actually implement it — multipart boundaries, streaming vs buffering, size limits, and MIME-type validation all add up quickly. In this tutorial you will build a complete file-upload REST endpoint using Jersey 3.x (JAX-RS 3.1), test it with an HTML form and with curl, enforce a file-size limit, and save uploads to a configurable directory on disk.
Tag Archives: Java
Secure Your Jersey REST APIs – Complete Authentication & Authorization Guide
Exposing a REST endpoint is only half the job — you also need to control who can call it and what they are allowed to do. Jersey, the reference implementation of Jakarta RESTful Web Services (JAX-RS), provides a clean extension point through ContainerRequestFilter that lets you intercept every request before it reaches your resource class. In this guide you will implement HTTP Basic authentication, JWT Bearer-token validation, and role-based authorization step by step, using plain Jersey and then the Spring Boot integration.
Mastering Maven: How to Create Your Own Custom Archetypes
Every time you run mvn archetype:generate, Maven reads a blueprint called an archetype to scaffold your project structure. The built-in archetypes cover plain Java and simple web apps, but when your team has its own folder conventions, preferred dependencies, or boilerplate code, you need a custom archetype. In this guide you will build a complete custom Maven archetype from scratch, install it to your local repository, generate a new project from it, and optionally deploy it to a team-shared repository so your whole organisation can use it in one command.
Mastering Variable Declarations in TypeScript: var, let, and const Explained
When you start learning TypeScript (or JavaScript), one of the very first questions you face is: should I use var, let, or const? They all declare variables, but they behave very differently in terms of scope, hoisting, and re-assignment. Getting these rules wrong leads to subtle bugs that are notoriously hard to track down. In this guide you will understand every difference with concrete examples, see the TypeScript compiler’s role, and learn the simple rules that modern TypeScript developers follow every day.
Mastering Credit Card Validation with Regular Expressions in Java
Validating credit card numbers at the point of entry catches typos before an expensive payment gateway call is made. In this tutorial you will learn how to use Java regular expressions to check card number format for the major card networks, and then apply the Luhn algorithm — the checksum standard built into every valid card number — to confirm the number is mathematically plausible. The combination of regex format check + Luhn checksum is the industry-standard client-side validation used by checkout pages worldwide.
Continue reading Mastering Credit Card Validation with Regular Expressions in JavaA Practical Guide to Formatting ZonedDateTime in Java
ZonedDateTime is the most complete date-time class in the modern java.time API: it stores a date, a time, and a full timezone (e.g. America/New_York). Displaying it in a human-readable or machine-readable format requires the DateTimeFormatter class. In this tutorial you will learn every important formatting pattern, understand the difference between predefined ISO formatters and custom patterns, and see how to parse a string back into a ZonedDateTime — all with annotated code examples and sample output.
JMS Deep Dive: A Practical Guide to Asynchronous Messaging in Java
The Java Message Service (JMS) API is the standard Java EE / Jakarta EE API for sending, receiving, and reading messages in an asynchronous, loosely coupled way. Rather than having Service A call Service B directly, JMS lets A drop a message onto a queue or topic and carry on. Service B picks it up whenever it is ready. In this guide you will learn the key JMS concepts, study both queue (point-to-point) and topic (publish-subscribe) messaging models, and walk through a fully working Java example using Apache ActiveMQ — the most widely deployed open-source JMS broker.
Continue reading JMS Deep Dive: A Practical Guide to Asynchronous Messaging in Java