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

岁酱吖の 提交于 2019-11-27 12:05:18

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.

An even more late answer ...

Setting "antiResourceLocking" to "true" in the context file may prevent JSP to be reloaded by the Tomcat (Bugzilla 37668).

This is documented on the Tomcat doc, at the "antiResourceLocking" parameter explanation

Rajan Kumar Kharel

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>

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.

cherit

A late answer, anyone else might find this useful though.

Check the permissions on the Tomcat folder, I have tried a lot of other solutions and it did not work out.

Finally I gave my 'user account' 'Full control' permission to the Tomcat folder and Tomcat picked up the changes whenever I made a change in JSP. I am assuming you are using Windows. The rationale behind this was: whenever you make a change in JSP, it has to be compiled and deployed (written) to the webapps folder. If there is no 'write' permission on that folder, it will silently fail. This was happening in my case. So if reloadable = true and development = true in the context.xml do not work, try this permission fix.

I am using Tomcat 7 on Windows 7.

Synchronize server & client time

you can check your server time and client system time. For me a few days ago after changing the server time correctly worked. It reflected the changes of the .jsp files.

user2283714

You will need to go to the server project in Eclipse and edit the web.xml file and set 'development' to true.

Bic Mitchun

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

I am using TomEE 1.7.2 on Windows 7 with Eclipse. The solution that worked for me was simply changing the web.xml file for the TomEE server at localhost-config (in my IDE) so that the development init param is true:

<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>
    <init-param>
        <param-name>development</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

(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.

I too faced this problem while doing jsp changes in myeclipse, those are not reflecting in the application while running. I hope these checks will help you.

  1. Double click on Tomcat Server from MyEclipse.
  2. click the Publishing menu from the Overview window.
  3. Select the Radio button "Automatically publish when resources change"
  4. enter the publishing interval time as 1 second.

I hope this will help you.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!