1.环境配置
2.OSGI中开发Web--------------------HttpInOSGI
package com.xue.httpinosgi;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;
public class Activator implements BundleActivator {
private ServiceReference serviceReference;
private HttpService httpService;
private static BundleContext bc;
public void start(BundleContext context) throws Exception {
System.out.println("Hello World!!");
bc = context;
registerResource();
}
private void registerResource() {
try {
serviceReference = bc.getServiceReference(HttpService.class
.getName());
if (serviceReference != null) {
httpService = (HttpService) bc.getService(serviceReference);
httpService.registerResources("/demo", "page", null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!!");
unregisterResource();
}
private void unregisterResource() {
try {
httpService.unregister("/demo");
} catch (Exception e) {
e.printStackTrace();
}
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>Hello, This is a test page!
</body>
</html>
参考http://www.cnblogs.com/skyme/archive/2012/07/10/2583952.html
3.升级JSP