Hello, World! Web App
Ten Quick Steps for Deploying a Super Simple JSP Web App (WAR) on JBoss AppServer
Updated for JBoss 5.0.0 on Java 1.6.0
Tutorial
Follow these steps to install JBoss and then create and test a simple web application (WAR). The steps are designed for Windows XP, but you should be able to modify them for other OSes without too much effort.1) Install Java
Obtain Java by clicking the ">> Download" button for Java SE Development Kit (JDK) 6 Update 11 at:http://java.sun.com/javase/downloads/
Run the installer with the default options, which will install Java into "C:\Program Files\Java\jdk1.6.0_11\".
Note: Application servers, like JBoss, require the full JDK (Java Development Kit), which contains the JRE (Java Run-Time Engine) plus a bunch of stuff for developers, such as the "javac" compiler.
2) Install JBoss Application Server
Go to the JBoss download page at:http://www.jboss.org/jbossas/downloads
Locate version 5.0.0.GA, and follow the "Download" link to get the "jboss-5.0.0.GA.zip" file. Unzip the file into "C:\Apps\JBoss\".
3) Create Work Folder
Create a folder called "HelloWorld" separate from your JBoss installation. For example, the full path of your work folder could be "C:\Projects\HelloWorld".4) Create Startup Script
In the "HelloWorld" folder create a file named "JBoss.bat" with the following content:JBoss.bat
@echo off
set JAVA_HOME=\Program Files\Java\jdk1.6.0_11
set JBossHome=\Apps\JBoss\jboss-5.0.0.GA
set Path=%JAVA_HOME%\bin;%Path%
cd "%JBossHome%\bin"
run.bat
set JAVA_HOME=\Program Files\Java\jdk1.6.0_11
set JBossHome=\Apps\JBoss\jboss-5.0.0.GA
set Path=%JAVA_HOME%\bin;%Path%
cd "%JBossHome%\bin"
run.bat
This script will launch JBoss.
5) Launch JBoss
Run the "JBoss.bat" file you just created.6) Write JSP File
Also in the "HelloWorld" folder, create a file named "hi.jsp" as:hi.jsp
<html><head><title>JSP Test</title>
<%!
String msg = "Hello, World.";
%>
</head>
<body>
<h2><%= msg %></h2>
<%= new java.util.Date() %>
</body></html>
<%!
String msg = "Hello, World.";
%>
</head>
<body>
<h2><%= msg %></h2>
<%= new java.util.Date() %>
</body></html>
This JSP simply displays a greeting along with the current date and time.
7) Create Deployment Descriptor
In the "HelloWorld" folder, create a sub folder called "WEB-INF", and in that folder create a file named "web.xml" as:web.xml
<web-app>
<display-name>Hello World</display-name>
</web-app>
<display-name>Hello World</display-name>
</web-app>
The deployment descriptor provides information to JBoss about your web application.
8) Create WAR Builder & Deployer
In the "HelloWorld" folder, create a file called "Deploy.bat" as:Deploy.bat
@echo off
set JAVA_HOME=\Program Files\Java\jdk1.6.0_11
set JBossHome=\Apps\JBoss\jboss-5.0.0.GA
"%JAVA_HOME%\bin\jar.exe" -cvf helloworld.war *.jsp WEB-INF
copy helloworld.war "%JBossHome%\server\default\deploy"
pause
set JAVA_HOME=\Program Files\Java\jdk1.6.0_11
set JBossHome=\Apps\JBoss\jboss-5.0.0.GA
"%JAVA_HOME%\bin\jar.exe" -cvf helloworld.war *.jsp WEB-INF
copy helloworld.war "%JBossHome%\server\default\deploy"
pause
This script uses Java's JAR utility to zip up the appropriate contents into a WAR file.
9) Do It
Run the "Deploy.bat" file.10) Test Your Web Page
In a browser, open "http://localhost:8080/helloworld/hi.jsp" to see your web application run.Now explore the JBoss console at "http://localhost:8080". Click on "JBoss Web Console" and expand "J2EE Domains", "jboss.management.local", and "JBoss". Select "helloworld.war" to see information about your web application.
That's It
For your convenience, here's the completed Hello World! Web Application:HelloWorldWebApp.zip (screen shot)
If you're ready to take the next step to servlets and EJBs, try these tutorials:
Laliluna EJB Tutorial Eclipse EJB Application JBoss EJB Tutorial
If you know of any better EJB tutorials, please send in your suggestions.
'Computer Science' 카테고리의 다른 글
박성규씨의 ATL강좌 (0) | 2009.04.24 |
---|---|
ATL/COM 강좌 (0) | 2009.04.24 |
tomcat 세팅 및 가상 디렉토리 설정 하기 (0) | 2009.04.23 |
ubuntu에서 tomcat설치/apache2에 연동 (0) | 2009.04.23 |
[FTP] Active Mode 와 Passive Mode (0) | 2009.04.23 |