I just opened a "project" I made when I was studying Java some years ago, and although it runs fine, I get these errors and I don't know what they mean:
warning: [options] bootstrap class path not set in conjunction with -source 1.5 Note: D:***\src\java\reportes\ServletRLineaMunieca.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:***\src\java\reportes\ServletRLineaMunieca.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
This web project includes many files, but I will only paste the one that gives the error:
package reportes;
import com.sql.ConectaDb;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperRunManager;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
public class ServletRLineaMunieca extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
HttpServletRequestWrapper srw =
new HttpServletRequestWrapper(request);
String fpath = srw.getRealPath("") +
"/reporte/RLineaMunieca.jrxml";
JasperDesign jasperDesign =
JRXmlLoader.load(fpath);
JasperReport jasperReport =
JasperCompileManager.compileReport(
jasperDesign);
HashMap jasperParameter = new HashMap();
jasperParameter.put("logo", "http://localhost:8084/tarea/images/logo.jpg");
Connection cn = new ConectaDb().getConnection();
byte[] bytes =
JasperRunManager.runReportToPdf(
jasperReport, jasperParameter, cn);
cn.close();
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream out =
response.getOutputStream();
out.write(bytes, 0, bytes.length);
out.flush();
out.close();
} catch (Exception e) {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Reportes</title></head>");
out.println("<body>");
out.println("<pre>");
e.printStackTrace(out);
out.println("</pre>");
out.println("</body>");
out.println("</html>");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
Since I made this a long time ago I have forgotten a lot about Java. Please bear with me, this is also my first time posting here, if my code is pasted wrong please show me how to do it properly.
i forgot to add that this part:
String fpath = srw.getRealPath("") +
the getrealpath is strikeout (is that how you say it?)