If I take your question literally (i.e. invoke doGet()
from doPost()
), you can just invoke the doGet()
method... it's a standard method like any other.
Here's a tip: When the doPost()
and doGet()
methods share a common set of logic, it's a good practice to isolate that logic into a separate (private) method that is to be invoked by all relevant do***()
methods. For example:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// GET-based logic
processCommonLogic();
// Other GET-based logic
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// POST-based logic
processCommonLogic();
// Other POST-based logic
}
private void processCommonLogic() /* throws ServletException and/or IOException if needed */ {
// Common logic
}
You can use this pattern to create a processError()
method that can be invoked wherever you need it.
However, if the scope your question goes beyond invoking doGet()
from doPost()
, I suggest you have a look at the references pointed by Alain O'Dea.