Rakesh Juyal
Rakesh Juyal

Reputation: 36799

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

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>

Upvotes: 33

Views: 98287

Answers (13)

Eduardo Vila&#231;a
Eduardo Vila&#231;a

Reputation: 7

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>

Upvotes: 0

Pankaj Singla
Pankaj Singla

Reputation: 1

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.

Upvotes: -2

Mdhar9e
Mdhar9e

Reputation: 1376

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.

Upvotes: 0

denispyr
denispyr

Reputation: 1443

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

Upvotes: 0

Warren Smith
Warren Smith

Reputation: 51

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>

Upvotes: 0

Bic Mitchun
Bic Mitchun

Reputation: 518

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

Upvotes: 0

Rajan Kumar Kharel
Rajan Kumar Kharel

Reputation: 129

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>

Upvotes: 6

kkk
kkk

Reputation: 848

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

Upvotes: 11

Beez
Beez

Reputation: 2101

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.

Upvotes: 7

lighthouse
lighthouse

Reputation: 494

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.

Upvotes: 2

Tito
Tito

Reputation: 9054

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.

Upvotes: 3

user2283714
user2283714

Reputation: 1

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

Upvotes: 0

Bozho
Bozho

Reputation: 597362

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.

Upvotes: 32

Related Questions