JSP vs Servlets Comparison

Key Differences

JSP Implicit Objects

These are variables automatically available in JSP pages during request handling stage. They are internally local variables of the jspService() method:

Object Type Description
request HttpServletRequest HTTP request object
response HttpServletResponse HTTP response object
config ServletConfig Servlet configuration
session HttpSession User session object
application ServletContext Application context
page Object Current page (this pointer)
pageContext PageContext Page context for attributes
out JspWriter Output writer
exception Throwable Available only in error pages

JSP Syntax Elements

1. Directives <%@ ... %>

2. Declarations <%! ... %>

3. Scriptlets <% ... %>