Java Reference
In-Depth Information
Aborts the current HTTP request.
Gets all the response headers.
getResponseHeader(string header)
Gets a specified response header.
open(string method, string url,
boolean asynch, string username,
string password)
Opens a HTTP request. Does not send
a request. Boolean parameter asynch
specifies if HTTP request is asynchronous;
default value is true. Username and
password are optional.
Sends a HTTP request to the server,
including data. The send() method
is synchronous or asynchronous
corresponding to the value of the
asynch argument in the open() method.
If synchronous, the method does not
return until the request is completely
loaded and the entire response has been
received. If asynchronous, method returns
headerName, string headerValue)
Sets HTTP request headers.
In this chapter, we create an EJB 3.0 Ajax application in which an input form is
validated using Ajax and persisted using EJB 3.0. The following procedure is
used for a catalog entry form validation and submission:
1. A user inputs a catalog ID in a catalog entry form.
2. The catalog id value is sent to a servlet doGet method. The servlet looks up
the remote component interface of a session bean and invokes a validate()
method that returns a Catalog entity instance to validate the catalog id.
3. The session bean validate() method runs a Java persistence language query
using the catalog id value. If the query returns an empty list, the validate()
method returns null, else it returns a list with a Catalog entity instance; the
validate() method returns the Catalog entity instance.
4. In the servlet, if the validate() method returns null, the servlet constructs
a String consisting of an XML element <valid>true</valid>, which is
returned to the browser that sent the catalog id value via Ajax.
5. In the catalog entry form, the XML is parsed and if the valid element value
is true, a validation message that the catalog ID specified is valid gets
displayed. A user may continue to fill the form and submit it to create a new
catalog entry.
Search WWH ::

Custom Search