{"id":894,"date":"2015-01-29T03:51:03","date_gmt":"2015-01-29T03:51:03","guid":{"rendered":"http:\/\/mooredynasty.net\/?p=894"},"modified":"2015-01-29T03:51:03","modified_gmt":"2015-01-29T03:51:03","slug":"java-server-pages-app-in-tomcat","status":"publish","type":"post","link":"https:\/\/mooredynasty.net\/index.php\/2015\/01\/java-server-pages-app-in-tomcat\/","title":{"rendered":"Java Server Pages App in Tomcat"},"content":{"rendered":"<p>Getting ramped back up on Java is fun!&#160; With Hello World running at the command prompt, it\u2019s time for a web version.<\/p>\n<p>I\u2019d previously installed Tomcat 8 and verified it was functioning with a couple of the sample apps <a href=\"http:\/\/www.ntu.edu.sg\/home\/ehchua\/programming\/howto\/Tomcat_HowTo.html\">with the help of this tutorial<\/a>.<\/p>\n<p>To start the web app, I used <a href=\"http:\/\/www.mkyong.com\/maven\/how-to-create-a-web-application-project-with-maven\/\">this tutorial about creating a web application using Maven<\/a>.<\/p>\n<p><strong>Creation<\/strong><\/p>\n<p>First, Maven\u2019s code generator started things off again.&#160; Instead of using the <em>quickstart<\/em> template, I used the <em>webapp<\/em> archetype:<\/p>\n<blockquote>\n<p>mvn archetype:generate -DgroupId=edu.gatech.ateam.helloweb -DartifactId=helloweb -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false      <\/p>\n<\/blockquote>\n<p><strong>Packaging<\/strong><\/p>\n<p>Next I created the WAR file:<\/p>\n<blockquote>\n<p>mvn package<\/p>\n<\/blockquote>\n<p>This created a <em>helloweb.war <\/em>in the <em>project\/target<\/em> folder<em>.<\/em>&#160; Note the friendly WAR file name, unlike the package name given to the Hello World JAR quickstart project.<\/p>\n<p><strong>Deployment<\/strong><\/p>\n<p>The last step was to deploy the WAR file to Tomcat, which was nothing more than copying it from the <em>target<\/em> folder to the Tomcat <em>webapps <\/em>folder, which for me was <\/p>\n<blockquote>\n<p>C:\\apache\\apache-tomcat-8.0.17\\webapps <\/p>\n<\/blockquote>\n<p>Then I fired up Tomcat by running the script:<\/p>\n<blockquote>\n<p>C:\\apache\\apache-tomcat-8.0.17\\bin\\startup.bat<\/p>\n<\/blockquote>\n<p><strong>NOTE:&#160; <\/strong><a href=\"http:\/\/stackoverflow.com\/questions\/9951763\/deploy-a-war-to-tomcat?rq=1\">Tomcat does not always like to auto-deploy WAR files and some cleanup is helpful<\/a>.&#160; One thing I do recall from my previous go-around with JSP was that it was better to religiously shutdown the server, clean the folders, and re-deploy than to try to save time by skipping these steps.&#160; This was common advice in many posts.<\/p>\n<p><strong>Execution<\/strong><\/p>\n<p>I\u2019d originally set up Tomcat to listen on port 9999, per the Tomcat setup tutorial \u2013 your mileage may vary.<\/p>\n<p>Pointing Chrome to the site <a href=\"http:\/\/localhost:9999\/helloweb\">http:\/\/localhost:9999\/helloweb<\/a> produced the following:<\/p>\n<blockquote>\n<h4>&#160;<\/h4>\n<h4>Hello World!<\/h4>\n<h4>&#160;<\/h4>\n<\/blockquote>\n<p><strong>Conclusion<\/strong><\/p>\n<p>Much easier than I\u2019d dared to hope!<\/p>\n<p>Next step is to implement a Java Servlet and perfect the art of deployment again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting ramped back up on Java is fun!&#160; With Hello World running at the command prompt, it\u2019s time for a web version. I\u2019d previously installed Tomcat 8 and verified it was functioning with a couple of the sample apps with the help of this tutorial. To start the web app, &hellip; <\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-894","post","type-post","status-publish","format-standard","hentry","category-development"],"_links":{"self":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts\/894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/comments?post=894"}],"version-history":[{"count":1,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts\/894\/revisions"}],"predecessor-version":[{"id":895,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/posts\/894\/revisions\/895"}],"wp:attachment":[{"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/media?parent=894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/categories?post=894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mooredynasty.net\/index.php\/wp-json\/wp\/v2\/tags?post=894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}