22
votes

I have a Hello-World application with one java class and one jsp. The JSP prints out some text that is embedded in the JSP and from the java class. (It prints out two things)

I followed the directions here to create and deploy my application and it (mostly) WORKS! I am able to invoke the JSP and it properly displays the page. I am also able to hotswap changes in the java class after I press the Intellij reload button.

Problem: If I change the JSP, it does not get reflected in the browswer.

I have verified the following:

  • web.xml in the Tomcat/conf directory does not override the "development" value. The default is true.
  • context.xml in both the HelloWorld\web\META-INF\context.xml and Tomcat\conf\context.xml has reloadable=true
  • That the JSP is copied from C:\code\HelloWorld\web\index.jsp to C:\code\HelloWorld\out\artifacts\HelloWorld_war_exploded\index.jsp on any change immediately
  • Its not a browser cache issue

any thoughts?

4
Can't reproduce. Try the vanilla Tomcat installation and see if it helps. If not, send your project to JetBrains support and provide the exact steps to reproduce the bug.CrazyCoder
I think the same issue and the proper solution is: stackoverflow.com/questions/19596779/…Fatih Aksu

4 Answers

31
votes

I am using Intellij IDEA 10.0.3 and ran into the same issue. I resolved it by checking a setting - "Update resources on frame deactivation" in you tomcat server setting under the Run/Debug Configuration section. Hope this helps.

31
votes

As I answer this question, IntelliJ IDEA is at version 13.0.2. The options are slightly different since this question was asked. In short, via the "Run/Debug Configurations" panel for your project:

  1. Make sure your project is set to be deployed as "war exploded" (via the "Deployment")
  2. On the "Server" tab, set "On frame deactivation" to "Update classes and resources"

Following those two steps, in order, will result in the project being "hot swapped" when IDEA loses focus (i.e. when you change focus to a web browser).

The full instructions are available at http://www.jetbrains.com/help/idea/2016.1/updating-applications-on-application-servers.html?search=application%20servers

6
votes

Try to edit Run/Debug Configuration, go to Deployment tab and deploy exploded war file.

2
votes

Years ago I had Tomcat configured to recompile jsp's when it saw a change in the modified time. Recently I tried the same settings, but it did not work for me.

In my situation the changes I needed to see were mostly changes in html and so I was able to encapsulate most of the html into a separate html file. I then include its contents within the jsp using a file read. I was then able to get immediate changes to the html reflected in the browser without a redeploy. Note that a jsp include did not do the trick (it cached the html), had to read the file using a file reader within a java helper to return the string to the jsp. (you could put the java logic in the jsp, but that's not at all mvc-like)

One caveat to this approach is merging variable data into the file read html. There are a couple of approaches you can use. 1. make up your own string replace algorithm and have your helper app dynamically replace the strings 2. output your variable data into a javascript block and let javascript update the html values within your file read html block (assuming you have the javascript chops to pull that off).