Question Bank 1 – Java and DropWizard

Hey! Every now and then, I keep coming up with various questions/blockers during the development phase. But because their answers are just too small (even one liner), I tend to avoid writing a post about it. Therefore, I am writing these “Question Banks” for myself to refer those questions/answers later if required.


  1. How to make an external HTTP request from Java/DropWizard?
  2. How to cache in Java/DropWizard?
  3. How to async in Java/DropWizard?
  4. How to debug in Java?

How to make an external HTTP request from Java/ DropWizard?

Like we can use “requests” module in Python, etc. What can we do in Dropwizard?



    // in a class, in a method
    Client client = ClientBuilder.newClient();
    String result ="http://path_to_external_resource").request().get(String.class);

    return result;

How to cache in Java/DropWizard?


package com.eduonix.redis.example
import redis.clients.jedis.Jedis; 

public class RedisCacheExample { 
   public static void main(String[] args) { 
      //Connect to Redis server using localhost
      Jedis jedis = new Jedis("localhost"); 
      System.out.println("Connection successful"); 	  
      //set string data in redis cache
      jedis.set("eduonix", "Redis cache tutorial"); 
      //Retrieve the string value from the cache 
      System.out.println("Stored data in cache: "+ jedis.get("eduonix")); 

How to async with Java/Dropwizard?


public class HelloResource {
    public void asyncHelloWorld(@Suspended final AsyncResponse asyncResponse) {
        new Thread(() -> {
            sleepUninterruptibly(1000, MILLISECONDS);
            asyncResponse.resume("Hello world!");

How to debug in Java?


That’s all for now. Thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s