cc.kkon.gmhttps.server.servelt.DefaultHttpServlet Maven / Gradle / Ivy
package cc.kkon.gmhttps.server.servelt;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public abstract class DefaultHttpServlet {
protected abstract void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
protected abstract void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
final void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String method = req.getMethod().toUpperCase();
if (method.equals("GET")) {
this.doGet(req, resp);
} else if (method.equals("POST")) {
this.doPost(req, resp);
} else {
throw new RuntimeException("Not supported method: " + method);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy