You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by GitBox <gi...@apache.org> on 2022/03/17 17:07:51 UTC

[GitHub] [tomcat] F4ded commented on pull request #484: Change the logic for judging whether a jsp file is outdated

F4ded commented on pull request #484:
URL: https://github.com/apache/tomcat/pull/484#issuecomment-1071100064


   > 
   Here is the details.
   
   org.apache.jasper.compiler.Compiler#isOutDated(boolean):
   ```java
   public boolean isOutDated(boolean checkClass) {
   
           if (jsw != null
                   && (ctxt.getOptions().getModificationTestInterval() > 0)) {
   
               if (jsw.getLastModificationTest()
                       + (ctxt.getOptions().getModificationTestInterval() * 1000) > System
                       .currentTimeMillis()) {
                   return false;
               }
               jsw.setLastModificationTest(System.currentTimeMillis());
           }
       //...
   }
   ```
   - `jsw.getLastModificationTest()` default value is 0 
   - `ctxt.getOptions().getModificationTestInterval()` default value is 4
   
   After modifying the jsp file, condition `if(jsw.getLast ...... > System.currentTimeMillis())` is false when the jsp file is accessed for the first time, then `jsw.setLastModificationTest(System.currentTimeMillis())` will be executed.
   
   So within 4 seconds we access this jsp page again, the condition `if(jsw.getLast ...... > System.currentTimeMillis())` will be true and the function `isOutdated` will return false:
   <img width="1098" alt="image" src="https://user-images.githubusercontent.com/66620626/158852595-7a68480a-9b17-4a51-bcdd-221c44e15a45.png">
   
   The statement `try{..}` will not be executed, when the function `compile()` returns to `JspServletWrapper#service`, the `
   compileException` will not be thrown, then function `getServlet()` will return a servlet which corresponds to the old jsp file, request will be handled by it, so the we get the response of old jsp file:
   <img width="862" alt="image" src="https://user-images.githubusercontent.com/66620626/158854495-3ac488c4-6807-4271-9b5c-a9bb1b5bcf7f.png">


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org