Home Answers Viewqa JSP-Servlet SaveAs Dialogue box is not working on button click in servlet

 
 


vikas pandey
SaveAs Dialogue box is not working on button click in servlet
0 Answer(s)      6 months and 23 days ago
Posted in : JSP-Servlet

Hii Sir, i added response.setHeader into my servlet code to export the data into excel file but this is not working on button click ...plz give me the write code. Thank you Sir.

response.setHeader("Content-Type", "application/vnd.ms-excel"); response.setHeader("Content-Disposition","attachment; filename=excel.xls");

String datum1 = request.getParameter("fromdate");
String datum2 = request.getParameter("todate");
SimpleDateFormat sdfSource = new SimpleDateFormat("dd-MM-yyyy");
Date date = sdfSource.parse(datum1);
Date date2 = sdfSource.parse(datum2);
SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd");
datum1 = sdfDestination.format(date);
System.out.println(datum1);
datum2 = sdfDestination.format(date2);
System.out.println(datum2);


HSSFWorkbook hwb = new HSSFWorkbook();
HSSFSheet sheet = hwb.createSheet("CallBillingSystem");

HSSFRow rowhead = sheet.createRow((short) 0);
rowhead.createCell((short) 0).setCellValue("calldate");
rowhead.createCell((short) 1).setCellValue("src");
rowhead.createCell((short) 2).setCellValue("dst");
rowhead.createCell((short) 3).setCellValue("dstchannel");
rowhead.createCell((short) 4).setCellValue("lastapp");
rowhead.createCell((short) 5).setCellValue("duration");
rowhead.createCell((short) 6).setCellValue("disposition");
rowhead.createCell((short) 7).setCellValue("amaflags");
rowhead.createCell((short) 8).setCellValue("cdrcost");


String strQuery = "";
ResultSet rs = null;

conexion conexiondb = new conexion();
conexiondb.Conectar();

strQuery = "SELECT * FROM cdrcost where date(calldate) between '" + datum1 + "' and '" + datum2 + "'";

 //strQuery = "SELECT * FROM cdrcost where date(calldate) between '2011-09-01' and '2012-01-01'";

rs = conexiondb.Consulta(strQuery);
int i = 1;
while (rs.next()) {
    HSSFRow row = sheet.createRow((short) i);
    row.createCell((short) 0).setCellValue(rs.getString("calldate"));
    row.createCell((short) 1).setCellValue(rs.getString("src"));
    row.createCell((short) 2).setCellValue(rs.getString("dst"));
    row.createCell((short) 3).setCellValue(rs.getString("dstchannel"));
    row.createCell((short) 4).setCellValue(rs.getString("lastapp"));
    row.createCell((short) 5).setCellValue(rs.getString("duration"));
    row.createCell((short) 6).setCellValue(rs.getString("disposition"));
    row.createCell((short) 7).setCellValue(rs.getString("amaflags"));
    row.createCell((short) 8).setCellValue(rs.getString("cdrcost"));
    i++;
}
FileOutputStream fileOut = new FileOutputStream(filename);
hwb.write(fileOut);     
hwb.write(response.getOutputStream());
System.out.println("Your excel file has been generated!");
FileOut.close();

} catch (Exception ex) { System.out.println(ex);

}

}

View Answers









