Using php one can easily define global variables using
global $variable
However, if you are using java, you have to do something. Java can provide variables,objects to be defined or stored in application life-cycle called application scope. You can define it in jsp;
getServletContext().setAttribute(String,Object);
To access this varibale
Sample sample = (Sample) getServletContext().getAttribute(String);