
in struts how to display the values in pdf format when clicking a button in jsp page

jsp code using itext api:
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%@page import="com.lowagie.text.*"%>
<%@page import=" com.lowagie.text.pdf.*"%>
<%
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("C:/data.pdf"));
document.open();
PdfPTable table=new PdfPTable(2);
table.addCell("Name");
table.addCell("Address");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from data");
while(rs.next()){
table.addCell(rs.getString("name"));
table.addCell(rs.getString("address"));
}
document.add(table);
document.close();
%>