How send different files to browser at same time ..example(pdf&html) want display in same request using servlet

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









Related Tutorials/Questions & Answers:
How send different files to browser at same time ..example(pdf&html) want display in same request using servlet
How send different files to browser at same time ..example(pdf&html) want...); } } }![alt text][1] [1]: http://How send different files to browser at same time ..example(pdf&html) want display in same request using servlet
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p  Hi, I have designed a "back" button for jsp page. Now I want to disable Browser's default button So that people will use "back
Advertisements
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p  Hi, I have designed a "back" button for jsp page. Now I want to disable Browser's default button So that people will use "back
Want to display Arraylist items on same row in JSF
Want to display Arraylist items on same row in JSF  I want do display values of one arraylist on same row using datatable? If i use h:column, then it goes on different row. Please tell me, how I can do it?   Hi Friend
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
Using insert update and delete in the same servlet
Using insert update and delete in the same servlet  How to write insert, update and delete coding in the same servlet
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list ...),then it want to display all records from table specific to that rollno in that same... with the request directly received from browser, but not with the events. In JSP a simple
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 print different Messge for the same NumberFormatException on different cause objects in JAVA?
How to print different Messge for the same NumberFormatException on different cause objects in JAVA?  How to print different Messge for the same NumberFormatException on different cause objects in JAVA? try { int
login for different user in the same page
login for different user in the same page  how can i do the login for different user in the same page throug jsp
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE ... is how to get Roleid in textbox when i select Role_name from combobox in a same createuser.jsp page. I want to store this Roleid into database. So please send me
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
How to display content in same page while selecting fron dropdown list
How to display content in same page while selecting fron dropdown list  Thanks for your suggesstion.but Please provide me coding by using only one dropdownlist in javascript or jquery.Thanks in advance
how to use dropdown list in JSP and display value in same page
how to use dropdown list in JSP and display value in same page  I... in the same page Value selected = C How can we do this in a JSP page... one option the value must get displayed below it in the same page
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
display checked ckeckbox in same jsp page
display checked ckeckbox in same jsp page  how to display checked ckeckbox in same jsp page?   Hi, Here is the html code to display check... || []).push({}); Now i want to display ,selected checked checkboxes
How to browse and upload the file in same page using jsp.
How to browse and upload the file in same page using jsp.  Hi, I am doing a project and i want to browse and upload the file in same page inside...;TITLE>Display file upload form to the user</TITLE></HEAD> <
How to browse and upload the file in same page using jsp.
How to browse and upload the file in same page using jsp.  Hi Sir, I am doing a project in jsp servlets and i want to browse and upload the file in cell if a table in same page, post answer as soon as possible.thanks
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
how to get values for same column name from two different tables in SQL
how to get values for same column name from two different tables in SQL  how to get values for same column name from two different tables in SQL???? column name is emp_id loacated in these two tables company,employee
How to upload files to server using JSP/Servlet?
How to upload files to server using JSP/Servlet?  How to upload files to server using JSP/Servlet
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser
reading data from a text box with the same name using servlets - JSP-Servlet
reading data from a text box with the same name using servlets  Hello sir, i want to get the values from four textboxes having the same name like a= b= c= using servlet i want to print all the values from each text
different output trying to execute same java code
different output trying to execute same java code  i am using net... and tried to run, JOptionPane showing "portList : false" Why there is different output trying to execute same java code (adsbygoogle
display contents on the same page by selecting a radio button
display contents on the same page by selecting a radio button  Bill...")) { %> Due Date<input type="date" name="date"/> <% } %> i want... on the same page under the radio button
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... " portList : false" Why there is different output trying to execute same java
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... " portList : false" Why there is different output trying to execute same java
how to restrict user against marking same event more than one times - JSP-Servlet
giving multiple time same test. Is it possible that once user marked particular test, the same test should not display them once he/she will log in next time...how to restrict user against marking same event more than one times 
Do I learn ML and IoT at the same time
Do I learn ML and IoT at the same time  Hi, I want to make better... to learn first? Do I learn ML and IoT at the same time? Thanks   Hi, All... are very important. I advice you to start learning ML and also some time
Do I learn ML and IoT at the same time
Do I learn ML and IoT at the same time  Hi, I want to make better... to learn first? Do I learn ML and IoT at the same time? Thanks   Hi, All... are very important. I advice you to start learning ML and also some time
Servlet signup same output - JSP-Servlet
Servlet signup same output  Ok i solved the problem of content type by res.setContentType("text/plain"), but the output is same it always prints the else value(i.e. One of the mandatary field is empty) so please help, thanks
how to display a table from database using servlet
how to display a table from database using servlet  how to display...({}); http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks   Hi... go through the following link: http://roseindia.net/jsp/servlet-jsp-data
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
Time display - JSP-Servlet
Time display   In a web application or ina website if we display the time getting as system time, whether it is server' system time or client' system time. Is there any difference between getting time using java Date
How to send HTTP request in java?
How to send HTTP request in java?  How to send HTTP request in java
Get form value in same page - JSP-Servlet
Get form value in same page  Hello friends, Can we get a form field value in the same to be processed in java coding. For example
Can I learn Python and R at the same time?
Can I learn Python and R at the same time?  Hi, I am beginner... to learn: Can I learn Python and R at the same time? Try to provide me good examples... and R at the same time?". Also tell me which is the good training courses
How to get browser time zone?
How to get browser time zone?  How to get browser Time Zone and browser date using java concept
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks... and example program at Retrieve image from database using Servlet. Thanks
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet

Ads