Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Submit and Excel buttons and my Jsp

 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I've 2 buttons(submit and excel) in 2 forms in my jsp.The submit runs a query and displays a html table,while the excel button
exports this in microsoft excel format.

I don't know why, when i click the excel button it'ss not showing me the dialog box,instead it just refreshes the same
page.I even tried having both buttons is one form but that didn't worked either.My other reports show me the dialog
box so there can't be I.E problem.Can anyone tell me..if there's something wrong with my code.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, I would print out the value of 'foo' to make sure it's what you think it is (remember you're working with a case sensitive language).

Also, MSIE sometimes ignores the content-type header and treats everything as HTML. Set the Content-Disposition tag and give your page a filename with an xls extension. This might prod to MSIE to do what you want it to.
 
Avery Hou
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to set response header to notify browser how to handle this response


<form action="aaa.jsp" method="POST">
<font face="Helvetica">
<input type="Submit" VALUE="SUBMIT" name="go">
</form>
<%

if(request.getParameter("go") != null) {
String file = "test.html";
response.addHeader("Content-typ","application/octet-stream;charset=big5");
response.addHeader("Content-disposition","attachment; filename=" + file);
}
%>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65542
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Avery",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Friends,
I am printing out the "foo" value and its showing me the exact value as i need.And I also tried with Avery's code,with aaa.jsp....that can't work becuase it throws a error....and when i change it to Test.jsp,it just refreshes the page.I have no clues to this..and my deadline is approaching...due you guys have any further clues....
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
Basically when i add this part to my jsp file,my excel dialog box stops showing up..and when i remove this code it works fine.Can someone tell me why this unusual behaviour is happening.I am posting the code,which is really simple to understand.

Help me Guys.
 
Water! People swim in water! Even tiny ads swim in water:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!