// Step 2: Create PrerendererPackageContext initialized with the
// list of remote page URIs. The PrerendererPackageContext throws
// IllegalArgumentException in case any of the URIs in not valid. In
// case of error, send HTTP 400 error with exception message.
PrerendererPackageContext prerendererPackageContext = createPrerendererPackageContext(
request, pageURIs, baseURI, prefixPathURI);
// Step 3: Get the list of rewritten page URIs.
List rewrittenPageURIs = prerendererPackageContext.getRewrittenPageURIs();
// Step 4: Prepare the XML response.
Document outputDocument = new Document();
Element outputPagesElement = new Element("pages");