Counting active accounts with Metrics

Based on a request parameter in a servlet context Recently I had the task to report active accounts based on http requests. Here I’m going to show you my solution with Dropwizard Metrics. Basically I am using a servlet filter togehter with an counter. [code] @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws …

Embedded Jetty with Servlet and Annotations

How do I programmatically configure Jetty that I can use Servlet Annotations? If you doing just servlets with jetty, this article could be interesting for you. I show you how I did it. Here comes the configuration: [code] … server = new Server(port); server.addBean(LOG); WebAppContext webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); String webxmlLocation = JettyServer.class.getResource("/webapp/WEB-INF/web.xml").toString(); webAppContext.setDescriptor(webxmlLocation); …

Unit Testing Servlets with Mockito

A quick example how to write unit tests for servlets Okay, I’m writing a Servlet. So I want to write a unit test too. With Mockito this is a quite simple task. Here I show you a simple unit test for a Hello World Servlet. The Servlet returns only „Hello World“. [code] public class HelloWorldServletTest …

Consent Management Platform von Real Cookie Banner