Problem in(IE 6) Opening non-html files using Servlets (Urgent)

Hi,
My application developed using struts 1.3 have an option to upload and download any kind of files.
The uploaded files shall be displayed as hyperlinks in the HTML page. On click of a hyperlink, a servlet shall be called and the corresponding file shall be opened as an attachment. But i am facing problem in opening the files.
The problem is,
Whenever i try to open a file of type (.doc or .xls or .pdf) the browser(*IE 6*) does not identify the content type. So it opens the content in a browser as binary content. But it works perfectly in IE 7 and firefox. (I used mim.types file to fetch the content type dynamically based on the file chosen)
However, the code i used to open a .doc file is,
response.setContentType("application/msword");
response.setHeader("Content-Disposition", "attachment;filename="+content.getFileName());
response.setContentLength(content.getStream().size());
ServletOutputStream out;
out = response.getOutputStream();
content.getStream().writeTo(out);
out.flush();
content - is a TO which shall hold the fileName and ByteArrayOutputStream ,etc.
Please anyone can help me solving this issue.
Thanks,

thanks..
its working fine now. i just added response.reset() before setting the properties of HTTPResponse object.

Similar Messages

  • Opening a HTML file using platformRequest

    Hi all,
    I am able to open a URL using the platformRequest() method.
    However, is it possible to open a HTML file which is stored in the file system? I tried the code given below, but it didn't work.
    platformRequest("file:///root1/Temp.html");Is this possible?
    Thanks,
    Venkat

    Hey Venkat,
    From what I understand, this HTML file is not inside your JAR -it is in the file system of the phone. In MIDP 2.0, for accessing the file system of the mobile, there are optional APIs that a MIDP device needs to support. This code will not work for MIDP 2.0

  • How to open non-HTML fiiles in the web browser???

    Hi.. My project requires that I should be able to open all the non-HTML or HTML files in the web browser itself. Ex. If there is some pdf file or doc file or any other file it should open in the browser itself. If the appropriate plug-ins are not there then it should first ask to download those plug-ins and then after downloading it the file should open in the browser.
    I would be grateful if anyone can help me out. If there is some link or something like that then please let me know.
    Thanks in advance.

    hi,
    you can open non-HTML files in the browser... when the file is sent from the server side you have to set the content type to match the content type of the file you are sending..
    for example, if you are sending a pdf file.. you have to set the content type as : application/pdf
    Another example: If you are sending a word doc use: application/msword
    -- Abdel Raoof Olakara
    http://olakara.googlepages.com

  • Opening HTML file using a Jbutton

    can anybody tell me how can I open an HTML file using a Jbutton.
    I have a help button on my menu of my GUI. I wanna open a html document using the help (jbutton)
    thank you

    call this class in your button action
    import javax.swing.JInternalFrame;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.JOptionPane;
    import javax.swing.BorderFactory;
    import javax.swing.border.*;
    import javax.swing.JDesktopPane;
    public class Taa extends JFrame implements HyperlinkListener{
         public JEditorPane hh;
         public JScrollPane ss;
    *Taa default constructor
    *@param Nothing
    *@return Nothing
    *@thorws nothing
    *@see descon
    public Taa(){
    //set top left image in the gui
    setIconImage(Toolkit.getDefaultToolkit().getImage("buttons/help.jpg"));
    try{
         File f=new File("Here you can put your html"such as"Help.htm");
         String s = f.getAbsolutePath();
         s = "file:"+s;
         URL url = new URL(s);
    hh=new JEditorPane(s);
    hh.setEditable(false);
    hh.addHyperlinkListener(this);
    catch (MalformedURLException e) {
         System.out.println("Malformed URL: " + e);
    catch (IOException e) {
         System.out.println("IOException: " + e);
         ss=new JScrollPane(hh);
         getContentPane().add(ss);
         setBounds(232,0,490,500);
         setResizable(false);
         show();
    *Implementation of HyperlinkEvent
    public void hyperlinkUpdate(HyperlinkEvent e) {
         if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
         linkActivated(e.getURL());
    *this method activate link
    *@param URL the URL
    *@return Nothing
    protected void linkActivated(URL u) {
         Cursor c = hh.getCursor();
         Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
         hh.setCursor(waitCursor);
         SwingUtilities.invokeLater(new PageLoader(u, c));
    *this class load help files
    class PageLoader implements Runnable {
    *Taa default constructor
    *@param Url the url,Cursor c
    *@return Nothing
    *@thorws nothing
    *@see descon
         PageLoader(URL u, Cursor c) {
         url = u;
         cursor = c;
    public void run() {
         if (url == null) {
              // restore the original cursor
              hh.setCursor(cursor);
              Container parent = hh.getParent();
              parent.repaint();
         } else {
              Document doc = hh.getDocument();
              try {
              hh.setPage(url);
              } catch (IOException ioe) {
              hh.setDocument(doc);
              getToolkit().beep();
              } finally {
              // schedule the cursor to revert after
              // the paint has happended.
              url = null;
              SwingUtilities.invokeLater(this);
         URL url;
         Cursor cursor;

  • When i open any .HTML file from my computer it is not opening in firefox. Only a blank New Window Opens. Facing this problem since the firefox has updated.

    Whenever i try to open any HTML file from my computer, it opens a new firefox window which is blank. Facing this problem after the new update. please fix this problem

    I found that after Firefox v29, a LOT of my settings and<BR>
    add-ons were changed / reset. Try this;
    '''''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]'''''
    <BR>While you are in safe mode;<BR>
    '''''Firefox Options > Advanced > General'''''.<BR>
    Look for and turn off '''Use Hardware Acceleration'''.<BR>
    Then check ALL of your settings. Browser and add-ons. Then restart.

  • I have opened two versions of Firefox (v3.6.18 and v3.5), v3.6.18 is my default browser. The problem comes after an attempt to open a HTML file.

    I have opened two versions of Firefox (v3.6.18 and v3.5), v3.6.18 is my default browser. The problem comes after an attempt to open a HTML file. An error appears: "Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system." Why wouldn't it just open on my default browser? Thanks for the help!

    A possible cause is security software (firewall) that blocks or restricts Firefox without informing you about that, maybe after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox.
    See [[Firewalls]] and http://kb.mozillazine.org/Firewalls
    http://kb.mozillazine.org/Browser_will_not_start_up

  • FF16.02: opens webpage HTML file as code instead of webpage, seems to save as temporary .txt instead of html.

    Hi,
    I'm using FF 16.0.2
    I have to open a link/attachment on a webpage that is a .html file.
    When I click open, regardless of what software I use to do so: OpenOffice, IE, FF, notepad, wordpad - only HTML code is seen. This is what I assume to be because of what "jscher2000" mentioned - the URL is converted into a HTML.txt file.
    Notably, if I go to the website on IE and open the HTML file through it, it works no problem. I have tried disabling addons.
    I have been looking for fixes & addons to go around this problem, but none so far. First time posting!

    See my answer here: [[/questions/930461#answer-378263]]

  • Open an html file inside spry collapsible panel

    Greetings,
    Using CS5
    Does anyone know the CSS code/possibility of opening an html file inside the Spry panel?
    I've tried the following code:
    .CollapsiblePanelContent {
        background-image: url(lookoutgraph.html);
    Is there a better CSS element for calling up an html file?
    For what it's worth...the html file I'm tring to open uses a <canvas> tag. When opened by itself, the html file has no problem opening and displaying the canvas data.
    Much Thanks!

    With the exeption of images, to add external content to a document you will need to make use of either serverside or clientside code.
    Have a look at the SpryHTMLPanel here http://labs.adobe.com/technologies/spry/samples/htmlpanel/html_panel_sample.html
    Otherwise, please supply a link to your site so that we can come up with alternatives.
    Gramps

  • Open an HTML file from a SAP Report

    Hi all!
    I would like to open an HTML file, that`s in a local directory of my PC, from a SAP Report.
    It is an alv list, where I have added a pushbotton. And I would like to code the utility of open a local html file, when someone push it.
    Anybody knows if it is possible?
    Thx

    Here is some sample code.
    report zrich_0002.
    call method cl_gui_frontend_services=>execute
      EXPORTING
        DOCUMENT               = 'C:test.html'
    *    APPLICATION            =
    *    PARAMETER              =
    *    DEFAULT_DIRECTORY      =
    *    MAXIMIZED              =
    *    MINIMIZED              =
    *    SYNCHRONOUS            =
    *  EXCEPTIONS
    *    CNTL_ERROR             = 1
    *    ERROR_NO_GUI           = 2
    *    BAD_PARAMETER          = 3
    *    FILE_NOT_FOUND         = 4
    *    PATH_NOT_FOUND         = 5
    *    FILE_EXTENSION_UNKNOWN = 6
    *    ERROR_EXECUTE_FAILED   = 7
    *    others                 = 8
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Please remember to award points accordingly and mark this post as solved when you problem is solved.  Thanks.
    Also, Welcome to SDN!!
    Regards,
    Rich Heilman

  • Opening local .html files on iPad

    I have created a personal homepage that I have loaded on my Macs at home. Any way I can use this file on my iPad 3?

    It is possible to open local HTML files in Safari on iPad2. Easy!
    Open your Safari.
    Touch Bookmark icon for a little while.
    A dialogue box appears with "/var/Mobile" title.
    Go to "Applications" > your app (iFile, GoodReade or whatever yours) > Documents.
    And you are there. Open your HTML files.
    Now you can go anywhere to and fro without problem.
    It is FTP:///.
    If need later, Bookmark that.
    With Loving-Kindness!
    bhikkhusirin

  • Opening a HTML file through GUI

    Hi guys I am new to java and HTML and now I need to open a HTML file which is saved on disk and search for a word my code is as shown below.......
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class Test_Find extends JFrame {
        public Test_Find() {
            initComponents();
            setExtendedState(JFrame.MAXIMIZED_BOTH);
            textarea.setText(initialText);
            textarea.setCaretPosition(0);
            setVisible(true);
            textarea.requestFocusInWindow();
        private void initComponents() {
            scrollTextarea = new JScrollPane();
            textarea = new JTextArea();
            toolbar = new JToolBar();
            findB = new JButton();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setTitle("Test Find");
            scrollTextarea.setViewportView(textarea);
            getContentPane().add(scrollTextarea, BorderLayout.CENTER);
            toolbar.setFloatable(false);
            findB.setText("Find");
            findB.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    findBActionPerformed(evt);
            toolbar.add(findB);
            getContentPane().add(toolbar, BorderLayout.NORTH);
        private void findBActionPerformed(ActionEvent evt) {
            String input = JOptionPane.showInputDialog(
                    "Find what:", pattern);
            if(input==null){
                input="";
            pattern=input;
            doFind();
        private int doFind(){
            textarea.requestFocusInWindow();
            currentCaretPosition = textarea.getCaretPosition();
            text = textarea.getText();
            if(!pattern.equals("")){
                int pos=0;
                pos = text.toLowerCase().indexOf(pattern.toLowerCase(), currentCaretPosition);
                if(pos>-1){
                    scrollTextarea.getHorizontalScrollBar().setValue(0);
                    textarea.setCaretPosition(pos+pattern.length());
                    highlight(textarea, pattern);
                    return 1;//found
            }else{
                removeHighlights(textarea);
                return 0;//no pattern
            return -1;//not found
        // Creates highlights around all occurrences of pattern in textComp
        public void highlight(JTextComponent textComp, String pattern) {
            // First remove all old highlights
            removeHighlights(textComp);
            try {
                Highlighter hilite = textComp.getHighlighter();
                Document doc = textComp.getDocument();
                String text = doc.getText(0, doc.getLength());
                int pos = 0;
                // Search for pattern
                while ((pos = text.toLowerCase().indexOf(pattern.toLowerCase(), pos)) >= 0) {
                    // Add highlight around pattern using private painter
                    hilite.addHighlight(pos, pos+pattern.length(), textPainter);
                    pos += pattern.length();
            } catch (BadLocationException e) {
        // Removes only our private highlights
        public void removeHighlights(JTextComponent textComp) {
            Highlighter hilite = textComp.getHighlighter();
            Highlighter.Highlight[] hilites = hilite.getHighlights();
            for (int i=0; i<hilites.length; i++) {
                if (hilites.getPainter() instanceof TextPainter) {
    hilite.removeHighlight(hilites[i]);
    // An instance of the private subclass of the default highlight painter
    private Highlighter.HighlightPainter textPainter = new TextPainter(Color.yellow);
    // A private subclass of the default highlight painter
    class TextPainter extends DefaultHighlighter.DefaultHighlightPainter {
    public TextPainter(Color color) {
    super(color);
    public static void main(String args[]) {
    new Test_Find();
    private String input, pattern, text;
    private int currentCaretPosition;
    private JButton findB;
    private JScrollPane scrollTextarea;
    private JTextArea textarea;
    private JToolBar toolbar;
    private String initialText =
    "Swing JTable and JScrollPane Problem\n" +
    " tlloreti 4 Jul 5, 2005 4:15 PM\n" +
    "by Tom.Sanders \u00bb \n" +
    "Swing CTRL-A (select all) ignored in applet\n" +
    " ilmbeachgirl 4 Jul 5, 2005 4:10 PM\n" +
    "by ilmbeachgirl \u00bb \n" +
    "Swing drawing problem\n" +
    " gnosnahz 0 Jul 5, 2005 4:09 PM\n" +
    "by gnosnahz \u00bb \n" +
    "Java Event Handling events effecting panels in multiple tabs\n" +
    " sean_hagen 1 Jul 5, 2005 4:06 PM\n" +
    "by es5f2000 \u00bb \n" +
    "Swing Searching text in files & highlighting that text\n" +
    " sketty 1 Jul 5, 2005 3:57 PM\n" +
    "by camickr \u00bb \n" +
    "Swing JTextField displaying prtially its contents\n" +
    " SreeJay 1 Jul 5, 2005 3:55 PM\n" +
    "by camickr \u00bb \n" +
    "Swing how to get BufferedImage of a JPanel\n" +
    " praveen.Arora 1 Jul 5, 2005 3:53 PM\n" +
    "by camickr \u00bb \n" +
    "Swing Creating a form from a xml schema..\n" +
    " zoltern 0 Jul 5, 2005 3:51 PM\n" +
    "by zoltern \u00bb \n" +
    "Swing Da Suckers: Java and Windows XP\n" +
    " [email protected] 1 Jul 5, 2005 3:42 PM\n" +
    "by [email protected] \u00bb \n" +
    "Java 2D Rescaling using JAI\n" +
    " G-Rehuku 0 Jul 5, 2005 3:30 PM\n" +
    "by G-Rehuku \u00bb \n" +
    "Swing how to get Page Preview of multiple page JPanel\n" +
    " Sonu.Arora 0 Jul 5, 2005 2:20 PM\n" +
    "by Sonu.Arora \u00bb \n" +
    "Swing IDE for Swing Development\n" +
    " JavaEnthusiastt 8 Jul 5, 2005 2:17 PM\n" +
    "by uhrand \u00bb \n" +
    "Java 2D Can't connect to X11 window server\n" +
    " kusigubi 0 Jul 5, 2005 2:06 PM\n" +
    "by kusigubi \u00bb \n";
    }Since I am new to the field requesting the kind quick help by java experts here to help me change the code so that I would be able to search a web apge saved on disk and search and highlight a word in that page ....
    Thanks in advance........
    Looking forward for your kind suggestions.......                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Since I am new to the field requesting the kind quick help by java experts here to help me change the code so that I would be able to search a web apge saved on disk and search and highlight a word in that page ....
    Thanks in advance........
    Looking forward for your kind suggestions......1) Did you write that code? If yes, proceed to 2). If no, I charge 150 euros/hr. Let me know when you want me to start.
    2) Post the code for a program that opens a text file with the following in it:
    hello world
    and prints the contents out using System.out.println().
    3) Modify the program in 2) to determine if the file contains the word "yes". Post the code.
    4) An html file is no different than the text file in 2).

  • When I try to open the HTML file "file:///C:/Users/DHeimann/Documents/JP Cohousing/Retreat agenda 2014.htm", the system attempts to access Gmail and hangs.

    I can open various most other *.htm or *.html files on my C drive without a problem. However, there are other HTML files on the drive that do have this problem when I try to open them.
    When I try to open the file in Internet Explorer rather than Firefox, I get a message that JavaScript is not enabled. However, I do have JavaScript enabled, and have just updated Java to Version 7, Update 51.

    One of the problems with saving web pages from complex dynamic sites like Gmail is that you may be saving the instructions for rendering the page rather than the actual content of the page. In that case, if you are logged out of your account or there is a cross-site security bar to pulling the needed data, then the saved page may not display correctly or at all. If a message is critical, it's a good idea to print or save the page to PDF or grab a screen shot to work around that problem.
    The message you're getting in Internet Explorer may be related to the fact that IE has different security zones with different restrictions. For example, sites in the Internet Zone normally can run JavaScript, and sites in the Restricted Sites list cannot. The local computer zone has much tighter security compared with the old IE6/XP days, and that may explain what you're seeing there.
    P.S. Browsers interpret JavaScript internally without using the Java plugin.

  • Open my html file and cannot edit it

    When I open my html file from Flash, in view design all I get is a grey box with the Flash symbol in the middle and no html tools.
    I want to link some of my buttons but if I go into view live I get html tools but I still can't access them to make links.
    How do I get my html page so that I can make my links?
    Forrest

    Your next button can still do that.  But it has to be programmed within Flash.  Flash files are not natively handled by Dreamweaver.  You have to export them in order to place them on a website within Dreamweaver.
    The only way that Dreamweaver can do this for you is if you create a button in Dreamweaver which does this action for you outside of the Flash area.  Then this button can link to another page or Flash file.  But if the button resides within the Flash file then it must be edited with Flash.

  • Help Needed in opening a HTML File from swing application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Check your Application's JFrame properties (may be ur Frame is set to be in top position ,always),and also check running your application in some other OS.

  • How do I Open an HTML file for iOS?

    How do I open an HTML file for iOS using acrobat?

    This is a forum for Adobe Reader for iOS. Acrobat doesn't run on iOS. You need to run it on a Mac or Windows computer. In Acrobat, you can choose File > Create > PDF from Web Page to do what you want. You cannot do that in iOS.

Maybe you are looking for

  • Disconnect Device through Hotspot and can no longer connect

    I recently disconnected a Windows 7 device through the "Connected Devices" option on the Verizon Hotspot. After disconnecting that Windows 7 device I am no longer able to connect through the Verizon Hotspot. I have removed and added back the hotspot

  • How to hide the select-options fields on radiobutton select in webdynpro

    hi Could you please help how to hide the select-option fields in webdynpro there are four radio buttons for every radiobutton there is corresponding the select_option filed is associated to it user as only provision select  one radio button and reset

  • Very basic code questions

    Hi, I'm pretty new to dealing with this so please bare with me. I come from a PHP background so I got alot to learn here ;) Anyway, to my question then. I've got a book that im reading and following examples from but also try to evolve those examples

  • Nokia please tell us when exactly the updates of N...

    Why Nokia don't tell us when exactly the updates of N93 will be available? what is the problem of giving us an exact date? we paid money not to get a VGA image on a 3.2 megapixel camera !!! my 6600 gives better image quality than my N93'sMessage Edit

  • Safari won't open after installing Parallels 5 for Mac

    Recently installed a trial version of Parallels for Mac. After installation I could open both Safari and Explorer and access web pages from both. Now when I try to open Safari I get an error that says safari quit unexpectedly and will not relaunch wh