24

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?

Tihom
  • 3,384
  • 6
  • 36
  • 47
  • 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 Apr 05 '11 at 22:54
  • 1
    I think the same issue and the proper solution is: http://stackoverflow.com/questions/19596779/intellij-and-tomcat-changed-files-are-not-automatically-recognized-by-tomcat – Fatih Aksu Apr 09 '15 at 08:10

4 Answers4

34

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

James Sumners
  • 14,485
  • 10
  • 59
  • 77
  • @Madbreaks I updated it, but I'm sure it'll break again. No one knows what a 301 is for any more. So you'll just have to search the documentation for "application servers" in the future. – James Sumners May 13 '16 at 15:05
31

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.

cyanglee
  • 311
  • 2
  • 2
6

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

Sumit Singh
  • 15,743
  • 6
  • 59
  • 89
Sasa
  • 71
  • 1
  • 3
  • I tried all the solutions but on idea12, this one seems the only working solution. After deploying the exploded war, press the button "Update Resources on frame deactivation" on the "Run"/"Debug" tab – Rigg802 Jan 28 '13 at 16:20
2

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

TroyJ
  • 1,620
  • 1
  • 10
  • 7