0

Is using JSP Hot deployment a solution to publish new or updated content to avoid restarting the Java EE server (cannot hot deploy jar)? I should not use JSP to code a lot of java, but do I have any other solution?

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
J.M. Kenny
  • 384
  • 4
  • 11
  • JSPs are a form of hot deployment, being compiled too. Updated content might come from a data base, or maybe generated files, not necessarily in the same web app. – Joop Eggen Apr 25 '13 at 16:01
  • Thanks for you answer. My concern is about using JSP to code java because in a lot of books, they always recommend to use jsp for presentation when talking about application design. This is good, but I just wonder If I will run into issues using JSP to code application logic other than presentation because I need frequent update without restarting tomcat, without Jar hot deployment. There is not a lot of code in each JSP but I will need many jsp. – J.M. Kenny Apr 25 '13 at 16:38
  • Code like filling a `List` _(data model)_ can be done in a servlet _(controller)_, that does `getRequestDispatcher("my.jsp").forward(request, response)` and setting the data List in a request attribute. JSPs are for the final _view_, doing the templating and showing the data. – Joop Eggen Apr 25 '13 at 16:47
  • Yes, this is true. But I will need to restart tomcat if I make any changes in the servlet because I only hot deploy JSP. My Idea was to use let say one JSP as controller and then update it without having to restart tomcat. Then in this JSP I will use forward action. I wonder if the only reason for not doing something that is possible is because of design (like MVC). – J.M. Kenny Apr 25 '13 at 16:53
  • Restarting tomcat when the servlets are updated has become a pain because there are other modules that are used, but I need to publish frequent updates... – J.M. Kenny Apr 25 '13 at 17:10
  • You could deploy the war "exploded", with the classes folder editable, then when you make a "java" change, you can replace the compiled class and touch web.xml...theoretically. – Sumit Apr 25 '13 at 20:29

2 Answers2

2

With Tomcat, you can use the Parallel Deployment method. You will be able to deploy your new version and keep older one running with every users that has a session on it.

It is really simple when you are using WAR files, I recommend a simple script to delete older versions after couple of days for exemple, just to keep only few running versions.

You can get more informations here : http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Parallel_deployment

Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72
1

Did you have a look at JRebel yet?

Stefan
  • 12,108
  • 5
  • 47
  • 66