Related Pages:
SaveAs Dialogue box is not working on button click in servlet
SaveAs Dialogue box is not working on button click in servlet  Hii Sir, i added response.setHeader into my servlet code to export the data into excel file but this is not working on button click ...plz give me
Click on Page Refresh - JSP-Servlet
Click on Page Refresh  hi ,i am working on jsp with mysql. i m facing a problem whenever i click on page refresh or f5 button, the value on form... the condition in which record insert in the database only when the "submit button
get a radio button click value - JSP-Servlet
get a radio button click value  thanks sir for sending code ,but i...") in servlet that is used in another jsp so can i call getParameter("radio") i.e... servlet from another jsp i.e 'main.jsp', then you have to store the value of id
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
Browser Back Button click event javascript
Browser Back Button click event javascript  I am using the below code but window.onBeforeUnload is not working with back button.. how can i apply the below code for the click event of back button? window.onBeforeUnload
File Upload is working in FireFox & Chrome but not in IE7 using java & jquery
File Upload is working in FireFox & Chrome but not in IE7 using java & jquery  Hi, I have a form which is called on my button click "Upload a file" and shows dialogue to select the file.After that I am calling Jquery function
combo box
a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get... to that user in left list.when we select module from left list and click INCLUDE button...combo box  Hi, [_|] dropdown box
click on check box
click on check box  I create a check box in HTML and when i click on my check box relative information in page store in database
on click button php
on click button php  Function in PHP for on click button
Applet is not Working
on the ?Security? tab. Then click on the ?Custom Level? Button, it shows you... Applet is not Working     ... applet is not working in the browser Are you running Mac OS 9? Firstly check
css click box
css click box  I wanted to create a click box in CSS with a hyperlink that should appears flat.   Find the below given code.. In your HTML file .. click box Text CSS a { display:inline-block; width:30px
passing values on button click
passing values on button click  Please help me to solve this issue.I want to pass a value assigned to button to another view upon button click in xcode
iphone button click event
iphone button click event  Hi, How to write iphone button click event? Thanks   Hi, Here the method declaration: -(IBAction) myMetod...{ NSLog(@"Button clicked"); } Thanks
jquery button click
jquery button click  jquery button click - I have created a button in JQuery but the problem is that it's not detecting click. What could... to create a button event in JQuery. You can edit it as per your requirement. In Header
How to check for Empty textboxed and fill it with a value on a button click
with a Button beside it . when i enter a text in that box and click the button it should go.... the button should be disabled once i click it(i managed to do that), but when i'm... click. When you enter a text in a textbox and click the button, it will get added
JSP Submit Button
JSP Submit Button  Sir, I have a JSP page with 2 Submit button, both calls doPost method of same servlet. If I click any submit button the text box value get refreshed and set to null or blank, that should not happen. Plz help
How to add download option for openwith and saveAs on exporting file to excel in servlet
How to add download option for openwith and saveAs on exporting file to excel in servlet  Hii Sir, I made an application in which i need to export... my requirement I need to give download option for openwith and saveAs from
How to add download option for openwith and saveAs on exporting file to excel in servlet
How to add download option for openwith and saveAs on exporting file to excel in servlet  Hii Sir, I made an application in which i need to export... my requirement I need to give download option for openwith and saveAs from
java swing button click event
java swing button click event  java swing button click event   public void doClick()   Java Swing Tutorials
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
servlet not working properly ...pls help me out....its really urgent
as the user click submit button he will reach to updation.java servlet through WEB.XML 2)**WEB.XML** <web-app> <servlet> <servlet...servlet not working properly ...pls help me out....its really urgent  
SERVLET
name,when user enter his id and click on the edit button,then the value should... to the next page with value,and when user enter his id and click on the delete button...SERVLET  I want to create a login form with one text box submit edit
window.open() not working - Ajax
is that the pop up window is not at all working.. Once I click the button, the page...(containing Database informations) on clicking a button. I have used
Call a servlet on click of hyperlink
Call a servlet on click of hyperlink  Call a servlet on click... the servlet url of desired servlet as href="<%=request.getContextPath()%>/CallServlet? . CallServlet is the url of the Servlet. <html>
How to call java method on Button click in jsp?
How to call java method on Button click in jsp?  How to call java method on Button click in jsp
SubCombo box not working - Development process
SubCombo box not working  Hi, in the following code subcombo box is not working and while storing combo box numbers(1,2,3) are stored instead of values. Search Page var arr = new Array(); arr[0] = new
adding a dialogue
adding a dialogue  Blockquote Hi can you help with the program below,the program is a loop that prints out a code and a quantity when prompt for the user input.what I need is to modify the code to incorporate a dialogue asking
On Click on Submit Button Display Data on Orderlist
On Click on Submit Button Display Data on Orderlist  How can retreive data from database on orderlist on Click on submit Button of same page
jQuery image replacement by click or select
by button click or by selecting an option of select drop down box without refreshing... to replace image by button click or select drop down without refreshing complete...; <center><h3>Click below button to change Image</h3><
JavaScript click method
JavaScript click method       In the html page we can select the check box either... the JavaScript method click() on the checkbox object. In this example we have developed
button
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can we retriving dat from database, capturing data, moving to next page.. etc
button
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can be retriving dat from database, capturing data, moving to next page.. etc
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
create text box by clicking button and submittong text in text box using submit
create text box by clicking button and submittong text in text box using submit  Hi, I created a button when i click on button new textbox... will click submit button the text should be submitted(it shows the value in text
onClick not working - Java Beginners
pizza order button is clicked. I have it linked to a function... click the To cancel the order and start over, click
Alert Box in Flex
is modal, which means it retains the focus until we close it or click on any button...;middle"> <mx:Button label="Click" click="ClickEvent()"... as follows will be shown on the screen. If we click Yes button, output
click on back button go to the login page
click on back button go to the login page  now when i click on back button the page show that page on where i came from and it shows the session expired but i want when i click a back buttob then it should show a login page
JSP view detail page on accept button click
JSP view detail page on accept button click  i Have 1 jsp page in that there r 2 button accept and view details when we click on aceept button it will submit to next page and when click on view details page it will shown the data
Click On Images of Submit Button Perform Action
Click On Images of Submit Button Perform Action  I have login page in which insert of submit button i used image. Therefor on Click of image i have to validate form , link with database and goto the next page
Open website on Button Click - Java Beginners
Open website on Button Click  Hello sir I want to open website on button click using java swing plz help me sir. in my swing application one "VISIT US BUTTON" i want to open my website on Button CLick  Hi Friend
iPhone Button Click Sound
iPhone Button Click Sound In this series of iPhone button tutorial, we... the application to listen the sound on button click. The sound file that i have used... on clicking the button in iPhone SDK. For the audio we are going to use
submit button
using hibernate in JSP(Netbeans). When I click insert button it should go...;/p>   Perform action on Servlet from jsp in the following manner: Put your servlet inside classes folder of your web application folder inside
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box  Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values will generate from database table
Expand / Collapse form div when click on button
Expand / Collapse form div when click on button  Hi, I have a form integrated from Wufoo with iFrame code. If the user misses a field an error message appears but it takes more space than the DIV Formbox. How can I make the DIV
Image selection instead of radio button very urgent.. - JSP-Servlet
button to select Emp ID which is getting populated in the text box of my home page...Image selection instead of radio button very urgent..  Respected Sir... of this radio button. There must be an arrow or icon for each Emp ID. The color
dialog box size allignment
dialog box size allignment  actually i have 1 button,when clicked on it has to show dialog box containing 14 rows and 3 columns(jtextfield and jlables). i added action listener.is it working fine.but when i resized the dialog
Display alert box on clicking link
"redirecting...." and when we click "Ok" button... is used to display alert box on clicking link : $("a").click(function...Display alert box on clicking link In this tutorial, we will display alert box
Session expire and back button in jsp and servlet .
Session expire and back button in jsp and servlet .  Hii Sir... previous pages by clicking back button of browser without again logging. Plz sir give me the full working code of this .It is the starting need of my project

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.