Friday, 27 September 2013

A HelloWorld Servlet in JBoss EAP 6 using Eclipse


To show a simple JEE6 HelloWorld Servlet development


  • Eclipse Juno
  • JBoss EAP 6.0 Application Server
  • Java 7


1.       Start Eclipse.
2.       Configuring Server
a.       (Go to Menu Window -> Preferences)
b.      Select button Add, this will open a new window
c.       Select Server “JBoss Enterprise Application Platform 6.0 Runtime”. 
In case the server is not listed please download the one via selecting “Download additional server adapters” link shown on top right corner.
d.      Specify correct path for JBoss EAP 6.0 and right JRE
e.      Click on button “Finish” and then “OK” on previous window.
f.        Open Servers view (Window -> Show View -> Servers)
g.       On Servers view click on “new server wizard...” link
h.      A “New Server” window will open
Ensure the “JBoss EAP 6.0 Runtime” Server runtime environment is selected and click on Finish.
i.         Specify correct path for JBoss EAP 6.0 and right JRE

3.       Create a Dynamic Web Project (File -> New -> Dynamic Web Project)
4.       Give project name as “HelloWorldServlet”
Click on Finish.
5.       You should see the project “HelloWorldServlet” created. Now right click on project and click New -> Servlet.
6.       Specify Servlet name as “HelloWorldServlet” and package as “com.test”
Click on Finish.
7.       Make following changes on doGet() and doPost() method as:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   PrintWriter out = response.getWriter();
   out.print("<html><body><b>Respons from HelloWorld Servlet</b></body></html>");
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              doGet(request, response);
8.       Right click on project and select “Run As” -> “Run on Server”
Click on Finish.
9.       You should see “Console” view showing server startup logs. Once server is started successfully a browser window will open with URL http://localhost:8080/HelloWorldServlet


1.       You must hit the URL http://localhost:8080/HelloWorldServlet/HelloWorldServlet either in Eclipse Web Browser window or any other Web Browser you have.
2.       Once hit the browser must show message “Respons from HelloWorld Servlet
Congratulations this completes your HelloWorldServlet which is a Servlet 3.0 Spec compliant running in JBoss EAP 6.0.