I would like to generate the resume to PDF. Firstly, the resume will be viewed by getting the id of the user. The next step is to generate the resume to PDF.
Below is the codes of servlet and SQLCommands.java. What should I do?
Servlet
package com.dls.csb.process.web.controller;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Blob;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dls.csb.utility.SQLOperations;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
@WebServlet("/generateresume.html")
public class GenerateResume extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int id = Integer.parseInt(request.getParameter("id"));
Document dc = new Document();
try {
ResultSet rs = SQLOperations.viewResume(id);
while (rs.next()) {
dc.open();
dc.add(new Paragraph(rs.getBlob("resume")));
dc.close();
}
}
catch (DocumentException de) {
de.printStackTrace();
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
SQLCommands.java
package com.dls.csb.utility;
public interface SQLCommands {
String VIEW_RESUME ="select resume from account where id=?"
}