nome; } public void setNome(String nome) { this.nome = nome; } public String getTelefone() { return telefone; } public void setTelefone(String telefone) { this.telefone = telefone; }}2) Criando uma interface DAOFigura 20 - Interface DAOCODEpackage com.myapp.dao;import com.myapp.model.Contato;import java.util.List;public interface ContatoDao { public void create(Contato contato); public List<Contato> findAll();}3) Criando uma classe que implemente a interface DAOFigura 21- Criando a implementacao da interfaceFigura 22 - nome da Classe de implementacaoCODEpackage com.myapp.dao;import com.myapp.model.Contato;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;import java.util.logging.Level;import java.util.logging.Logger;public class ContatoDaoImpl implements ContatoDao { static { try { Class.forName("com.mysql.jdbc.Driver"); } catch (Exception ex) { Logger.getLogger(ContatoDaoImpl.class.getName()).log(Level.SEVERE, null, ex); throw new ExceptionInInitializerError(ex); } } private Connection getConnection() throws SQLException { return DriverManager.getConnection("jdbc:mysql://ns1/springlessons", "springlessons", "DHADdSXcDF29WGXy"); } @Override public void create(Contato contato) { Connection Con = null; PreparedStatement pstm = null; try { Con = getConnection(); String sql = "INSERT INTO `springlessons`.`contato`" + "(`nome`,`telefone`)" + " VALUES (?,?)"; pstm = Con.prepareStatement(sql); pstm.setString(1, contato.getNome()); pstm.setString(2, contato.getTelefone()); pstm.executeUpdate(); } catch (Exception e) { throw new RuntimeException(e); } finally { try { pstm.close(); } catch (Exception e) { Logger.getLogger(ContatoDaoImpl.class.getName()).log(Level.SEVERE, null, e); } try { Con.close(); } catch (Exception e) { Logger.getLogger(ContatoDaoImpl.class.getName()).log(Level.SEVERE, null, e); } } } @Override public List<Contato> findAll() { Connection Con = null; PreparedStatement pstm = null; ResultSet rs = null; try { Con = getConnection(); String sql = "SELECT `contato`.`id`,`contato`.`nome`,`contato`.`telefone`" + " FROM `springlessons`.`contato`"; pstm = Con.prepareStatement(sql); List<Contato> contatos = new ArrayList<Contato>(); rs = pstm.executeQuery(sql); while (rs.next()) { Contato contato = new Contato(); contato.setId(rs.getInt("id")); contato.setNome(rs.getString("nome")); contato.setTelefone(rs.getString("telefone")); contatos.add(contato); } return contatos; } catch (Exception e) { throw new RuntimeException(e); } finally { try { pstm.close(); } catch (Exception e) { Logger.getLogger(ContatoDaoImpl.class.getName()).log(Level.SEVERE, null, e); } try { Con.close(); } catch (Exception e) { Logger.getLogger(ContatoDaoImpl.class.getName()).log(Level.SEVERE, null, e); } } }}4) Criando uma interface de ServicoFigura 23 - criando a interface de ServicoCODEpackage com.myapp.service;import com.myapp.model.Contato;import java.util.List;public interface ContatoService { public void create(Contato contato); public List<Contato> findAll();}5) Criando uma classe que implemente a interface de ServicoFigura 24 - Implemente a interfaceFigura 25 - nome da implementacaoCODEpackage com.myapp.service;import com.myapp.dao.ContatoDao;import com.myapp.dao.ContatoDaoImpl;import com.myapp.model.Contato;import java.util.List;public class ContatoServiceImpl implements ContatoService { private ContatoDao dao = new ContatoDaoImpl(); @Override public void create(Contato contato) { dao.create(contato); } @Override public List<Contato> findAll() { return dao.findAll(); } }6) Criando as classes p/ atender os actions que serao mapeados no arquivo struts-config.xml, que extendem a classe org.apache.struts.action.Action, dentro de um novo package ...action- CreateContatoAction.java- ContatoForm.java- RedirectContatoAction.javaI) CreateContatoAction.javaFigura 26 - Criando a ActionCODEpackage com.myapp.action;import com.myapp.model.Contato;import com.myapp.service.ContatoService;import com.myapp.service.ContatoServiceImpl;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.commons.beanutils.BeanUtils;import org.apache.struts.action.Action;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;public class CreateContatoAction extends Action { private ContatoService userService = new ContatoServiceImpl(); public void setContatoService(ContatoService userService) { this.userService = userService; } @Override public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {// return super.execute(mapping, form, request, response); ContatoForm contatoForm = (ContatoForm) form; Contato contato = new Contato(); BeanUtils.copyProperties(contato, contatoForm); userService.create(contato); return mapping.findForward("list"); }}II) ContatoForm.javaFigura 27 - mande o NB criar essa classe no package actionCODEpackage com.myapp.action;import org.apache.struts.action.ActionForm;public class ContatoForm extends ActionForm { private String nome; private String telefone; public ContatoForm() { } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } public String getTelefone() { return telefone;