Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. package com.jwt.struts.action;
  2.  
  3. import com.jwt.struts.dao.UserQueryDAO;
  4. import com.jwt.struts.dao.UserRegisterDAO;
  5. import com.jwt.struts.form.UserQueryForm;
  6. import com.jwt.struts.form.UserRegisterForm;
  7. import com.lowagie.text.Document;
  8. import com.lowagie.text.Element;
  9. import com.lowagie.text.pdf.PdfPTable;
  10. import org.apache.struts.action.Action;
  11. import org.apache.struts.action.ActionForm;
  12. import org.apache.struts.action.ActionForward;
  13. import org.apache.struts.action.ActionMapping;
  14.  
  15. import javax.servlet.http.HttpServletRequest;
  16. import javax.servlet.http.HttpServletResponse;
  17. import javax.servlet.http.HttpSession;
  18. import java.awt.*;
  19. import java.sql.ResultSet;
  20.  
  21. public class GeneratePDFaction {
  22. public ActionForward execute(ActionMapping mapping, ActionForm form,
  23. HttpServletRequest request, HttpServletResponse response)
  24. throws Exception {
  25. HttpSession ses = request.getSession(true);
  26.  
  27. UserQueryForm registerForm = (UserQueryForm) form; ;
  28.  
  29. String userName = registerForm.getUserName();
  30.  
  31. UserRegisterDAO dao = new UserRegisterDAO();
  32.  
  33. ResultSet result = dao.consultarPorUsuario(userName);
  34.  
  35.  
  36.  
  37.  
  38. String firstName = result.getString(0);
  39. String lastName = result.getString(1);
  40. String uName = result.getString(2);
  41. String password = result.getString(3);
  42. String email = result.getString(4);
  43. String phone = result.getString(5);
  44.  
  45. PdfPTable table = new PdfPTable(6);
  46. table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
  47. table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
  48. table.getDefaultCell().setBackgroundColor(Color.lightGray);
  49.  
  50. table.addCell("nombre");
  51. table.addCell("apellidos");
  52. table.addCell("nombre de usuario");
  53. table.addCell("contraseña");
  54. table.addCell("email");
  55. table.addCell("telefono");
  56.  
  57. table.addCell(firstName);
  58. table.addCell(lastName);
  59. table.addCell(uName);
  60. table.addCell(password);
  61. table.addCell(email);
  62. table.addCell(phone);
  63.  
  64. Document document = new Document();
  65.  
  66. document.add(table);
  67.  
  68. return mapping.findForward("success");
  69.  
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement