I’ve written a simple REST service class, and I need to deploy and run it under glassfish server, installed on my eclipse.
What steps have I to do in order to put this restlet service online and reach it from my browser?
This is the code:
import javax.ws.rs.*;
import javax.ws.rs.core.*;
@Path("/myApplication")
public class MailRestlet {
@SuppressWarnings("unused")
@Context
private UriInfo context;
/**
* Default constructor.
*/
public MyRestlet() {
// TODO Auto-generated constructor stub
}
@GET
@Produces("text/html")
public String getHtml() {
return "<html><body><h1>Hello World!!</h1>The service is online!!</body></html>";
}
}
You also need to configure the web.XML file, for example, as in http://download.oracle.com/docs/cd/E19776-01/820-4867/ggrby/index.html
There is also a way to avoid web.XML change, by extending the Application class from jaxrs…