Created
May 10, 2018 09:23
-
-
Save shariqislam786/c8dadae9037757744743ded53998dfec to your computer and use it in GitHub Desktop.
How to inject existing servlet into spring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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