link to table of contentsgo to previous topicgo to next topiclink to glossaryindex of terms

 

Testing Your Servlet

AppComposer and its included local web server provide several ways to test the servlets and other kinds of capsules that you create. This lesson takes you through some simple testing with the servlet hello.zac. Hello.zac retrieves user input from a form and generates a custom greeting in response to the input. If you do not have this capsule created and saved from the previous lessons, you can use the capsule AppComposer/docs/tutorials/resources/helloUser.zac to begin this lesson.

The goal for this section is to use the debug server's parameters testing function.

To open the capsule in the debug web server:

  1. If you did not create or save the hello.zac capsule from the earlier sections of this tutorial, open AppComposer/docs/manuals/tutorials/resources/helloUser.zac in AppComposer.
  2. Make sure you have set up the debug server.
  3. Open a browser.
    Note: Netscape 4.7 has a bug with respect to some of AppComposer's debugging tools. If you encounter unexpected results, such as the browser displaying the HTML source instead of what the user would see, you may wish to use a different browser to debug your servlets.
  4. Go to the URL http://localhost/, or wherever you defined AppComposer's local server when you configured it.
    The debug server page appears, with a link to the hello.zac servlet.

If you click on the link to the servlet, the browser shows you an empty page. This is because the servlet responds to input from a form. Since the form is not built yet, there is no input for the servlet to respond to. This is why the debug server page provides the button. You can use it to feed parameters into your servlet to test that it processes them correctly.

To pass parameters to your servlet:

  1. Click the Parameters button.
    The Parameters page for hello.zac appears.

    You may have a longer list of parameter fields, depending on how you configured the debug server.
    Notice how username is already filled in for you as the first parameter. AppComposer gives you this easy way to check that all your parameters are defined in the capsule properties. If you had not defined username as a capsule parameter, you could still type it into the list and test it here.
  2. In the empty field next to username, enter a sample name. Use your own name, or any name you choose.
  3. Click Post.
    You may have to scroll to the bottom of the page to see the Post button.
  4. See the result.

If everything has gone as planned, you should see your customized Hello message. This is the simplest way in AppComposer to test that your servlets function correctly, without needing to complete the other parts of the web application to which they belong.

When servlets are more complex than this simple example, you need to test and debug your servlet capsules on a more detailed level than just passing parameters and looking at the result. AppComposer provides several tools to help you with line-by-line debugging.

In the next section you will learn how to manage multiple files in a project window and how to use a servlet capsule in conjunction with a JSP file.

 



link to table of contentsgo to previous topicgo to next topiclink to glossaryindex of terms
      © 2003 DigiSlice Corporation