Rapid web development

I am experimenting with the following technique to speed up web application development with Java. First, define an interface called Controller with a single method called handleRequest that takes an HttpServletRequest and an HttpServletResponse as arguments. The method should also throw an Exception.

Then, create a hierarchy of JSP files and folders based on user stories. For example, say, we are writing a page to allow users to register new accounts. We’ll create the following files. In the /user/register folder:

  • index.jsp This is the entry point for our controller.
  • default.jsp This is the view that is shown by default.
  • success.jsp This is the view that is displayed when user registration is successful.

Now, in index.jsp, write the following:

Next, create the default.jsp and success.jsp pages. For example, default.jsp looks like this.

I am not sure how viable this is as as way to speed up web application development, but the following benefits are already obvious.

  • index.jsp serves as the controller.
  • There is no need to re-compile after adding controllers since JSP pages are compiled automatically, thus speeding up code-test cycle.
  • There is no need for servlet mappings. The folder structure and the designation of index.jsp as a welcome file take care of that.
  • URLs are clean and clear.

There are certainly weaknesses in using this scheme, but as I wrote at the beginning, I am still experimenting with this.

Using Apache Axis in NetBeans 5.0

Introduction

I did not want to have to install Sun Java Application Server on my computer just to use web services. So, I looked around on the Internet and, from the information I gathered here and there, managed to put together this short tutorial on how to set up NetBeans projects to use Axis for web services.

Server-side

  1. Create a new web application project called AxisTest.
  2. Register the Axis JARs as a required library for the project.
  3. Add the following to web.xml.
  4. Write the service class.

  5. Create <service name>.deploy.wsdd</service> and <service name>.undeploy.wsdd</service> files in /WEB-INF/.

    WSStuff.deploy.wsdd


    WSStuff.undeploy.wsdd


  6. Customise and add the following to build.xml.
  7. Build and deploy project.

Client-side

The service should now be available from http://localhost:8088/AxisTest/services.

  1. Create a new project.
  2. Register the Axis JARs as required library for the project.
  3. Customise and add the following to build.xml.
  4. Write client code.

Technorati Tags: ,