User Profile Sample

This sample shows you how to capture name and address information from an HTML form and save it in a database.

This sample uses the WebSphere Application Server's UserProfile class.. Before you run this sample, the UserProfile class must be enabled.

Enable the UserProfile class

Run this sample

 


How this sample works:

This sample has:

  • An input form for Web site visitors to enter their data
  • A servlet that stores the data in the database
  • A page that is returned when a user profile is successfully created
  • A page that is returned if this person already has a user profile
  • A servlet file that provides information about the servlet to the WebSphere Application Server

The input form contains data entry fields for four of the variables in the UserProfile class. The userName is the unique identifier for this person and is the only required field on this form. When you fill in the form and click Submit, it invokes the Java servlet.

The servlet checks to see if the userName already exists. If it does, the servlet returns a page asking the user to try another userName. Otherwise, the servlet creates a new instance of the UserProfile in the database for this unique userName, initializes the fields with the data provided, and returns a page that says "Thanks".


How to use this sample on your web page:

You can use this sample to create a customized registration for your Web site.

Copy the sample pages and add your own style, banner, text, and images, change fonts, or change the data entry labels.

Capture other data:

  • Add fields to the input form for any of the variables in the UserProfile class. Remember the userName is required, but you can call it whatever makes sense at your Web site, for example User ID, Nickname or Login
  • For each field on the form, add code to the UserProfileServlet to initialize that field with the value sent in the request

Publish the pages and start registering your visitors.