JSP Tips

To fetch value from a request if not sure about the attribute to be available always use below code:

String key = (request.getAttribute("my_key") != null) ? request.getAttribute("my_key").toString() : "";

The logic used here is :

return (value != null) ? value : DEFAULT;
The advantage of using this is we can handle Null Pointer Exception if attribute is not available in the jsp while using a common jsp by several pages.