NetBurner 3.5.6
PDF Version
HTML Form Post 2.X Compatible

NetBurner HTML Form POST Example

Overview

This application demonstrates HTML Form POST handling on NetBurner embedded devices using the NetBurner Development Kit (NNDK). It provides backward compatibility with NNDK 2.x POST handling methodology while running on NNDK 3.x platforms.

The standard HTTP POST methodology in 3.x should be used whenever creating a new project. The 3.X methods enable cleaner code, less URL parsing, and better performance.

For customers migrating large and complex applications from legacy NNDK 2.X tools and platforms to NNDK 3.X, it is possible to create a HTTP POST callback function that in turn calls a MyDoPost() style 2.X function. This example assumes familiarity with the NNDK 3.X HTTP POST methods.

  • A NNDK 3.X HTTP POST callback function is declared with a wildcard mask ("*") so that it is called for all HTTP POST operations.
  • Strings are created for the URL containing the form action name and the posted form data
  • The 2.X style MyDoPost() function is called with the URL and data strings
  • The ExtractPostData() function is copied from the 2.X tools an included as a function in the application

Once the example has been loaded, interaction is through the device's web page. There are two web pages with forms for data entry, and a summary page at the end to display the assigned values from the post. Status messages are displayed on the serial port that can be viewed with a serial terminal, such as the MTTTY utility.

While every attempt has been made to ensure compatibility, every application must be tested to verify proper operation. Also, this example will not work with multi-part forms.

Purpose

The application illustrates how to:

  • Process HTML POST requests from web browsers
  • Handle multiple web forms with different data fields
  • Extract and parse form data from HTTP POST requests
  • Provide web page responses and redirects
  • Maintain compatibility between NNDK 2.x and 3.x POST handling methods

Key Features

  • Dual POST Handling: Implements both legacy 2.x style MyDoPost() function and modern 3.x callback mechanisms
  • Multiple Form Support: Handles two separate HTML forms with different data fields
  • Data Extraction: Includes URL decoding for form data (handles spaces, special characters)
  • Web Page Flow: Demonstrates proper HTTP response handling with redirects
  • Debug Output: Provides serial console output for monitoring POST operations

Application Structure

Main Components

  1. main.cpp: Application entry point and initialization
  2. web.cpp: Web server POST handling and form processing logic

Form Processing

The application processes two types of forms:

Form 1 (/form1)**:

  • formValue1: First text input
  • formValue2: Second text input
  • formValue3: Third text input
  • Redirects to page2.htm after processing

    Form 2 (/form2)**:

  • textForm2: Single text input
  • Redirects to complete.htm after processing

Technical Details

POST Data Processing

The ExtractPostData() function handles:

  • URL-encoded data parsing
  • Special character decoding (XX hex codes)
  • Space character handling (+ to space conversion)
  • Parameter separation (& delimited)

Compatibility Layer

The application provides a bridge between NNDK versions:

  • 3.x Callback: form1PostCallBack() handles modern POST events
  • 2.x Function: MyDoPost() maintains legacy function signature
  • Event Processing: Converts 3.x events to 2.x compatible data structures

Setup and Configuration

Network Configuration

  • Uses DHCP for automatic IP address assignment
  • Waits up to 5 seconds for network connectivity
  • Default web page: index.htm

Build Requirements

  • NetBurner Development Kit (NNDK) 3.x
  • Compatible NetBurner hardware platform
  • Web server files (HTML forms)

Usage

  1. Compile and Load: Build the application and load it onto your NetBurner device
  2. Network Connection: Ensure the device obtains a network connection via DHCP
  3. Web Interface: Access the device's IP address through a web browser
  4. Form Interaction:
    • Fill out Form 1 on the main page
    • Submit to process and redirect to page 2
    • Fill out Form 2 and submit
    • View results on the completion page

Serial Console Output

The application provides detailed debugging information via serial console:

Application: HTML Form Post Example 2.x Port
NNDK Revision: [version]
----- Processing Post -----
Post URL: /form1
Post Data: formValue1=test&formValue2=data&formValue3=example

Migration Notes

For 2.x to 3.x Migration

This example is specifically designed for customers migrating complex applications from NNDK 2.x to 3.x:

  • Minimal Code Changes: Existing MyDoPost() functions can be reused
  • Gradual Migration: Allows incremental updates to newer POST handling methods
  • Testing Framework: Provides compatibility verification for existing applications

Limitations

  • Multi-part Forms: This compatibility layer does not support multi-part form uploads
  • Performance: 3.x native methods provide better performance for new applications
  • Maintenance: New projects should use standard 3.x POST methodology

Web Page Requirements

The application expects the following web pages:

  • index.htm: Main page with Form 1
  • page2.htm: Second page with Form 2
  • complete.htm: Results/completion page

Each form should use appropriate action attributes (form1, form2) and matching input field names.

Development Recommendations

For New Projects

Use the standard NNDK 3.x HTTP POST methodology for:

  • Cleaner code structure
  • Better performance
  • Reduced URL parsing overhead
  • Enhanced functionality

For Legacy Migration

This example provides a proven path for:

  • Large application migrations
  • Complex form processing systems
  • Gradual modernization of existing codebases