0

I have written a simple web application in java. There is a button in the index.jsp page when clicked, a method from a jar file called which print something. The index.jsp is like this:

<html>
  <head>
    <title></title>
  </head>
  <body>
    <form action="indexServlet.do">
      <input type="submit" value="Click me!"/>
    </form>
  </body>
</html>

My IndexServlet is like this:

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());
    }
}

I want to run the program with Apache Tomcat and change the Test.jar when the program is running, I want to change the method getMessage() in Test.jar. How can I do this with Knopflerfish OSGi? I mean replace Test.jar with another jar file, Test.jar, but getMessage() in new Test.jar file print something else.

There is an article OSGi Web application development with Server-Side Equinox but it is not in knopflerfish.

Ali
  • 11
  • 1
  • "I mean replace Test.jar with another jar file, Test.jar, but getMessage() in new Test.jar file print something else.": Do you that: Replace the old bundle with a new one without restarting the container – Balazs Zsoldos Jan 25 '15 at 18:12
  • yes, I want to change the jar file without restarting tomcat. – Ali Jan 25 '15 at 18:26
  • Is there any reason why you want to use Tomcat? As much as I know OSGi-Tomcat is supported by the Virgo project, but it is not really live nowadays. In the other hand, Jetty is supported by several projects and it would be easier to find the right solution if your code was Servlet Container independent. I guess you would like to run the Servlet container within an OSGi container, but correct me if I am wrong. – Balazs Zsoldos Jan 26 '15 at 09:17
  • I'm not forced to use Tomcat. I tried to add Pax web to Knopflerfish and run my project on Knopflerfish, as mentioned here: http://www.knopflerfish.org/kf_pax_web_tutorial.html. Until I use only JSP in the project, it works but when I add servlet to my project, it does not work. – Ali Jan 28 '15 at 06:15
  • Interesting. I will try that out when I have some time. I guess you wanted to deploy a WAB with a JSP and a Servlet that was defined in web.xml. – Balazs Zsoldos Jan 28 '15 at 07:45

0 Answers0