Entering content frame

Procedure documentation Executing a Servlet as Portal Component Locate the document in its SAP Library structure

Use

Any servlet can be packed and executed as a portal component by packaging the servlet objects in a PAR file.

Procedure

·        Define a standard servlet class:

Example

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpServlet;

 

public class ServletTest extends HttpServlet {

   protected void doGet(HttpServletRequest req, HttpServletResponse resp) {

      try {

         resp.getWriter().write("I am a servlet");

      } catch (Exception e) {

      }

   }

}

·        In the PAR file declare that this object is a component of type servlet:

Example

<components>

 <component name="ServletTest">

  <component-config>

   <property name="ClassName" value="com.sapportals.portal.prt.component.ServletTest"/>

   <property name="ComponentType" value="servlet"/>

  </component-config>

</component>

·        Package the servlet object in the PAR file:

Example

<Portal Archive>

  |

  +-- META-INF

  +-- MANIFEST.MF

  +-- …

  +-- PORTAL-INF

  |   |

  |   +-- private

  |   |   +-- lib

  |   |       +-- servletTest.jar

 

 

Leaving content frame