The default superclass is HttpServlet. implements Specifies a

<%@ extends = "CustomHttpServletSuperclass" %> The default superclass is HttpServlet. implements Specifies a list of interfaces the servlet should implement. Multiple interfaces can be given in a comma- separated list or given through multiple import directives. For example: <%@ implements = "Serializable" %> The default behavior is to not implement anything. method Specifies the servlet method that should contain the generated code and handle client requests. The default is “service”, which handles all requests. For example: <%@ method = "doPost" %> language Specifies the scripting language used by the back-end. The default language is “java”. Some servers can choose to allow other languages. For example: <%@ language = "java" %> Example 2-8 shows a revised version of the Hello page that uses JSP expressions and directives. It uses a method directive to indicate it should handle POST requests, and it uses an expression to simplify its display of the nameparameter. Example 2-8. Saying Hello using JSP expressions and directives <%@ method = doPost %> Hello

<% if (request.getParameter( name ) == null) { %> Hello World <% } else { %> Hello, <%= request.getParameter( name ) %> <% } %>

The background workhorse servlet for this JSP page should look nearly identical to Example 2-7, with the only difference that this servlet implements doPost()instead of service(). Declarations Sometimes it’s necessary for a JSP page to define methods and nonlocal variables in its workhorse servlet. For this there is a construct called a JSP declaration. A declaration begins with a tag. In between the tags, you can include any servlet code that should be placed outside the servlet’s service method. Example 2-9 demonstrates this with a JSP page that uses a declaration to define the getName()method.
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra j2ee hosting services

Comments are closed.