显示标签为“web application development”的博文。显示所有博文
显示标签为“web application development”的博文。显示所有博文

2015年6月28日星期日

[方法整理] 关于用Java8开发的webapp在EC2 instance上部署的问题

过程基本上与之前写过的Deploy war file on EC2 instance相同,但是java的版本不一样,所以需要如下操作:

(1)将EC2上默认安装的Java7升级到Java8
(reference:http://serverfault.com/questions/664643/how-can-i-upgrade-to-java-1-8-on-an-amazon-linux-server):
sudo yum remove java-1.7.0-openjdk
sudo yum install java-1.8.0

(2)安装tomcat8:
(reference:http://stackoverflow.com/questions/26637550/how-to-install-tomcat-8-in-amazon-webservices-ec2
yum install tomcat8-webapps tomcat8-admin-webapps

脑洞:关于EC2的security group的设定,今天又犯迷糊了,应该是这样的:


2015年5月9日星期六

[方法整理]Create a simple war file

Create a simple war file

(source: http://oak.cs.ucla.edu/cs144/projects/tomcat/)

Now that we understand the basic structure of a WAR file, we will be creating a very simple WAR file, called simple.war, that just contains a static "hello, world" type HTML page and the basic web.xml file. Here is a step-by-step instruction on how you can create a .war file:

Create a temporary folder to place all files that should go into the .war file. Make it as your current directory by "cd" into the directory.
Create a file named hello.html in your temporary directory with the following content.
<html>
    <head><title>Hello World</title></head>
    <body><h1>Hello World</h1></body>
</html>

Create a WEB-INF folder and create the deployment descriptor file web.xml in it with the following content.
<web-app id="simple" version="2.4">
    <welcome-file-list>
        <welcome-file>hello.html</welcome-file>
    </welcome-file-list>
</web-app>

This descriptor file will make the hello.html page as the "default page" that your application returns.Since you are not including any servlet classes in the WAR file yet, you can skip steps 4 and 5 below and move directly to step 6.
Build your servlet classes. Create a WEB-INF/classes folder and copy your servlet classes into it.
Create a WEB-INF/lib folder and place all JAR library files that your servlet code depends on. After these steps, the layout of your temporary folder may look like the following, for example:
simple_temp
 |
 +- hello.html
 |
 +- WEB-INF
     +- web.xml
     |
     +- lib
     |   +- core-library.jar
     |
     +- classes
         +- edu
             +- ucla
                 +- hello.class

At the root of your temporary folder, use the jar command to create your WAR file. For example:
jar cfM simple.war *

Follow the above instructions to build your "hello, world" page and web.xml as simple.war file and deploy it by placing the war file into the $CATALINA_BASE/webapps directory of your Tomcat server. Once deployed, point your browser to http://localhost:1448/simple. You should see the "Hello World" HTML page you specified as the welcome-file.