There is documentation for DWR exception handling for Client side:
http://directwebremoting.org/dwr/documentation/browser/errors.html
But I'm looking for documentation for DWR Server side Exception handling. Basically the problem that I'm running into is: verbose errors(stacktrace) is returned to the client side, exposing web application details. Need to ensure no stacktrace is returned to the client.
DWR Version: 3.0
Any pointers on server-side exception handling for DWR? Thanks.
In that case I would wrap the exception with a try/catch block. The question is: Where should you do that?
Well, DWR has a Filter mechanism which is much like filters in Java Servlet API.
You could write something like this:
public class ExceptionFilter implements org.directwebremoting.AjaxFilter {
public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception {
Object res;
try{
res = chain.doFilter(obj, method, params);
} catch(Exception e){
// throw your Exception with no "extra" data
throw new RuntimeException();
}
return res;
}
}
You may need to do some configuration in the dwr.xml file (which I leave to your reading: http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/filters.html)
(edit 1) Some more explanation:
What this does is intercept the DWR remote call and forward the call on to the execution chain. What I added to that call (chain.doFilter) is a try/catch block; In case your code should throw any exception, it will end up in the catch block and then its up to you what to do next.
I hope this will help you :]