Step 1: Projects Window After Adding Servlet Page in Source Package
Step 2:
1.doGet, if the servlet supports HTTP GET requests
2.doPost, for HTTP POST requests
3.doPut, for HTTP PUT requests
4.doDelete, for HTTP DELETE requests
5.init and destroy, to manage resources that are held for the life of the servlet
6.getServletInfo, which the servlet uses to provide information about itself
The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
The servlet container creates an HttpServletResponse object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
Source Code
fServlet.java
Step 3: Web.xml code
Download Code Link 2
Step 4: Right click on fServlet.java code page and click on Run File or press Shift+F6
Output:
Step 2:
java.io Package
public class IOException extends Exception
Signals
that an I/O exception of some sort has occurred. This class is the
general class of exceptions produced by failed or interrupted I/O
operations.
public class PrintWriter extends Writer
Prints
formatted representations of objects to a text-output stream. This
class implements all of the print methods found in PrintStream.
javax.servlet Package
public class ServletException extends Exception
Defines a general exception a servlet can throw when it encounters difficulty.
javax.servlet.http Package
public abstract class HttpServlet extends GenericServlet implements Serializable
Provides
an abstract class to be subclassed to create an HTTP servlet suitable
for a Web site. A subclass of HttpServlet must override at least one
method, usually one of these:1.doGet, if the servlet supports HTTP GET requests
2.doPost, for HTTP POST requests
3.doPut, for HTTP PUT requests
4.doDelete, for HTTP DELETE requests
5.init and destroy, to manage resources that are held for the life of the servlet
6.getServletInfo, which the servlet uses to provide information about itself
public interface HttpServletRequest extends ServletRequest
Extends the ServletRequest interface to provide request information for HTTP servlets.The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
public interface HttpServletResponse extends ServletResponse
Extends
the ServletResponse interface to provide HTTP-specific functionality in
sending a response. For example, it has methods to access HTTP headers
and cookies.The servlet container creates an HttpServletResponse object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
java.io.PrintWriter
public void println()
Terminates
the current line by writing the line separator string. The line
separator string is defined by the system property line.separator, and
is not necessarily a single newline character ('\n').Source Code
fServlet.java
Step 3: Web.xml code
Download Code Link 2
Step 4: Right click on fServlet.java code page and click on Run File or press Shift+F6
Click ok button
More Servlet Topics :
- Introduction : Servlet Interface
- Java Package javax.servlet(Interfaces,Classes and Methods)
- Java Package javax.servlet.http (Interfaces,Classes and Methods)
- How to Create a Web Application using NetBeans and Apache Tomcat Server
- Basic Program using HttpServlet Class
- Basic Login Program using JSP and GenericSevlet class
- Login using JDBC,Servlet with NetBeans and Oracle
- SevletConfig Interface using JDBC,NetBeans 6.9 and Oracle 10g
- Validation on TextField using JavaScript and Print command using servlet on NetBeans
- ServletContext Interface
- RequestDispatcher Interface and SendRedirect() Method
- Session Tracking
- Session Tracking using Cookies
- Session Tracking using HttpSession Interface
- Session Tracking using URL Rewriting
- Session Tracking using Hidden Forms Field
- Sql Query Tool using Servlet
No comments:
Post a Comment