Border Border
Java JBoss

Hello, World! Web App

Ten Quick Steps for Deploying a Super Simple JSP Web App (WAR) on JBoss AppServer


Updated for JBoss 5.1.0 on Java 6

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 JDK" button for JDK 6 Update 18 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_18\".
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.1.0.GA, and follow the "Download" link to get the "jboss-5.1.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.cmd" with the following content:
JBoss.cmd
@echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_18
set JBossHome=C:\Apps\JBoss\jboss-5.1.0.GA

set Path=%JAVA_HOME%\bin;%Path%
cd %JBossHome%\bin
run.bat

This script will launch JBoss.  If you get a "Windows Security Alert" message about running Java, click the "Unblock" button.

5) Launch JBoss

Run the "JBoss.cmd" 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 message = "Hello, World.";
%>
</head>
<body>
<h2><%= message%></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>

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.cmd" as:
Deploy.cmd
@echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_18
set JBossHome=C:\Apps\JBoss\jboss-5.1.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.cmd" 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.

Questions or Comments:

Send Us a Message

Message:
Name:
E-Mail:

Powered by PERFECT

All the fields are optional.  However, if you want a response, make sure to provide your e-mail address.

Random

"Muchas Gracias"
J.C., June 28, 2009

"Very usefull for the beginners."
R.R., June 22, 2009

"Very very usefull documentation for fresher, and it helped me a lot"
R., June 19, 2009

"Great tutorial"
H.M.R., June 9, 2009

"Superb simple steps Jboss sample, thanks!"
J., June 2, 2009

"Excellent Tutorial.  Simply superb.  I was struggling to do this earlier.  Now I can comfortably deploy applications to jboss.  Thanks a lot."
N.R., April 27, 2009

"You Rock !!!!!!!!!! Very good in layman terms .........."
U.M., March 19, 2009

"Works in first attempt..  Great one!!!"
B., March 19, 2009

"Thanks a lot - worked the first time!"
T., March 12, 2009

"This really cut to the chase, the definition of K.I.S.S! for the newbie, just what I needed, thanks!"
J.C., March 9, 2009

"this was really helpful....  I was looking forward to start from a scratch and I succeeded in it...  thanks a ton...."
R., February 10, 2009

"So simple even I could do it!"
S., January 26, 2009

"A huge motivational startup for beginners of java, jboss.."
S., December 18, 2008

"very nice tutorial.  I was able to run jsp within two mins.  Thanks a lot"
G.P., November 20, 2008

"It is a good tutorial.  I changed few things in this tutorial to display hello world in Fedora core 6, but with out this tutorial it would be of mess."
N.M., November 17, 2008

"Very good for the beginners.  It's like spoon feeding."
P., October 1, 2008

"very good step by step appraoch.  make things easy to follow and implement."
I., September 21, 2008

"Simply the best JBOSS JSP example: it works!!"
L.D., September 21, 2008

"Fantastic, a little time spent.  A lot learned."
J.H., September 9, 2008

"3 minutes until I had my system "verified" with this hello world on a Linux-box.  Cool, Thanks from Zurich !"
F.P.R., August 5, 2008

"You showed me the path and I made my first painless step with JBoss.  Thank you Master.  Seriously:I wish there were more simple tutorials like this.  Great job!"
R., August 1, 2008

"Quick and simple.  I enjoyed it.  Thx."
S.L., July 31, 2008

"The best tutorial for starters...short and yet powerful, covering all necessary concepts."
D., July 27, 2008

"Thanks for nice tutorial.  It took me just a few minutes."
Z., July 16, 2008

"Thank you very much for this tutorial.  The best part is that its so simple and just works!!!"
J.R., July 13, 2008

"Simple to-the-point intro to JBoss web application."
L.C., June 29, 2008

More...

Border Border