Search code examples
javaservletsreturn

Should a servlet explicitly return at the end of doGet/doPost?


Is there any difference between explicitly returning at the end of doGet or doPost-methods, and just letting the method return "by itself"?

public void doGet(HttpSerlvetRequest req, HttpServletResponse resp) {
    <my code here>
    return;
}

public void doGet(HttpSerlvetRequest req, HttpServletResponse resp) {
    <my code here>
}

Solution

  • No. As a regular void method, it does not require a return