Opening Word file in Tomcat

Hi all,
I have a table in MS Access database that stored some MS Word documents. Those documents and stored as OLE object type in Access. Now i connected my Tomcat with Access using JSP but the problem is how can i open those word files in a separate window. How will i call them from database. Can anyone please help me.Thank you

How is the request being made? I assume via a jsp.
When user clicks on link put something like this....
HTML
<a id="wordDoc1" href="javascript:openDoc(docIDOrResultSetID)">open Doc<a>now have a function that calls your servlet or jsp that handles the processing...
JavaScript
function openDoc(id)
//build your url (path to the jsp or servlet...)
var url = "http://yourServletOrJsp";
url += "?docsID"+id
window.open(url,'name','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,dependent,width=500,height=500,left=100,top=100');
}This is just pseudo code nothing special. The main thing is use window.open() to create a new window.
Now your trick is to grab the content...
In the jsp or servlet or action class whatever framework you are using... (MVC 1 or 2, Struts - look them up if you don't know)
Get a handle to the resultset where the doc resides. And get the doc as a clob or blob (dont really know I don't use OLE).
look here...
http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html
get that from the recordset and put it into a bytearray --> byte[]
now return it...
JAVA
//your byte array...
byte[] content = null
//content is populated
String strMimeType = "application/ms-word";
response.setContent(strMimeType);
OutPutStream outStr = response.getOutputStream();
outStream.write(content);Something like that there are lots of ways to do this...
I hope that helps...
Also you can always just put a link to the file in the DB and keep the doc in a regular directory and use file i/o instead of keeping it in Access. Access starts to bog down when large entries / many records exist.
-D

Similar Messages

  • Can't open word files sent from my 9500 to E90

    Can some one please help me,
    word documents sent to my E90 from my 9500 won't open,
    message says :Unable to open file not supported,
    It all started with data mover, Contact & Calendar entries are fine but document folders are recognised but won't open,
    Nokia suggested using drag & drop, using Pc suit
    with the 9500 connected drag all wanted files from the phone into my Pc then connect the E90 and reverse the process, files appear but I can't open them,
    Then I was told to e-mail from my Pc as an attachment,
    did'nt work either, doesn't matter how you get the files into the E90 you don't seem to be able to open them.
    So, is it possable to get word files into an E90 from a 9500
    Thank you.

    11-Nov-200708:34 PM
    vmoisa wrote:
    Open Word file in 9500, choose "Save as" from the Menu and you will have an option on one of the buttons at the right of the screen regarding the Format. Press that button and choose MS Word format. If you save all your Word files like this you should be able to open them on E90.
    This is from memory alone. If I was not clear enough, please let me know and I will give you more detailed instructions. Good luck.
    Me again, opened and a file in my 9500 and saved it in MS Word 97 then using Pc Suit copied it from one phone into the other, but once again I get the same message (Unable to open.. File type not supported)
    I don't know if all E90's come with the same programs pre-loaded, in mine I have a program entitled Quick Office in which it says you can open and manipulate Word files along with Excel and also Lotus Notes but first you have to purchase and download software from Nokia to activate it,
    I have found that if I go into Quick Office and write a document in word then save it, I get the same message as above when I try to open it,
    As I said in my previous message, I suspect I will have to purchase the Quick Office software from Nokia,
    I look forward to hearing your thoughts,
    Kind Regards.
    As

  • Cannot open Word File because "there are problems with the contents"

    Hi Everyone,
    I cannot open Word File because "there are problems with the contents" unspecified error; Location: 2.  Please help as I need this doc for work meeting this morning.  Nothing special about this doc but links were copied into it???  However I do that all the time.  I have never had this happen before.  I am on a 2010 machine.  I just ran a disk permissions repaired and emptied the trash but still no dice.  I had several other word docs up as well when I got up this morning but they are all fine.  I do not have Time Capsule turned on (which I need to do but that will be another thread/question).
    Thank you,
    sb

    Ok, I found a way to open this but not sure what happened to begin with and the formatting setup is different now, almost like text editor?  Not sure what happened here but hope it doesn't happen again?

  • Since updating my ipad2 with latest software I can't open Word files - reason??

    Since updating my ipad2 with latest software I can't open Word files - reason??

    Try this:
    1. Close all apps in the Task Bar. Double-click the Home button and hold apps down for a second or two. Tap the minus sign to close app.
    2. Hold the Sleep and Home button down until you see the Apple Logo.

  • Issue regarding open word file and read only mode using c# & MS-word interop

    i am programmatically open a word file for search and highlight keyword. my routine is working fine. the problem is when i am opening the file programmatically then a dialog come and ask me to open file in read only mode. the dialog look like below one
    actually i do not want to open the file in read only mode because people can open and like to change and save. so guide me what i can do to not to open the file in read only mode.
    here is my full code. just have a look and tell me what is wrong in my code or tell me any trick as a result i can open the file not in read only mode. here is my code.
    private void button1_Click(object sender, EventArgs e)
                object fileName = "";
                string filePath = "";
                string strSaveasPath = "";
                DialogResult result = openFileDialog1.ShowDialog();
                if (result == DialogResult.OK)
                    fileName = openFileDialog1.FileName;
                    //strSaveasPath = Path.GetDirectoryName(path.ToString());
                //fileName = "Z:\\C0000000003.doc";
                List<string> _list = new List<string>();
                _list.Add("tridip");
                _list.Add("arijit");
                //object fileName = "D:\\CVArchievePath\\C0000000001.doc";
                object textToFind = "test";
                object readOnly = false;
                Word.Application word = new Word.Application();
                Word.Document doc = new Word.Document();
                object missing = Type.Missing;
                try
                    doc = word.Documents.Open(ref fileName, ref missing, ref readOnly,
                                              ref missing,
    ref missing, ref missing,
                                              ref missing,
    ref missing, ref missing,
                                              ref missing,
    ref missing, ref missing,
                                              ref missing,
    ref missing, ref missing,
                                              ref missing);
                    doc.Activate();
                    object matchPhrase = false;
                    object matchCase = false;
                    object matchPrefix = false;
                    object matchSuffix = false;
                    object matchWholeWord = false;
                    object matchWildcards = false;
                    object matchSoundsLike = false;
                    object matchAllWordForms = false;
                    object matchByte = false;
                    object ignoreSpace = false;
                    object ignorePunct = false;
                    object highlightedColor = Word.WdColor.wdColorGreen;
                    object textColor = Word.WdColor.wdColorLightOrange;
                    object missingp = false;
                    Word.Range range = doc.Range();
                    foreach (string line in _list)
                        textToFind = line;
                        bool highlighted = range.Find.HitHighlight(ref textToFind,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing,
    ref missing);
                    System.Diagnostics.Process.Start(fileName.ToString());
                catch (Exception ex)
                    Console.WriteLine("Error : " + ex.Message);
                    //Console.ReadKey(true);
                finally
                    //doc.Close(missing, missing, missing);
                    if(doc!=null)
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(doc);
                    if (word != null)
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(word);
                    word = null;
                    doc = null;
                    GC.Collect();
                    GC.WaitForPendingFinalizers();

    I know it's a very old issue and I reached to this page looking for a solution. Finally, I have found a fix to this problem.
    The problem is that we create an instance of Word and do not close it correctly. This makes program believe that the file is already open and hence you're getting the respective message of file being locked by you.
    Set the visibility of your application to true and then when you close it both file and instance should close and you will not get the problem again.

  • Can no longer open Word files in finder since upgrading to Mavericks

    When I click on Word files on my desktop of in a folder, the Word progrm laucnhes but file will not open.  I can only open them through the Application.  Any solutions to this?  This seems to be across th board microsoft office issue.  In Office 2008, so do I need an upgrade or patch?
    thank you

    louisefromamsterdam wrote:
    Hi Brody, It doesn't work because Word wasn't in the dock and now I cant drag it there or do it  via 'add to sidebar' - probably because of this awfull Microsoft . is there no other solution to work with mavericks and Word?
    thanks for ideas
    There, I fixed it for you.
    I haven't used Word 2008 in quite a while.
    If Word launches, but doesn't open the file, it is something in Word that is not processing the open request from the Finder.
    You might try resetting the LauchServices database with this command in Terminal:
    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user
    Can you explain more about not being able to add Word to the Dock or Sidebar?
    It may be a corrupt Dock plist or databse causing that. I don't think it would affect Word opening documents, though.
    I haven't figured out how to reset the Dock and the Sidebar in Mavericks. The way I used to know doesn't seem to work.

  • Can't open Word files in Yosemite

    I installed Yosemite on my MacBook Pro Saturday. Now, I can't open existing files with Microsoft Word 2011. I can create and open new files, but I can't open old files. What gives?

    Let's gather some more information:
    How many of the following ways to open one of your old Word documents have you tried?
    * Double-click in Finder
    * Right-click in Finder, Open with..., Word
    * File > Open inside Word
    Do they all fail? In the same way?
    When an open fails, does it...
    * ... give an error message? (What message?)
    * ... beep?
    * ... fail silently?
    What file extension do these files have?
    * .DOCX
    * .DOC
    * .RTF
    * .TXT
    * something else? (What?)
    Have you tried uninstalling Word, reinstalling it, and updating it to the current version? (The intent is to rule out the possibility some component of Word has gotten damaged at some time in the past, and Yosemite triggers the damage to manifest itself.)

  • Download problem with JSF: Cannot open PDF-file after opening WORD-file

    Hello,
    I have a JSP (created with Java Studio Creator) which displays a table with links to different files. Some links open PDF-documents, other for instance DOC-files (msword). I download the file as follows:
    public String downloadFile(String fileName) {
    try {
    int dotIndex = fileName.lastIndexOf('.');
    String fileExtension = "";
    String contentType = "";
    if(dotIndex > 0) {
    fileExtension = fileName.substring(dotIndex+1, fileName.length());
    contentType=CONTENT_TYPES.get(fileExtension.toUpperCase()).toString();
    if(!fileExtension.equals("") && !contentType.equals("")) {
    // method that reads file to the byte array
    byte[] fileContent = getContentOfFile(new File(fileName));
    FacesContext faces = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
    response.setContentType(contentType);
    response.setContentLength(fileContent.length);
    response.setHeader("Content-disposition", "inline; filename=\""+fileName+"\"");
    try {
    ServletOutputStream out;
    out = response.getOutputStream();
    out.write(fileContent);
    } catch (IOException e) {
    e.printStackTrace();
    faces.responseComplete();
    catch(Exception ex) {
    return ("!!!ERROR: downloadFile(fileName) - Could not completely download file "+ fileName + ex.getMessage());
    return "";
    contentType is application/pdf if it`s a PDF-file or application/msword if it`s a word-file.
    fileName contains the full file path.
    link-properties:
    <ui:hyperlink action="#{showOriginalPDF.hyperlinkShowPDF_action}" binding="#{showOriginalPDF.hyperlinkShowPDF}"
    id="hyperlinkShowPDF" immediate="true" onClick="testSubmit()" target="_blank" text="#{currentRow.value['display']}"/>
    and the code of the JS-function testSubmit() (without this function I couldn�t get the right row selection in the hyperlink-table):
    function testSubmit() {
    document.getElementById('form1').submit();
    return false;
    All pdf-links are working fine and the correct document is displayed in a new browser window. but if I open a WORD-document and after that I click on another link to a pdf-file, the WORD-file is loaded again in the new window. Only if I close the window which contains the WORD-document, I can download the correct pdf after that.
    Is something wrong with the response header (I tried "attachment" instead of "inline" too but without effect)?
    Can anybody help?

    More than you asked for but good stuff. Permissions is buried in there somewhere.
    Reading
    [Resolve startup issues and perform disk maintenance with Disk Utility and fsck|http://docs.info.apple.com/article.html?artnum=106214]
    [Using Disk Utility in Mac OS X 10.4.3 or later|http://docs.info.apple.com/article.html?artnum=302672]
    [Disk Utility's Repair Disk Permissions 10.0-10.6|http://docs.info.apple.com/article.html?artnum=25751]
    "Try Disk Utility" (modified from [http://support.apple.com/kb/TS1417])
    1. Insert the Mac OS X Install disc that came with your computer (Edit: Do not use this disc if it is not the same general version as what you have currently on your computer, e.g. use a Tiger disc for a Tiger drive, not a Panther disc), then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
    5. Select your Mac OS X volume.
    6. Click Repair. Disk Utility checks and repairs the disk.
    Then boot in Safe Mode, (holding Shift key down at bootup; takes longer to boot this way so be patient), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    [Mac OS X: Starting up in Safe Mode|http://docs.info.apple.com/article.html?artnum=107393]
    [What is Safe Boot, Safe Mode? (Mac OS X)|http://support.apple.com/kb/HT1564]
    [Safe Boot takes longer than normal startup|http://docs.info.apple.com/article.html?artnum=107394]
    [Mac OS X 10.4, 10.5- Computer shuts down during Safe Boot|http://support.apple.com/kb/TA24054]

  • Can't open word files

    Ok, so I have tried every way of opening it under the sun, but I only get this message:
    The document “French Booklet.doc” couldn’t be opened.
    I opened it in textedit, and I can see it fine, but Pages seems to not want to open any word files.
    Anyone seen this before? Know how to fix it?
    Thanks in advance

    Make sure your iWork applications are updated. If you're not running the latest versions & Software Update says your software is up to date, make sure the applications are where the installer initially put them. The updaters are very picky. If the location is not where the updater is programmed to look or if the folder doesn't have the name the updater looks for, it will not work. The applications cannot be renamed or moved. They must be in the iWork '09 folder in Applications. That iWork folder must be named iWork '09. If it doesn't have the '09 Software Update won't find them & the updaters won't work.

  • Open word file, stored in database through Forms.

    Assalam-o-Alikum
    to Genius of Oracle's
    I have stored the Word file name "MY_FILE.DOC" in oracle database. Now i want to open the file through Forms, remember i am using forms 6i. is there any body who help me to open the file.
    Best Regards
    Farrukh Shaikh

    Assalam-o-Alikum
    My in tension was not to hurt any body. if it did then sorry for that.
    here is the code through which i stored the file in database
    first create the DIRECTORY CREATE DIRECTORY generic AS 'C:\temp';---- --directory path where your files will be searched for storing.
    THEN
    create table my_blob_table
    pk_name varchar2(20) primary key,
    pk_value varchar2(20),
    col_document blob
    INSERT INTO MY_BLOB_TABLE
    (PK_NAME,PK_VALUE)
    ('A','A');
    COMMIT;
    CREATE OR REPLACE PROCEDURE load_blob_from_file
    ( src_file_name IN VARCHAR2
    , table_name IN VARCHAR2
    , column_name IN VARCHAR2
    , primary_key_name IN VARCHAR2
    , primary_key_value IN VARCHAR2 ) IS
    -- Define local variables for DBMS_LOB.LOADBLOBFROMFILE procedure.
    des_blob BLOB;
    src_blob BFILE := BFILENAME('GENERIC',src_file_name);
    des_offset NUMBER := 1;
    src_offset NUMBER := 1;
    -- Define a pre-reading size.
    src_blob_size NUMBER;
    -- Define local variable for Native Dynamic SQL.
    stmt VARCHAR2(2000);
    BEGIN
    -- Opening source file is a mandatory operation.
    IF dbms_lob.fileexists(src_blob) = 1 AND NOT dbms_lob.isopen(src_blob) = 1 THEN
    src_blob_size := dbms_lob.getlength(src_blob);
    dbms_lob.open(src_blob,DBMS_LOB.LOB_READONLY);
    278 Oracle Database 11g PL/SQL Programming
    END IF;
    -- Assign dynamic string to statement.
    stmt := 'UPDATE '||table_name||' '
    || 'SET '||column_name||' = empty_blob() '
    || 'WHERE '||primary_key_name||' = '||''''||primary_key_value||''' '
    || 'RETURNING '||column_name||' INTO :locator';
    -- Run dynamic statement.
    EXECUTE IMMEDIATE stmt USING OUT des_blob;
    -- Read and write file to BLOB.
    dbms_lob.loadblobfromfile( dest_lob => des_blob
    , src_bfile => src_blob
    , amount => dbms_lob.getlength(src_blob)
    , dest_offset => des_offset
    , src_offset => src_offset );
    -- Close open source file.
    dbms_lob.close(src_blob);
    -- Commit write.
    IF src_blob_size = dbms_lob.getlength(des_blob) THEN
    $IF $$DEBUG = 1 $THEN
    dbms_output.put_line('Success!');
    $END
    COMMIT;
    ELSE
    $IF $$DEBUG = 1 $THEN
    dbms_output.put_line('Failure.');
    $END
    RAISE dbms_lob.operation_failed;
    END IF;
    END load_blob_from_file;
    after create the PROCEDURE run the procedure
    begin
    load_blob_from_file('FILE_NAME.DOC',' my_blob_table','col_document','PK_NAME','A');
    end;

  • Problems open word files gmail

    When I want to save an attached Word file from gmail, want to save the program with a completely different and really long file name - desutom can not file to either save or open, it works the other hand, in Outlook.Jag have managed to save a ye go on my desktop but then saved it as an HTML page and not as a word document.
    To uninstall Firefox and use explorer 9 but I still have the same problem.

    Hi MMantle,
    I do not want to buy mac word
    You use to open Word document with the FREE Application "OpenOffice" I use it myself an it's great. You can find it via Google.
    Good luck ...
    Dimaxum

  • Opening Word Files in pages

    Hi,
    Sorry if this has been asked before......
    I recently converted from PC to iMac and bought myself a copy of Pages as part of iWork which (for me) is much nicer than MS word. One question though, is there any rules about what you can and can't open in terms of PC created word .doc files? I did a bit of experimenting and found that files on a USB memory stick open fine but when I look at my old PC's files across the network I get a message saying unable to open. Do files need to be local i.e I need to transfer to my HD? Is there a setting I need to change etc.?
    Kind regards,
    Phil.

    i've had no problems opening word docs from any version including .docx in pages. however you can't save them in .docx format.
    i have also no experienced the problem you have with network files. i can open files on a network share in pages (be they word docs or pages documents) without issue.
    could it be someone was editing the word doc you tried to open or you opened the temp file created by doc for autosaving? i've noticed the new version of word on the pc does not do a good job of cleaning those temp files up and have tried opening a few of them myself.

  • Can't open Word files with Document To Go

    I have installed Document To Go but I can't open files from word. When I open the files there are some messenge at the screen said "This application Word To Go has attempted to open a coonection to a location inside the firewall and outside the firewall which is not allowed by your IT policy." Then after that came out this text"Permission to your files was denied.Please configure your application permission appropriately" Can you help me to solve this problem,please

    so?
    what happens after you have configured the permissions for WordToGo?
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • Open word file in desktop from SAP

    Halo ,
    I have a requirement in which I have got a word file in my desktop . I have the location path . Is there any FM in which I can give this Path so that it opens up the word file by itself.
    Moreover is there any way to execute the file in the application server.
    Regards
    Arshad

    Hello,
    You can use GUI_RUN for desktop. provide the file path in command parameter and execute it to invoke the file on desktop.
    Also, you can use WS_EXECUTE to open file on application server.
    " For desktop:
    CALL FUNCTION 'GUI_RUN'
      EXPORTING
        COMMAND          =
    *   PARAMETER        =
    *   CD               =
    * IMPORTING
    *   RETURNCODE       =
    *For application server:
    CALL FUNCTION 'WS_EXECUTE'
    * EXPORTING
    *   DOCUMENT                 = ' '
    *   CD                       = ' '
    *   COMMANDLINE              = ' '
    *   INFORM                   = ' '
    *   PROGRAM                  = ' '
    *   STAT                     = ' '
    *   WINID                    = ' '
    *   OSMAC_SCRIPT             = ' '
    *   OSMAC_CREATOR            = ' '
    *   WIN16_EXT                = ' '
    *   EXEC_RC                  = ' '
    * IMPORTING
    *   RBUFF                    =
    * EXCEPTIONS
    *   FRONTEND_ERROR           = 1
    *   NO_BATCH                 = 2
    *   PROG_NOT_FOUND           = 3
    *   ILLEGAL_OPTION           = 4
    *   GUI_REFUSE_EXECUTE       = 5
    *   OTHERS                   = 6
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Both the function modules are obsolute!
    Also, check for there alternatives.
    Thanks,
    Augustin.

  • Microsoft Word has disappeared from Macbook, I can't open word files

    Microsoft Word has disappeared from my MacBook, I can't open my Word files and need to asap. How do I fix this?

    Bernadette201 wrote:
    Not simple, on the other side of the world on job search and my install discs not with me. Any other suggestions?
    If Word is actually gone (apps don't just disappear) then you can download a copy of LibreOffice, it is free, and Word compatible.

Maybe you are looking for

  • Problems with playback in premiere cs6

    I downloaded the trial version of premiere onto my imac two days ago. The problem is that when I try to playback the material I have on my timeline, it just plays a few frames then stops. If I hit play again, the same thing happens.

  • Image resizing not looking as good as MS Paint?

    I can't figure out why, but for some reason Paint makes my resized images look better than Photoshop when saved. I've messed around with Photoshop's Image Size/Resampler, but none of the options I have used seem beat the quality I am seeing from Pain

  • Billing date for return orders

    Hi, when creating return order (RE), without reference to any SD document, the billing date is default as current date. But, when I create the return order, with reference to a billing document, the billing date is scheduled, based on the lead times

  • Subscription Notification hour

    Hello, When the user receive the subscription email the hour is get in GMT and we want the hour of ours country. How can I get the right hour? In the portal I can see the hour correctly. Thanks in advance for your answer Maria Teresa

  • Cover flow no longer works

    i've been using itunes for at least 5 years; never had a problem or issue come up.. but that all changed yesterday night, Cover Flow stopped working completely! I've uninstalled and reinstalled itunes, checked display settings and even reinstalled di