public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//get the 'file' parameter String fileName = (String) request.getParameter("file"); if (fileName == null fileName.equals("")) throw new ServletException( "Invalid or non-existent file parameter in UrlServlet servlet.");
if (fileName.indexOf(".pdf") == -1) fileName = fileName + ".pdf";
buf = new BufferedInputStream(urlConn.getInputStream()); int readBytes = 0;
//read from the file; write to the ServletOutputStream while ((readBytes = buf.read()) != -1) stream.write(readBytes); } catch (IOException ioe) { throw new ServletException(ioe.getMessage()); } finally { if (stream != null) stream.close(); if (buf != null) buf.close(); } }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {