33

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, JSP changes don't require you to restart the server. The only configuration I found which is related to automatic reloading is reloadable = "true"

Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected.

I used this attribute in the context.xml, but still the problem persists. What could be the other possible reason of not detecting changes in JSP files without restarting?

@Bozho: This is the excerpt from web.xml. Do I need to change something?

 <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>
        <load-on-startup>3</load-on-startup>
    </servlet>
austin
  • 5,816
  • 2
  • 32
  • 40
Rakesh Juyal
  • 35,919
  • 68
  • 173
  • 214
  • the config is fine. check my update (and your browser cache) – Bozho Jan 05 '10 at 09:27
  • 1
    Thus, you're using an IDE which takes control over from the appserver? – BalusC Jan 05 '10 at 11:51
  • 1
    Got the same Problem with Tomcat 8 and Java 8. Worked fine with Tomcat 7 and Java 7. I also tried the development parameter but it's still not working. Maybe it is caused by the WTP library update which was necessary to configure Eclipse Kepler with Tomcat 8. – Chip Sep 04 '14 at 10:56

13 Answers13

32

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.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • 3
    interesting thins is i have deleted all files from `CATALINA_HOME/work/Catalina/localhost/contentName/org/apache/jsp` and on accessing the page, new .java and .class files are created for the jsp. But still the changes are not getting reflected. :( – Rakesh Juyal Jan 05 '10 at 09:11
  • We have the same issue from time to time, @RakeshJuyal have you found any solution? – Marcus Dec 06 '12 at 13:26
  • The comment about clearing the browsers cache saved me from losing another day on this! – M.C. Feb 17 '13 at 22:14
11

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

kkk
  • 818
  • 8
  • 11
7

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.

Beez
  • 2,081
  • 1
  • 20
  • 23
6

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>
austin
  • 5,816
  • 2
  • 32
  • 40
  • 1
    This also appears to work for static files, like html, js, etc. that you may wish to update independent of restarting the application. – J E Carter II Feb 17 '16 at 21:40
3

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.

bluish
  • 26,356
  • 27
  • 122
  • 180
Tito
  • 8,894
  • 12
  • 52
  • 86
  • I think this worked for me... the class and java files I added under the work directory weren't being picked up so I tried this and ran garbage collection and finally my jsp updates were reflected on the server – Edd Feb 12 '16 at 16:24
2

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.

lighthouse
  • 494
  • 1
  • 6
  • 12
0

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

bluish
  • 26,356
  • 27
  • 122
  • 180
0

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

Celt
  • 2,469
  • 2
  • 26
  • 43
Bic Mitchun
  • 478
  • 2
  • 9
  • 21
0

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>
Warren Smith
  • 41
  • 1
  • 1
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.

denispyr
  • 1,403
  • 3
  • 21
  • 34
0

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.

enter image description here enter image description here

I hope this will help you.

Mdhar9e
  • 1,376
  • 4
  • 23
  • 46
0

Go to your web.xml find your jsp servlet, add this parameter after the other ones:

<init-param>
  <param-name>developer</param-name>
  <param-value>true</param-value>
</init-param>
-2

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.