Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
borderStylesolid
titleMyServlet.java
package sampleear;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    static final long serialVersionUID = 1L;

    @EJB
    RemoteBusinessInterface remoteBusinessIntf;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        if (name == null || name.length() == 0) {
            name = "anonymous";
        }
        response.getWriter().write(remoteBusinessIntf.sayHello(name));
    }
}

Run it!

After a very hard 4-minute development All it's time to give it a shot and see if it works. Not much time left so hurry up!left before we test this sample it to deploy it. This task is done automatically for you when you choose to run the application directly from the eclipse workspace.

  1. Right-click on the SampleEAR project and select Run As -> Run on Server. When Run On Server popup window comes up, select the Always use this server when running this project checkbox. Leave the rest as is.

...


  1. Image Added

...


  1. Click Finish.
  2. The server's stopped so nothing happens (from a user's perspective at least). Open up the Servers tab and right-click on Apache Geronimo v2.

...

  1. 1 Server at localhost and select Start.

...

  1. After a few seconds, Geronimo

...

  1. will be up and running with the enterprise application published. Open up the browser of your choice and go to http://localhost:8080/SampleWARImage Modified.

Type in any name you want, e.g. Jacek and press Press me! button.

...