Application Server Solutions for Microsoft IIS and ASP.NET
       solutions   products   partners   company   support   downloads         store
ServletExec Self-Help: FAQ
Back to Search >  Back to Search Results

Faq ID 100
Product ServletExec
Category Class Loading/Reloading, JSP
Question My JSP uses a JavaBean (or some other helper object). When I change the class file of the JavaBean, the JSP does not use the new version of the JavaBean. Why?
Answer The first time that ServletExec receives a request for a particular JSP, It creates a Servlet representation of that JSP and then compiles it. Then that servlet class is loaded into the JVM and an instance of the Servlet is created to service the request (i.e. send an HTTP response). Servlets remain in memory (they are persistent) and they are multithreaded, so subsequent requests for the same JSP are serviced by the same servlet instance. If that servlet instance happens to create instances of other "helper" objects (a JavaBean for example), then the servlet continues to use the original JavaBean reference (i.e. the helper objects are persistent too). Depending upon where the class file for your JavaBean resides you have certain options to get the JSP to load the new version of the JavaBean:
  1. Change the last modified timestamp of the JSP source so that ServletExec will think it has changed. This will cause SE to throw away the currently loaded instance of the servlet, compile the "new" JSP into a new servlet, load an instance of it into the JVM (new reference to the new JavaBean) and invoke it to service the request.
  2. If you are running your JSP inside a Web Application then you could dynamically reload the entire Web Application from the SE Admin UI.
  3. Reinit ServletExec (which stops the JVM effectively unloading all code from the JVM)
If the class file for your JavaBean resides in the Servlets folder then it will be loaded by a Custom Classloader that is owned by ServletExec. This means that options 1, 2, or 3 listed above will work for you. If the class file for your JavaBean does NOT reside in the Servlets folder but instead is in the main ServletExec classpath then it will be loaded by the System Classloader. This means that only option 3 will work for you. If your JavaBean (and the JSP that uses it) is part of a Web Application then option 2 will work for you.
Essentially, if a class is loaded into the JVM using the System Classloader the only way to unload it and get the new version of the class to be used is to stop the JVM and start it up again. This is a big reason why Web Applications in ServletExec are so useful since all the code running in a web app is loaded into the JVM by a Single Custom Classloader.

company media information terms of use privacy policy contact us