Skip to content

Instantly share code, notes, and snippets.

@shariqislam786
Created May 10, 2018 09:23
Show Gist options
  • Save shariqislam786/c8dadae9037757744743ded53998dfec to your computer and use it in GitHub Desktop.
Save shariqislam786/c8dadae9037757744743ded53998dfec to your computer and use it in GitHub Desktop.
How to inject existing servlet into spring
import javax.servlet.annotation.WebServlet;
import org.springframework.web.context.support.HttpRequestHandlerServlet;
/**
* Servlet implementation class AnnotatedHttpServlet
*/
@WebServlet(description = "Graph Ql Servlet", urlPatterns = { "/endpoint" }, name = "servletHandler")
public class AnnotatedHttpServlet extends HttpRequestHandlerServlet {
private static final long serialVersionUID = 1L;
}
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.HttpRequestHandler;
@Component("servletHandler")
public class MyServletHandler extends YourServlet implements HttpRequestHandler{
/**
*
*/
private static final long serialVersionUID = -4341531037517042097L;
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment