Can I use VAJ version 2.0 to develop servlets and test or debug it without starting web server? Is there any third party provide tools that do this and can be integrated into VAJ?

Oliver Springauf

I did this quite a lot. Sun's Servlet DevKit (JSDK) includes a web server (sun.servlet.http.HttpServer) that you can use. In practice, give your servlet class a main method like

import java.lang.reflect.Method;


public static void main(java.lang.String[] args) {
  String sMyURL = 

  // this variable must be set by you
  String sMyBrowser = 

  try {
    boolean success = false;
    // Throw an exception if we are not in the VisualAge IDE
    Runtime.getRuntime().exec(sMyBrowser + " " + sMyURL);
    Class serverStarterClass = 
    Method method = 
                                     new Class[] {String[].class});
                  new Object[] {new String[] {"-p", "8080"}});
  catch (Throwable e) {

You can then start your servlet by executing its main(), which starts the web server and your browser. The JSDK server is only for testing, it lacks most features of other servlet engines (like aliases, url rewriting, ...) There are two minor inconveniences with this method: you have to find your own way to configure your servlet, and earlier versions of the JSDK server did not serve files (only servlets). I could imagine that it's also possible to integrate other servlet engines (like Apache's) into VAJ.

About | Sitemap | Contact