我用java编写了一个简单的Web应用程序。单击时 index.jsp 页面中有一个按钮,这是一个来自 jar 文件的方法,称为 which print something。index.jsp 是这样的:
<html>
<head>
<title></title>
</head>
<body>
<form action="indexServlet.do">
<input type="submit" value="Click me!"/>
</form>
</body>
</html>
我的 IndexServlet 是这样的:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class IndexServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().println(Test.getMessage());
}
}
我想用 Apache Tomcat 运行程序并在程序运行时更改 Test.jar,我想更改 Test.jar 中的 getMessage() 方法。如何使用 Knopflerfish OSGi 做到这一点?我的意思是用另一个 jar 文件 Test.jar 替换 Test.jar,但新 Test.jar 文件中的 getMessage() 会打印其他内容。
有一篇文章OSGi Web application development with Server-Side Equinox但它不在 knopflerfish 中。