Look, this is real simple:
Servlet:
doPost(req, res)...{
String forwardTo = "success.jsp"
try{
DataOps dataOps = new DataOps();
dataOps.getStuffFromDataBase();
dataOps.getUserInfoFromLdap(uid);
}
catch(Exception e){
forward = "failure.jsp";
if(e instanceof SQLException){
req.setAttribute("error", "The database is currently being updated. Please try again later");
}
else if(e instanceof NameNotFoundException){
req.setAttribute("error", "The uid entered is incorrect. It does not exist in LDAP!");
}
else{
req.setAttribute("A Service Interuption has occurred!");
}
e.printStackTrace();
}
RequestDispatcher rd = req.getRequestDispatcher(forwardTo);
rd.forward(req, res);
}
Here the method getUserInfoFromLdap throws a NameNotFoundException and getStuffFromDataBase throws a SQLException.
The JSP:
String error = (String)request.getAttribute("error");
if(error != null){
%>
<font color=red>* <%=error%></font>
<%
}
%>
This is the very least that should be done.