Hi
I am using the
servlet outputstream in my javaclass as shown below.
public class DbReportServlet extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
Connection connection;
ServletOutputStream servletOutputStream =
response.getOutputStream();
InputStream reportStream =
getServletConfig().getServletContext().getResourceAsStream
("/reports/DbReport.jasper");
try
{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection ("jdbc:mysql://
localhost:3306/flightstats?user=dbuser&password=secret");
JasperRunManager.runReportToPdfStream(reportStream,
servletOutputStream, new HashMap(), connection);
connection.close();
response.setContentType("application/pdf");
servletOutputStream.flush();
servletOutputStream.close();
}
catch (Exception e)
{
// display stack trace in the browser
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
response.setContentType("text/plain");
response.getOutputStream().print(stringWriter.toString());
}
}
}
Now i need to redirect to another
jsp and display the outputstream content in the jsp page.
I m stuck with this problem.
Please help me out....
Thanks in advance.