Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.jwt.struts.action;
- import com.jwt.struts.dao.UserQueryDAO;
- import com.jwt.struts.dao.UserRegisterDAO;
- import com.jwt.struts.form.UserQueryForm;
- import com.jwt.struts.form.UserRegisterForm;
- import com.lowagie.text.Document;
- import com.lowagie.text.Element;
- import com.lowagie.text.pdf.PdfPTable;
- import org.apache.struts.action.Action;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import java.awt.*;
- import java.sql.ResultSet;
- public class GeneratePDFaction {
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
- HttpSession ses = request.getSession(true);
- UserQueryForm registerForm = (UserQueryForm) form; ;
- String userName = registerForm.getUserName();
- UserRegisterDAO dao = new UserRegisterDAO();
- ResultSet result = dao.consultarPorUsuario(userName);
- String firstName = result.getString(0);
- String lastName = result.getString(1);
- String uName = result.getString(2);
- String password = result.getString(3);
- String email = result.getString(4);
- String phone = result.getString(5);
- PdfPTable table = new PdfPTable(6);
- table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
- table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
- table.getDefaultCell().setBackgroundColor(Color.lightGray);
- table.addCell("nombre");
- table.addCell("apellidos");
- table.addCell("nombre de usuario");
- table.addCell("contraseña");
- table.addCell("email");
- table.addCell("telefono");
- table.addCell(firstName);
- table.addCell(lastName);
- table.addCell(uName);
- table.addCell(password);
- table.addCell(email);
- table.addCell(phone);
- Document document = new Document();
- document.add(table);
- return mapping.findForward("success");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement