How to find your Servlet, JSP and Server version?

Today when I was doing something my colleague asked me about what version of JSP and Servlet are you using. Untill now I never bothered about this, but later found a way for this. below are the lines of code to know what version of servlet you are running, version of JSP and application server you are running.

Servlet Version :
<%= session.getServletContext().getMajorVersion() %>.
<%= session.getServletContext().getMinorVersion() %>

JSP Version :
<%= JspFactory.getDefaultFactory().getEngineInfo().
getSpecificationVersion()%>

Server Version : <%= application.getServerInfo()%>