13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

408Chapter 18Servlets: Java Pressed into ServiceExample 18.1 A “Hello, world” servlet/** HiServlet.java*/package net.multitool.servlet;import javax.servlet.*;import javax.servlet.http.*;/*** Simple Servlet that generates a page of HTML*/public classHiServletextends HttpServlet{/*** Think of this as the c<strong>on</strong>structor for the servlet.* We need do nothing for our example,* but we should call our parent object.*/public voidinit(ServletC<strong>on</strong>fig c<strong>on</strong>fig)throws ServletExcepti<strong>on</strong>{super.init(c<strong>on</strong>fig);} // init/*** Called when the Web server is shutting down* or wants to shut down this particular servlet.* We need do nothing.*/public voiddestroy(){} // destroy/*** Handles the HTTP GET method.* @param request servlet request* @param resp<strong>on</strong>se servlet resp<strong>on</strong>se*/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!