Java Reference
In-Depth Information
}
}
} catch (Exception ex) {
//do something
}
}
}
Completing the Application
There are just a few more steps to finish before you can test this example. First, you
need to adjust the index.html file that was created with your App Engine project.
You're going to add a basic HTML form to POST your uploaded image to the
ImageTransform servlet you created. Copy the code from Listing 8-10 to war/
WEB-INF/index.html . Paste the code block just before the closing BODY tag.
Listing 8-10. war/WEB-INF/index.html
<form action="ImageTransform" method="POST" enctype="multipart/form-data">
<div id="status" style="text-align:center;color:red"></div>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please select your file
to upload:</td>
</tr>
<tr>
<td>File:</td>
<td><input type="file" name="fileObj"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit"/>
</td>
</tr>
</table>
</form>
Finally, you need to map your new servlet so App Engine knows where to send your
POST request. Open the web.xml file in the war/WEB-INF/lib directory of the App
Engine project and add the code from Listing 8-11. The XML elements in Listing 8-11
map the ImageTransform and ImageSource servlets to their respective URL patterns.
 
Search WWH ::




Custom Search