Following are the steps to deploy a project in the server.
We use Apache Tomcat and the folder to place the project folder is usually C:\Program Files\Apache Software
Foundation\Tomcat 6.0\webapps
- Write the java code for the servlet and compile it to generate the required .class file.
- Place the .class file in the "classes" folder.
- Describe about class file we have placed in the class file into the web.xml
- Deploy the project on to the server i.e., copy the root project folder into the webapps folder of the server.
- Open the url of the project which is usually of the format http://localhost:8080/project-name/url-pattern
Points to remember:
1. Server is responsible to create objects when the project
is deployed on it. Request and Response objects are created by the server
directly.
2. Server is only responsible to destroy the objects and the
servlet when the project is removed from the server.
3. init() is
only executed once irrespective of how many times we execute the servlet.
4. service()
method only contains all the logic about the program and the operations to be
performed.
5. GenericServlet and HttpServlet classes are abstract and
only require the user to override the service()
method.
Basic Servlet Project: https://www.box.com/s/v1izt70n8e8n2s68w0zb
Basic Servlet Program: http://pastie.org/6281345
Output Screenshot:
Above program is a basic servlet and the output is observed
in the Apache Server Start Window.
0 comments:
Post a Comment