Skip to content

Instantly share code, notes, and snippets.

@syst3mw0rm
Created February 26, 2014 15:16
Show Gist options
  • Save syst3mw0rm/9231312 to your computer and use it in GitHub Desktop.
Save syst3mw0rm/9231312 to your computer and use it in GitHub Desktop.
example to share code among servlets
public class Servlet1 extends HttpServlet {
public void init() {
doHeavyProcessing();
}
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
parseRequest();
calculateResponse();
Servlet1CustomCode();
sendResponse();
}
private void doHeavyProcessing() {
}
private void Servlet1CustomCode() {
}
private void sendResponse() {
}
private void calculateResponse() {
}
private void parseRequest() {
}
}
public class Servlet2 extends HttpServlet {
public void init() {
doHeavyProcessing();
}
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
parseRequest();
calculateResponse();
Servlet2CustomCode();
sendResponse();
}
private void doHeavyProcessing() {
}
private void Servlet2CustomCode() {
}
private void sendResponse() {
}
private void calculateResponse() {
}
private void parseRequest() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment