I'm working on a port of an existing Java app to Salesforce.com and I ran into a Visualforce page that gave me some problems. The current JSP page allows the user to fill out a form, submit a new record to the database and then pop-up a new window to show some results while keeping the users on the same page with the form.
Here's something similar to what I came up with. You can run this example on my developer site.
The Controller exposes a public 'message' attribute that is used by the Visualforce page to display the results of the submission. The save() method inserts the record and set the value of the 'message' attribute if no error. If an error occurred, it set the error message to the 'message' attribute instead.