Why are my JSP changes are not reflected without restarting Tomcat?

前端 未结 12 1337
忘掉有多难
忘掉有多难 2020-12-02 18:48

I am editing JSP files which are residing directly inside tomcat/webapps/myapp/WEB-INF, but to see the changes, I have to restart the server. As far as I know,

相关标签:
12条回答
  • 2020-12-02 19:04

    Simple to figure out though it may be, here's what "setting development to true" means (more for a quick reference):

    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>false</param-value>
        </init-param>
        <!-- Add the following init-param -->
        <init-param>
            <param-name>development</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>
    

    And then restart.

    0 讨论(0)
  • 2020-12-02 19:05

    Open your context.xml file in your META-INF folder and set antiJARLocking to false.

    Your directory tree should be as follows:

    Web > META-INF > context.xml

    0 讨论(0)
  • 2020-12-02 19:08

    Actually jsp engine check whether jsp page is older than its servlet page or not and on the basis of this it it's decide whether changes are needed or not.

    0 讨论(0)
  • 2020-12-02 19:11

    I had the same problem and fixed the issue. Make sure that in conf/context.xml you do not have following configuration

    <Context antiJARLocking="true" antiResourceLocking="true">
    

    If you have that one, remove both antiJARLocking="true" antiResourceLocking="true", just write

    <Context>
    
    0 讨论(0)
  • (Tomcat 7.0.62) I had to go to CATALINA_HOME/temp/xx-mysite/, find my jsp file in that directory tree and edit it.

    xx is a random(?) prefix number, in my case 11, but every site had one.

    0 讨论(0)
  • 2020-12-02 19:13

    In the tomcat docs, see the development setting. It must be set to true in order to have jsps reloaded.

    development - Is Jasper used in development mode? If true, the frequency at which JSPs are checked for modification may be specified via the modificationTestInterval parameter.true or false, default true.

    This is in your CATALINA_HOME/conf/web.xml

    Additionally, if you need to refresh a jsp in a production environment without restart, you can go to CATALINA_HOME/work/Catalina/localhost/contentName/org/apache/jsp and delete the your_jsp.java and your_jsp.class files. They will be recreated the next time they are accessed.

    Edit: after providing your configuration, and comment about not refreshing the content, I have another though: clear your browser cache, or open the page from another browser.

    0 讨论(0)
提交回复
热议问题