div.collapsecontent{display:block;}

Express (Distributed operating systems), v8.0 > Develop and deploying applications > Rapid deployment of J2EE applications > Constructing a J2EE application from artifacts > Dropping J2EE artifacts into a free-form project > Add and deleting Web artifacts from a free-form project


Add and deleting servlets to a free-form project

We can add or delete servlet source code, annotated source, or compiled class files to or from a free-form project.


Before you begin

Restriction: We can use the rapid deployment tools for packaging applications at J2EE 1.3 or 1.4 specification-levels. However, the rapid deployment tools do not support Java EE 5.0 (or later) nor J2EE 1.2 specification-level. For tools support of deploying Java EE 5 and later modules, you can use the monitored directory starting in WAS V8.0 release. For more details about the monitored directory, see Ways to install enterprise applications or modules and Installing enterprise application files by adding them to a monitored directory topics.

Prerequisites

The servlet class must be an implementation of the following types:

javax.servlet.Servlet
javax.servlet.GenericServlet
javax.servlet.//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/  .HttpServlet


Procedure

  1. To add servlets to a free-form project, use your file management system to properly place your servlet artifacts into the free-form project. The directory name of the free-form project has the same string value providedd for the -project parameter used in the wrd-config command.
  2. The following activities occur when you drop a servlet into a free-form project:

    1. If necessary, the servlet class is generated and mapped to the imported_classes directory of the Web module project. The rapid deployment tools then copy the class files to its appropriate J2EE location which is WebContent/WEB-INF/classes folder of the Web module project. The console output can look like this example when adding a servlet Java source file (called HelloServlet.java) to a free-form project (called MyProject):
      [06:52:23 PM] [/MyProject/servlet/HelloServlet.java] Added
      [06:52:26 PM] [/MyProject/bin/servlet/HelloServlet.class] copied to project [MyProjectWeb]
      [06:52:27 PM] Servlet added to web.xml: HelloServlet
      [06:52:27 PM] Servlet mapping added.  URL is: [MyProjectWeb/HelloServlet]
      

      Tip: To monitor the rapid deployment activity, run your rapid deployment session with console output. You can complete this by running the rapid deployment launch tool as follows:

      • wrd.bat -monitor
      • wrd.sh -monitor

    2. A new servlet entry and servlet mapping entry is created in the Web deployment descriptor (found in the WebContent\WEB-INF\web.xml file in the Web module project). Example of the entries in web.xml:
      <servlet>
      <servlet-name>HelloServlet
      </servlet-name>
      <servlet-class>servlet.HelloServlet
      </servlet-class>
      </servlet>
      <servlet-mapping>
      <servlet-name>HelloServlet
      </servlet-name>
      <url-pattern>/HelloServlet
      </url-pattern>
      </servlet-mapping> 
    3. The application is synchronized with the server.

  3. We can test the servlet running on the server, use the URL displayed in the console. In this example, the console output provided the following URL mapping information to the deployed servlet:
    [06:52:27 PM] Servlet mapping added.  URL is: [MyProjectWeb/HelloServlet]
    
    Type //publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/ :// <machine_name>: <port>/MyProjectWeb/HelloServlet in the address bar and press Enter. Where <machine_name> is the host machine where WAS runs. By default, WAS runs on port 9080.

  4. To delete servlets from a free-form project, use your file management system to properly remove your servlet artifacts from the free-form project. The directory name of the free-form project has the same string value you had provided for the -project parameter used in the wrd-config command.
  5. The following activities occur when you remove a servlet from the free-form project:

    1. The console output can look like this example when removing a servlet Java source file (called HelloServlet.java) from a free-form project (called MyProject):
      [07:03:42 PM] [/MyProject/bin/servlet/HelloServlet.class] Deleted
      [07:03:42 PM] [/MyProject/servlet/HelloServlet.java] Deleted
      [07:03:42 PM] Servlet Mapping removed from web.xml /HelloServlet
      [07:03:42 PM] Servlet removed from web.xml: HelloServlet
      
    2. The application is synchronized with the server.


Feedback

+

Search Tips   |   Advanced Search