I am a little confused about the various methods’ implementations.
Actually, I was Learning Servlet and JSP and I found many methods like
request.getSession();
response.getWriter();
so please, can any one tell me where (In which class) the implementation of the methods (getSession(), getWriter(), etc) are present?
They are present in the servletcontainer itself. Even more, the servletcontainer is at its own actually the whole concrete implementation of the Servlet API.
In case of Tomcat (which is open source), the implementation of
request.getSession()is provided by theorg.apache.catalina.connector.Requestclass. In the current Tomcat 7.0.25 release it look like this:Equivalently, the
response.getWriter()implementation is provided byorg.apache.catalina.connector.Responseclass which look like this in Tomcat 7.0.25:So has each other servletcontainer/appserver (Glassfish, JBoss AS, Jetty, WebLogic, WebSphere AS, etc) its own implementation (although they mostly use a fork of Tomcat).