Processing HTML Form Data

The javaxt-server library includes an innovative form processor that makes it easy to upload files and process HTML form data. Here's an example:
package com.example;
import javaxt.http.servlet.*;

public class ServletTest extends HttpServlet {

    public void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {

        System.out.println(request);

      //Instantiate the form iterator and loop through the form inputs
        java.util.Iterator<FormInput> it = request.getFormInputs();
        while (it.hasNext()){
            FormInput input = it.next();
            if (input.isFile()){

              //Save file to a directory
                input.getValue().toFile(new java.io.File("/temp/uploads/" + input.getFileName()));
            }
            else{

              //Simply print the input name/value
                System.out.println(input.getName() + ": " + input.getValue());
            }
        }
    }
    
}