Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

write Excel through servlet

Thread view: 
finecur - 05 Apr 2007 05:07 GMT
Here is my servlet:

public void doGet(HttpServletRequest request,
         HttpServletResponse response)
         throws ServletException, IOException{

       response.setContentType("application/vnd.ms-excel");

       response.addHeader("Pragma", "no-cache");
       response.setHeader("Cache-Control","no-cache");
                   response.setDateHeader ("Expires", 0);

                   PrintWriter out = response.getWriter();
       out.println("<html>");
       out.println("<body>");
       out.println("<table border=1>");
       out.println("<tr>");
       out.println("<th>A</th>");
       out.println("<th>B</th>");
       out.println("</table>");
       out.println("</body>");
       out.println("</html>");
          }

When I call it from http://www.mydomain.com/myservlet.do?mypara=1 in
IE 7, it says

"Do you want to open or save this file?
Name:myservlet_do?mypara=1
Type:Microsoft Ecel Worksheet, 733
Form:www.mydomain.com
"

Then I click "Open",

but it says" Can not open the file", and the IE page went black.

Does anyone know why?

Thanks,

ff
LuckyBoy - 05 Apr 2007 05:34 GMT
This is a Bug in IE Header. Search Sun discussion forums and you will
get the answer. Did you try in Firefox or Other browser ? What does it
say then ?
Sanjay - 05 Apr 2007 16:08 GMT
> Here is my servlet:
>
[quoted text clipped - 38 lines]
>
> ff

I had exact same problem couple of years ago. I guess you code works
fine with Firefox or mozilla. Because your cache expires in 0 seconds,
what IE does in my opinion is downloads the file and because it expires
in 0 seconds  deletes it and now can not open it.

Try setting "expires" header to some value like 2 minutes etc. That
should work.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.