0 Replies Latest reply on Nov 25, 2008 2:46 PM by Gregory Nikle

    how to create seam servlet with EJB entitymanager?

    Gregory Nikle Apprentice
      Hi,
      I try to create fully functional seam servlet with EJB3.0 em.
      I read this artice: http://seamframework.org/Documentation/ReplacingServletsWithSeamResources

      Can anybody point step-by-step how to get what I want?

      1. I created class:

      `
      @Scope(ScopeType.APPLICATION)
      @Name("myResource")
      @BypassInterceptors
      public class MyResource extends AbstractResource {

          @Override
          public String getResourcePath() {
              return "/myresource";
          }


          @Override
          public void getResource(final HttpServletRequest request, final HttpServletResponse response)
                  throws ServletException, IOException {

              new ContextualHttpServletRequest(request) {
                  @Override
                  public void process() throws IOException {
                      System.out.println("somethink");
                      doWork(request, response);
                  }
              }.run();
          }

          private void doWork(HttpServletRequest request, HttpServletResponse response) {
             // Component.getInstance(...);
              System.out.println("somethink2");
          }
      }
      `

      and added to components.xml

      '<web:context-filter url-pattern="/servlet/*" />'


      what to do next?
      Do I need to write?


      `<servlet>
              <servlet-name>myresource</servlet-name>
              <servlet-class>com.servlets.MyResource</servlet-class>
          </servlet>
          <servlet-mapping>
              <servlet-name>myresource</servlet-name>
              <url-pattern>/servlet</url-pattern>
          </servlet-mapping> `


      my app is called by http:localhost:8080/app/
      how to call my servlet?