Tomcat Server Configuration in Intellij IDEA


Server Tab

As seen, in Server tab click Configure button located in Application Server line, then choose Tomcat Server path.

In the middle of that tab, change the "On frame Deactivation" setting to either "Update resources" or "Update Classes and Resources"

       Update resources: All changed resources (that is, all application components other than the classes) will be updated.

       Update classes: and resources. All changed resources will be updated; changed classes will be recompiled.

Note that whether the actual classes will be updated depends on the capabilities web server. If I recall, Tomcat will reload html/xhtml and jsp files, but not Servlets or classes that JSPs or Servlets use. You need to modified Tomcat to use a dynamic classloader for that.

You can also set the "On 'update' action as well.

       This determined what happens when you hit the Update Update icon icon (or Ctrl+F10) in the Run window.

       the "Show dialog" determines if IDEA prompts you each time you hit the update icon

Now anytime you make a change, IDEA will redeploy the changed file(s) when IDEA's frame is deactivated (i.e. loses focus). It does take a second or two, You'll see it in the lower status bar in IDEA. Obviously. you'll still need to refresh your web browser so it fetches the new file (unless of course if the page has an auto refresh of ajax like fetch).

Note: A good combination with Tomcat is to set "On frame deactivation" to "Update Resources" and the "On 'update' action to either "Redeploy" or "Restart Server". That allows static pages to be quickly updated via frame deactivation, and class updated via the 'update' action.

Note: A company named ZeroTurnaround sells JRebel which is a dynamic classloader solution. They also have a five part series on the subject that's very good.

Note: If you want to use free classloader solution, please look at HotswapAgent

Deploy Tab

In the "Deploy at Server Startup" section, remove (if present) the artifact my-webapp-name:war

Click the add icon, select 'artifact' and then select my-webapp-name:war exploded

Click OK

Note: If you want Tomcat to recognize changed files automatically, choose war exploded option.

Show JSP Variables

To show JSP variables, click pageContext variable in the Debug frame, then click attributes variable.

© 2019 All rights reserved. Codesenior.COM