beautypg.com

Modifying the empinfo-servlet.xml file, Modifying the, Empinfo-servlet.xml – HP Integrity NonStop H-Series User Manual

Page 136: File

background image

SQLException {

WebApplicationContext wac = WebApplicationContextUtils.
getRequiredWebApplicationContext(getServletContext ());

empdao = (EmployeeDao) wac.getBean("empdao");
int empid = ((Employee) command).getEmpid();
String firstname = ((Employee) command).getFirstname();
String lastname = ((Employee) command).getLastname();
int age = ((Employee) command).getAge();
String email = ((Employee) command).getEmail();

String rord = ((Employee) command).getRord();

if (rord!=null && rord.equalsIgnoreCase("Retrieve")) {

Employee emp1 = empdao.getDetail(empid);

Map model = new HashMap();
model.put("empid", "" + emp1.getEmpid());
model.put("empfn", emp1.getFirstname());
model.put("empln", emp1.getLastname());
model.put("empage", "" + emp1.getAge());
model.put("empemail", emp1.getEmail());

return new ModelAndView("retrieveresult", "model", model);

}

if (rord!=null && rord.equalsIgnoreCase("Delete")) {

String str = empdao.deleteEmployee(empid);

Map model = new HashMap();
model.put("del", str);
return new ModelAndView("deleteresult", "model", model);

}

else {
empdao.insertDetail(empid, firstname, lastname, age, email);

Map model = new HashMap();
model
.put("add",
"Transaction Complete - One Employee Added to Employee Database");
return new ModelAndView("insertresult", "model", model);

}

}
}

Modifying the

EmpInfo-servlet.xml

File

Modify the

EmpInfo-servlet.xml

file in the

EmpInfo/WebContent/WEB-INF

directory to

map the command name and its corresponding command class for

retrieveordelete.jsp

.

NOTE:

By default, XML files open in the XML Editor. The XML Editor has two views: Design

and Source view. Select the Source view.

After modification, the

EmpInfo-servlet.xml

file appears as:


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

136

Getting Started with Spring

This manual is related to the following products: