You need to use a servlet to do that:
import java.io.IOException;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
public class viewPDF extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
OutputStream out = null;
DB1 db = new DB1();
Connection conn=db.dbConnect(
"jdbc:jtds:sqlserver://localhost:1433/smpp","sa","");
try {
response.setContentType("application/pdf");
out = response.getOutputStream();
byte[] b = db.getPDFData(conn);
out.write(b,0,b.length);
out.close();
} catch (Exception e) {
throw new ServletException(
"Exception in Excel Sample Servlet", e);
} finally {
if (out != null)
out.close();
}
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
doGet(request, response);
}
}
See more info here and a fully working example which uses a PDF from a database in a browser: java-tips