Java Reference
In-Depth Information
NetBeans creates a servlet using the class name and package we specified in the
wizard. The generated servlet contains a processRequest() method that will be
executed every time the servlet receives an HTTP GET or an HTTP POST request
from the browser. This method takes an instance of javax.servlet.http.
HttpServletRequest and an instance of javax.servlet.HttpServletResponse
as parameters. These parameters are equivalent to the request and response implicit
objects in JSPs.
The processRequest() method is a NetBeans specific method that is generated
when we use the NetBeans servlet wizard to create a method. The reason this
method is created is because in most cases we would like the servlet to execute the
same code regardless of if the servlet received an HTTP GET or an HTTP POST
request from the browser. These two requests are handled by the doGet() and
doPost() methods, respectively, these methods are inherited from the javax.
servlet.http.HttpServlet class, which is the parent class of all the servlets in a
Java web application.
Notice at the bottom of our class we can see that there is some code in our servlet
that has collapsed (using NetBeans code folding feature). By clicking on the plus
sign next to the collapsed code we can expand it and examine it.
Search WWH ::

Custom Search