Monday, January 17, 2011

Eclipse and Netbeans Agile JSP Development

I have used rsync, maven and shell/ant scripts to deploy JSP files into the tomcat exploded application folder but if you are using Eclipse then you cannot miss the filesync plugin.

This is simply JSP development/deployment done the right way.

On one side you can hot deploy your JSPs to any application server supporting exploded deployment (who doesn't nowadays) and at the same time you just save the file in Eclipse and your changes are pushed into the server.

This is perfect for Servlet development, however for Liferay Portlet development for example it won't work as Liferay uses specific folders to store the JSPs with the application server. A similar plugin but running some kind of custom action "on save" could resolve that problem but Liferay has tools of its own nowadays to deal with hot deployment.

Netbeans currently does not have a plugin like Eclipse filesync, however "JSP deployment on save" is accomplished out of the box in a per supported server scenario. Let us see how you configure it for tomcat 6:
  1. Add a user and role for Tomcat Manager:
    $ vi conf/tomcat-users.xml
    <role rolename="manager"/>
    <user username="tomcat" password="tomcat" roles="manager"/>
  2. In Netbeans go to Services | Servers | Add Server | point to the tomcat root directory and supply tomcat/tomcat for username/password
  3. Right click on the Tomcat 6 Server entry and select Run. If the server was not running Netbeans will start it
  4. Any JSP changes will be deployed in the server. To see how to hot deploy java code without restarting the server refer to my previous post

No comments: