Java Reference
In-Depth Information
try {
pk = request.getParameter("DestroyYacht");
home.remove(pk);
session.removeAttribute(pk); // destroy the associated session
} catch (NumberFormatException e) {
log("Failed to destroy a Yacht.", out);
}
}
else if (request.getParameter("CreateNewYacht") != null) {
String yachtName = request.getParameter("YachtName");
if(yachtName == null) {
yachtName = "DefaulName";
}
String builder = request.getParameter("Builder");
if (builder == null) {
builder = "Unknown";
}
String engineType = request.getParameter("EngineType");
if (engineType == null) {
engineType = "Unknown";
}
int capacity = 0;
int maxVelocity = 0;
try {
capacity = Integer.parseInt(request.getParameter("Capacity"));
} catch (Exception e) {
capacity = 10;
}
try {
maxVelocity = Integer.parseInt(request.getParameter("MaxVelocity"));
} catch (Exception e) {
maxVelocity = 25;
}
// finally create the Yacht
try {
Yacht yacht = (Yacht) home.create(yachtName, builder, engineType,
capacity,
maxVelocity);
} catch (CreateException e) {
log("CreateException caught while trying to create a new yacht." +
e, out);
}
}
Search WWH ::




Custom Search