Here is a Sample.
This Code is in your JSP
<form action="Yourservlet?action=ButtonClicked" method="post">
<%-- Your Code Here --@>
<input type="submit" value=" Ok " />
</form>
This Code is inside Yourservlet.java
//Inside your servlet
String action = request.getParameter("action");
try{
if (action.equalsIgnoreCase(null)){
//Your error Handler
}else if (action.equalsIgnoreCase("ButtonClicked"))
{ // Here is where the code that will run if the button is clicked
} else {
//Your Default operation
}
} catch (Exception A) {
//Another Error Handler ^_^
}