SERVLET / NOTES</>↗Servlet19 Apr 2025
In Jakarta EE, you can define servlets using annotations instead of the traditional web.xml deployment descriptor. The most common annotation used for this purpose is @WebServlet. Here’s an overview of how to use annotations to define servlets: 1. Basic Syntax of the @WebServlet Annotation The @WebServlet annotation is used to declare a servlet and map […]
SERVLET / NOTES</>↗Servlet19 Apr 2025
In a Jakarta EE (formerly Java EE) application, you can configure servlets in the web.xml deployment descriptor. The web.xml file is located in the WEB-INF directory of your project. Here’s how you can configure a servlet in web.xml step-by-step: 1. Declare the Servlet You define the servlet by giving it a name and specifying its […]
SERVLET / NOTES</>↗Servlet18 Apr 2025
Handling cookies in the Jakarta Servlet API is simple and straightforward. Cookies are small bits of data sent from a server to a client and then sent back by the client in subsequent requests to the server. Below is how you can handle cookies using Jakarta Servlet API: 1. Creating and Adding a Cookie To […]
SERVLET / NOTES</>↗Servlet18 Apr 2025
To set response headers using HttpServletResponse in a Java web application (e.g., within a servlet), you can use the setHeader or addHeader methods provided by the HttpServletResponse class. Here’s an overview of both methods and how to use them: Methods for Setting Headers setHeader(String name, String value) This method sets a response header with a […]
SOUND API / NOTES</>↗Sound API18 Apr 2025
In Java, the FloatControl class is commonly used in conjunction with the javax.sound.sampled package to control certain sound properties, such as gain (volume) and balance, on lines (e.g., clips, data lines, or mixers). Here’s a quick explanation on how to apply gain and balance using FloatControl: Gain (Volume): The gain is used to adjust the […]
SOUND API / NOTES</>↗Sound API18 Apr 2025
To save the microphone audio as a proper WAV file, you need to use the AudioSystem.write() method. WAV files contain raw PCM data combined with a header that describes important details, such as the sample rate, number of channels, etc. Java’s javax.sound.sampled package makes it easy to save the audio in this format. Example: Saving […]