Hot Deploy JSP after modification with Intellij 10.X and tomcat 6.X
Asked Answered
G

4

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?

Grip answered 5/4, 2011 at 21:10 Comment(2)
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.Horsewhip
I think the same issue and the proper solution is: #19597279Frediafredie
B
35

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

Bellay answered 7/2, 2014 at 15:3 Comment(1)
@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.Bellay
C
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.

Conduplicate answered 3/5, 2011 at 20:12 Comment(0)
A
6

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

Alleviative answered 5/10, 2012 at 11:55 Comment(1)
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" tabBurrill
K
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).

Kellam answered 22/4, 2011 at 13:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.