How send different files to browser at same time ..example(pdf&html) want display in same request using servlet
package com.readfiles;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ReadPdfFileServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
performTask(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
performTask(request, response);
}
private void performTask(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
String pdfFileName = "Java Tips.pdf";
String contextPath = getServletContext().getRealPath(File.separator);
File pdfFile = new File(contextPath + pdfFileName);
response.setContentType("application/pdf");
response.addHeader("Content-Disposition", "attachment; filename=" + pdfFileName);
response.setContentLength((int) pdfFile.length());
FileInputStream fileInputStream = new FileInputStream(pdfFile);
OutputStream responseOutputStream = response.getOutputStream();
int bytes;
while ((bytes = fileInputStream.read()) != -1) {
responseOutputStream.write(bytes);
}
}
}![alt text][1]
[1]: http://How send different files to browser at same time ..example(pdf&html) want display in same request using servlet
View Answers
Ads
Related Tutorials/Questions & Answers:
Advertisements
i want to display where i entered values to same page
i
want to
display where i entered values to
same page hi friends !!
i have a values from jsp page .and i
want to store that values into DB at the
same time i
want to show immediatlly on
same jsp page with tabular format
i want to display where i entered values to same page
i
want to
display where i entered values to
same page hi friends !!
i have a values from jsp page .and i
want to store that values into DB at the
same time i
want to show immediatlly on
same jsp page with tabular format
i want to display where i entered values to same page
i
want to
display where i entered values to
same page hi friends !!
i have a values from jsp page .and i
want to store that values into DB at the
same time i
want to show immediatlly on
same jsp page with tabular format
How to send the request and get the request?
How to
send the
request and get the
request?
how to
send a
request to a JSP file in another domain in the
same server and get the
request done i.e
how to include JSP file of one domain to another doamin JSP within in the
same
display results on same jsp page
display results on
same jsp page is there any method to
display search results from database on the
same jsp page where i give the inputs
using struts 1.2
display results on same jsp page
display results on
same jsp page is there any method to
display search results from database on the
same jsp page where i give the inputs
using struts 1.2
display results on same jsp page
display results on
same jsp page is there any method to
display search results from database on the
same jsp page where i give the inputs
using struts 1.2
same thing i want but from db..
same thing i
want but from db.. http://www.roseindia.net/tutorial/javascript/dynamicCombo.html
same thing i
want but from db
inserting same data to different tables in oracle
inserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i
want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i
want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i
want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i
want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i
want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting
same data to
different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i
want pickup these table names from a drop down list in html...is there any chance can
Displaying Date in Servlet
;
In this
example we are going to show
how we can
display
a current date and
time on our
browser. It is very easy to
display it on our
browser... web server recieves the
GET
request from the
servlet. The doGet() method takes two