in Web-oa system, document management seems to be indispensable, sometimes need to query some data from the database in some format output, and in the form of Word documents, and sometimes many word documents saved to the database in the Blob field of a table, The server then presents the picture file saved in the Blob field to the user. Search through the internet found little about this kind of article, now sorted up for your reference.
1 generates Word documents directly on the client side
A Word document on a JSP page is very simple, simply change the contenttype= "text/html" to Contenttype= "Application/msword charset=gb2312" and the code below :
<%@ page contenttype= "Application/msword charset=gb2312"%>
lets you make the contents of the original page appear in Word by setting.
If you need to download a Word document, simply add the following code to the JSP page:
<%
response.setheader ("Content-disposition", "Attachment;filename=filename.doc");
%>
where filename in Filename.doc is the file name of the Word document to download, it can be customized by <%=docName%> from line, as follows
<%
response.setheader ("Content-disposition", "Attachment;filename=<%=docname%>.doc");
%>
This provides a hint for the user to choose from the image shown below
Tips: If a programmer needs to build a Word document in a format that he or she has designed beforehand in Word, you can copy the word format and paste it into FrontPage, with the HTML code pasted into the JSP page.
2 The Word entity in the database exists in the client output
Here we only discuss Word document entities in a BLOB field in client output Oracle. The class Getblobbean is invoked, which provides the ability to remove the blob from Oracle, with the following code:
package yourpackage;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import oracle.sql.*;
import beans.yourbeanpackage. Getblobbean;
/**
* <p>title: </p>
* <p>description: </p>
* <p>copyright:copyright (c) 2004</p>
* <p>company: </p>
* @author not attributable
* @version 1.0
*/