Skip to content

Commit

Permalink
Simple servlet registration.
Browse files Browse the repository at this point in the history
Now if you do "mvn clean install pax:provision" you can go to
http://localhost:8080/hello and get response from just registered
servlet.
  • Loading branch information
neotyk committed Mar 16, 2009
1 parent 73f08b8 commit 659497e
Showing 1 changed file with 14 additions and 2 deletions.
@@ -1,11 +1,23 @@
package pl.kungfoo.grizzly.osgi.httpservice.gitorial.impl;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.osgi.service.http.*;

public class RegisterServletComponent {

public void setHttp(HttpService http) {
System.out.println("Got Http Service: " + http);
public void setHttp(HttpService http) throws ServletException, NamespaceException {
http.registerServlet("/hello", new RegisterServlet(), null, null);
}
}

class RegisterServlet extends HttpServlet {

public void doGet(HttpServletRequest rq, HttpServletResponse rsp) throws IOException {
PrintWriter pw = rsp.getWriter();
pw.println("Hello World");
rsp.setContentType("text/plain");
}
}

0 comments on commit 659497e

Please sign in to comment.