JBoss.comEnterprise Documentation

Chapter 4. Developing a simple JSP web application

4.1. Setting Up the Project
4.2. Creating JSP Page
4.2.1. Editing a JSP Page
4.2.2. web.xml file
4.2.3. Deploying the project
4.2.4. JSP Page Preview
4.2.5. Launch JSP Project

Note:

We highly recommend developing in Seam. This chapter is for users who for some reason cannot use Seam.

In this chapter you'll find out how to create a simple JSP application using the JBoss Developer Studio. The application will show a classic "Hello World!" on the page.

We'll assume that you have already launched JBoss Developer Studio and also that the Web Development perspective is the current perspective. If not, make it active by selecting Window > Open Perspective > Web Development from the menu bar or by selecting Window > Open Perspective > Other... from the menu bar and then selecting Web Development from the Select Perspective dialog box.

We are going to start with the creating a Dynamic Web Project with a minimal structure, i.e. with just required facets. Thus this section will perform you all necessary steps on how to do this.


The jspHello node should appear in the upper-left Package Explorer view.


This section covers all the points how to create, edit and then preview JSP page.

In our simple application we need to create only one JSP page which displays a "Hello World!" message.

In the next window you can choose a template for your jsp page and see its preview.


Our hello.jsp page will now appear in Project Explorer.

While creating any web project you could experience a pain writing ant scripts and managing the packaging even when writing the most trivial web applications. With JBoss Developer Studio you are saved from such a pain. All you need is to start JBoss Server and launch your application in your favorite browser.

You can also create a war archive with JBDS's Archive Tools and export it to any web server.

JBDS comes with JSP design-time preview features. When designing JSP pages you can easily preview how they will look during runtime. You can even attach your stylesheet to the Preview.

  • Make a little change to hello.jsp page, e.g. put this code snippet:


<%= new java.util.Date() %>
  • Click Save button.

  • Switch to Preview page by clicking Preview tab at the bottom of the page. You will see how the page will look at runtime.