Uploading External Documents (*.doc, *.pdf, *.html) using JSP, Servlets, JDBC
I would like to upload external documents to an Oracle 8.16 db without using agents or interMedia.
Documents can range from *.doc, *.pdf, *.html and so forth. Ive been all over OTN and all I keep finding are examples on uploading Audio, Video or Image data - which is fine.. but damn, can we get a couple "Real World" examples in there?
Im even looking at iWorkplace which is excellent.. but a little out of my league when it comes to uploading external documents. But that's exactly what Id like to do. The documentation on this issue is very scarce - Please help.
Any help in this matter would be greatly appreciated.
Many Thanks in Advance.
Is anyone having problems loading text files using this routine? I can load a file with this, but even though the table contains a CLOB, the file is uploaded as binary and one only sees a series of question marks when looking at the CLOB. So, basically, the file appears to be converted somehow from text to binary. Any thoughts? I'm using 8.1.6.0.0 on Sun Solaris 2.7. character set in the database is UTF8.
Thanks.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Rick Post:
Steps you need to follow are:
1. Create a table to hold the documents
CREATE TABLE XML_DOCUMENTS (
DOCNAME VARCHAR2(200) NOT NULL,
XMLDOC CLOB,
TIMESTAMP DATE
2. Create a directory
CREATE OR REPLACE DIRECTORY bfile_dir AS /private1/LOB/files;
3. Grant READ privileges on the directory to the appropriate user
GRANT READ on bfile_dir to SCOTT;
4. Create a procedure
CREATE PROCEDURE insertXmlFile( dir VARCHAR2,
file VARCHAR2,
name VARCHAR2 := NULL) IS
theBFile BFILE;
theCLob CLOB;
theDocName VARCHAR2(200) := NVL(name,file);
BEGIN
-- (1) Insert a new row into xml_documents with an empty CLOB, and
-- (2) Retrieve the empty CLOB into a variable with RETURNING..INTO
INSERT INTO xml_documents(docname,xmldoc) VALUES(theDocName,empty_clob())
RETURNING xmldoc INTO theCLob;
-- (3) Get a BFile handle to the external file
theBFile := BFileName(dir,file);
-- (4) Open the file
dbms_lob.fileOpen(theBFile);
-- (5) Copy the contents of the BFile into the empty CLOB
dbms_lob.loadFromFile(dest_lob => theCLob,
src_lob => theBFile,
amount => dbms_lob.getLength(theBFile));
-- (6) Close the file and commit
dbms_lob.fileClose(theBFile);
COMMIT;
END;
5. Execute the procedure
INSERTXMLFILE('bfile_dir', filename, 'description');
Good Luck!
<HR></BLOCKQUOTE>
null
Similar Messages
-
How can i retrieve documents(e.g .doc,.pdf, .txt etc) using forms from the database.
i inserted the documents using sql*loader, below is the control and data files.
-- control file
LOAD DATA
infile 'load.txt'
INTO TABLE husman
APPEND
FIELDS TERMINATED BY ','
(id integer external,
fname FILLER CHAR(50),
docu LOBFILE(fname) TERMINATED BY EOF)
--data file
1,../husman/dell.doc,
2,../husman/me.pdf,
3,../husman/export.txt,
in the form i have a text field to display the id and an OLE container to display the document as an icon. but when i execute query, i only get the id number and not the document.
any help will be appreciated.
Thanks
Hussein SaigerStep by step
1. Erase all contents and settings
2. You'll be asked twice to confirm
3. You'll see Apple logo and progress bar
4. You'll see a big iPad logo on screen
5. Configuration start
6. Set language
7. Set country
8. Enable Location Service
9. Select network, enter password and join network
10. You'll be given 3 options (a) Setup as New iPad (b) Restore from iCloud Backup (c) Restore from iTune Backup
11. Selected Restore from iCloud Backup
12. You'll be required to enter Apple ID and Password
13. Agree to Terms and Conditions
14. Select Backup file
15. You'll see progress bar
16. Red slider will appear; slide to unlock; step #1 to #16 is fast
17. Pre-installed apps will be restored first
18. Message: Purchased apps and media will now be automatically downloaded
19. You'll see a pageful of apps with Waiting/Loading/Installing
20. Message: Some apps cannot be downloaded, please sync with computer -
File upload and download using jsp/servlets
How to upload any file to the server using jsp/servlets. . Help me out
You can also try the Jenkov HTTP Multipart File Upload. It's a servlet filter that is easy to add to your web-project. After adding it, you can access both request parameters and the uploaded files easily. It's more transparent than Apache Commons File Upload. There is sufficient documentation to get you started, and there is a forum if you have any questions.
Jenkov HTTP Multipart File Upload is available under the Apache license, meaning its free to use. -
How to upload an html file using jsp and jdbc
Hi,
im trying to upload an html page using JSP and jdbc. but of no success.
my aim is to keep some important html pages in the database.the file size can vary.the file has to be selected from a local machine (through the browser) and uploaded to a remote machine(where the databse resides).
any help/sample code or pointer to any helpful link is appreciated.
thanks in advance
javajar2003When uploading a file, I use a byte array as a temporary buffer..
So, you should then be able to store the byte array in the
database as binary data.
example>
//Temporary Buffer To Store File
byte[] tmpbuffer = new byte[860];
//Some Code To Upload File...
//File Should Now Be In Byte Array
//Get DB Connection and execute Prepared Statement
Connection con=//GET DB CONNECTION;
String sql=insert into TABLE(page) values(?);
PreparedStatement ps=con.prepareStatement(sql);
ps.setBytes(1,tempbuffer);
ps.executeUpdate();
//Close PS and Free DB Connection
..... and this method looks like you dont even have
to store the file in a byte array, you can just give
it the input stream.
ps.setBinaryStream(int, inputStream, int);
You may have to make several attempts at this. I have
uploaded a file and temporarily stored it in a byte array,
but have never from there stored it in the DB as binary
data.. but this looks like it'll work.
Good Luck! -
I am very new to this JDeveloper & BPEl Process , please could some one help in ersolving my problem that is , how to upload a file in BPEL Console Using JSP in JDeveloper.
Hi,
ADF Faces provides you with the file upload component
http://download-uk.oracle.com/docs/html/B25947_01/web_complex006.htm#CEGCEDHF
http://download-uk.oracle.com/docs/html/B25947_01/appendixa007.htm#CHDEDCFA
This gives you a handle to the file content. However, uploading files through a service is different and I suggest to consult teh BPEL forum for this BPEL
Frank -
Hi, I have a problem with filtering binary documents (.doc, .pdf, etc...). I use SQL*PLUS for remote access to Oracle 10.2 on Linux and I create table:
CREATE TABLE test (id NUMBER PRIMARY KEY, text VARCHAR2(100));
I insert to this table:
INSERT into test values(1, 'PATH/text1.doc‘);
INSERT into test values(2,'PATH/text2.doc‘);
and then:
CREATE INDEX test_index ON test(text) indextype is ctxsys.context
parameters (’datastore ctxsys.file_datastore
filter ctxsys.auto_filter’);
Message "Index created" is displayed, but objects: DR$test_index$I, DR$test_index$K, DR$test_index$N, DR$test_index$R and DR$test_index$P are empty => index wasn´t created probably.
I don´t know, where is bug, either bug is somewhere in this code or on the server (wrong installation oracle or constraint privileges). Do you know in what is bug?The following is an excerpt from the 10g online documentation. Note the items that I have put in bold.
"FILE_DATASTORE
The FILE_DATASTORE type is used for text stored in files accessed through the local file system.
Note:
FILE_DATASTORE may not work with certain types of remote mounted file systems.
FILE_DATASTORE has the following attribute(s):
Table 2-4 FILE_DATASTORE Attributes
Attribute Attribute Value
path path1:path2:pathn
path
Specify the full directory path name of the files stored externally in a file system. When you specify the full directory path as such, you need only include file names in your text column.
You can specify multiple paths for path, with each path separated by a colon (:) on UNIX and semicolon(;) on Windows. File names are stored in the text column in the text table.
If you do not specify a path for external files with this attribute, Oracle Text requires that the path be included in the file names stored in the text column.
PATH Attribute Limitations
The PATH attribute has the following limitations:
If you specify a PATH attribute, you can only use a simple filename in the indexed column. You cannot combine the PATH attribute with a path as part of the filename. If the files exist in multiple folders or directories, you must leave the PATH attribute unset, and include the full file name, with PATH, in the indexed column.
On Windows systems, the files must be located on a local drive. They cannot be on a remote drive, whether the remote drive is mapped to a local drive letter."
With accessible paths and files, you get something like:
SCOTT@orcl_11g> CREATE TABLE test (id NUMBER PRIMARY KEY, text VARCHAR2(100));
Table created.
SCOTT@orcl_11g>
SCOTT@orcl_11g>
SCOTT@orcl_11g> INSERT into test values(1,'c:\oracle11g\banana.pdf');
1 row created.
SCOTT@orcl_11g> INSERT into test values(2,'c:\oracle11g\cranberry.pdf');
1 row created.
SCOTT@orcl_11g>
SCOTT@orcl_11g> CREATE INDEX test_index ON test(text) indextype is ctxsys.context
2 parameters ('datastore ctxsys.file_datastore
3 filter ctxsys.auto_filter');
Index created.
SCOTT@orcl_11g>
SCOTT@orcl_11g> select count(*) from dr$test_index$i
2 /
COUNT(*)
608
SCOTT@orcl_11g> In the following, I used a non-existent path and non-existent file name, which produces the same results as when you use a remote path that does not exist locally.
SCOTT@orcl_11g> CREATE TABLE test (id NUMBER PRIMARY KEY, text VARCHAR2(100));
Table created.
SCOTT@orcl_11g>
SCOTT@orcl_11g>
SCOTT@orcl_11g> INSERT into test values(3,'c:\nosuchpath\nosuchfile.pdf');
1 row created.
SCOTT@orcl_11g>
SCOTT@orcl_11g> CREATE INDEX test_index ON test(text) indextype is ctxsys.context
2 parameters ('datastore ctxsys.file_datastore
3 filter ctxsys.auto_filter');
Index created.
SCOTT@orcl_11g>
SCOTT@orcl_11g> select count(*) from dr$test_index$i
2 /
COUNT(*)
0
SCOTT@orcl_11g> -
How to upload a file in BPEL Console Using JSP in JDeveloper, please help..
Please I am new to Jdeveloper and to BPEL Process of OASuite,I want to know , how to upload a file in BPEL process using JSP in Jdeveloper IDE.
The main aim is first we need to upload a file in JSP , it has to go to BPEL Process & it has to read the file & write the respective file in return to JSP through BPEL Process. Please I am in Urgent need of the Query , please help me ASAP.
Send to me response Please.....................................Hi,
I thin that you asked the same question before and I premember that I ointed you to the ADF BC developer guide and the SRDemo if your application uses JSF. For plain JSP - if you Google for: JSP and file upload then you find plenty of sources for JSP and Struts.
The remaining part is how to stiff the file into a BPEL service on the middle tier. For this I recommended to ask your question on the BPEL forum
BPEL
Note that the BPEL integration would be easier if it was done on the middle tier and not onthe client
Frank -
Upload video by using jsp/servlet
I'm using jsp/servlet to upload video file but I have a problem.
This error occurs for preparing SQL statement when I cast OraclePreparedStatement.
It is " Error : weblogic.jdbc.rmi.SerialPreparedStatement
at jsp_servlet._upload._jspService(_upload.java:185)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:263)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2390)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:1959)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)"
Please help me asap.
ThanksYou need to use the Oracle jdbc driver. Apparently, the Weblogic JDBC driver is being selected:
weblogic.jdbc.rmi.SerialPreparedStatement
The Oracle JDBC classes can be found in <ORACLE_HOME>/jdbc/lib/See <ORACLE_HOME>/jdbc/readme.txt for how to specify the correct class path in the application.
I would have thought that the oracle JDBC driver would have been selected (if in the classpath) or an exception would be raised if the Oracle JDBC driver was not found.... because the code should include:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
This should load the Oracle jdbc driver and classes, not the weblogic ones. IF the Oracle JDBC drivers are not found, an exception should be raised... -
Create login page using jsp, servlet & Oracle
hi,
i need the sample application for creating login page using jsp, servlet & Oracle,can you please post one sample application.
thanks
sonaSee
http://www.oracle.com/technology/products/jdev/collateral/papers/10g/adfstrutsj2eesec.pdf
Frank -
How do i Create charts using JSP/Servlet & Database
I have to create charts which shows the graph of stock exchange.
i have a database that keeps the data for creating charts.
But i did not know how to create charts using jsp-servlet.
Any Example might help me to go forward.
Any help will be really appreciated.
Please Advice me.JFreeChart - You can generate the charts then convert them to image formats (PNG and JPEG) all using the JFreeChart API
http://www.jfree.org/jfreechart/ -
Examination system using JSP/SErvlet and MySQL
Hi
I am new to JSP /servlet.
I am designing online examination system using JSP/Servlet and MySQL ,where multiple choice questions would be selected randomly from the database. After completion of the examination user gets the results ,also the results would be stored in the database for the future reference.
Can anyone guide me for this? If possible give me the code for similar type of application.
ThanksSounds like you want someone else to do your homework for you, did you not read this:
"This forum works so much better when you try to program the code yourself, then let us know where it doesn't work. Otherwise you learn very little, and we work a whole lot."
and this
"If you want free code, have you tried searching Google for it? You may want to consider looking for survey software. It will give you the question/answer capabilities then all you have to do is find a way to grade the survey (if you will)...
If you are using Tomcat as your server, which you probably are, there is a jdbc tutorial included in the documentation, that is the fastest way to set up your database.
As for your random selection, have a look at Math.random(), this is one way to generate random numbers, you will need an algorithm to convert this value (between 0.0 and 1.0) into a form that can be used to select information from your database. -
Any good books on web application using JSP/servlet?
Does anyone know good books on how-to build enterprise web application using JSP/servlet? Aside from the book "Head First JSP/Servlet". Development using Netbeans is more preferrable.
801264 wrote:
What about the free web server? JBoss or Glassfish or something else? I prefer web/application server that is fully compatible with JEE6 (unlike Tomcat that can't handle EJB). thanksI'm a JBoss user myself, so naturally I would advise that to you if I were ignorant. I'm not however, so in stead I'll tell you to investigate yourself and see which one you prefer. Nobody is going to tell you which one to use as there is no such thing as a 'better' or 'best' server. Just different servers each with different issues.
And the community edition of JBoss has had many issues in the past (because Red Hat of course wants to advise you to go to the enterprise platform which ain't cheap), but JBoss 5.1 was a rock solid piece of software that I have had zero problems with (after reading the odd forum or two). JBoss 6 builds on top of JBoss 5.1 and provides the full JEE6 web profile; this means it does NOT provide a certified 'full' JEE6 stack yet. This means nothing however as all the services you may need in an enterprise application are already there.
BTW: for simple servlet programming, don't neglect Apache Tomcat. Its a lightweight server that just works. -
Please let me know where I can find more information regarding iPlanet usage/deployment/configuring/tuning etc for support of technologies - like EJB, JSP/servlets, JDBC, connection pooling, XML, load balancing, JDBC & Transactions
(I have already read the 'Getting Started with the iPlanet Application Server' part five and six - http://developer.iplanet.com/appserver/testdrive/partfive.jsp and partsix.jsp)(I am using the ias testdrive version).Hi,
It's difficult to explain unless the J2EE architecture is understood. Also, explaining things like load balancing, Transactions, tuning, are bit vague and could blow the disk space of this site.
To get started, the best way is to test the sample applications and the best part is you don't require internet connection to follow each steps. Install iWS and iAS, open browser, type in http://hostname:port/ias-samples/index.html. You can find links to the sample applications bundled. Please follow the steps given on deploying the application. This will enable you to a higher level.
Regards
Ganesh .R
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support -
Using JSP/Servlet to write Word Document to BLOB
Hi
I need some help pls
When I use a normal class with a main method, it loads the word document into a blob and I can read this 100%.Stunning.
With a JSP/Servlet I cannot get the document out again. The "format" seems to be lost.
Any ideas,help greatly appreciated:
Here is the Main class that works:
package mypackage1;
import java.io.OutputStream;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.Writer;
import java.sql.Connection;
import oracle.jdbc.*;
import oracle.jdbc.OracleResultSet;
import oracle.sql.BLOB;
import org.apache.log4j.Logger;
import Util_Connect.DataBase;
public class TestLOB
//static final Logger logger = Logger.getLogger("test");
public TestLOB()
public static void main(String args[])
TestLOB testLOB = new TestLOB();
testLOB.TestLOBInsert("c:\\my_data\\callcenterpilot.doc");
public void TestLOBInsert(String fileName)
Connection conn = getConnection("wizard");
BLOB blob = null;
try
conn.setAutoCommit(false);
String cmd = "SELECT * FROM so_cs.testlob WHERE docno = 1 FOR UPDATE";
PreparedStatement pstmt = conn.prepareStatement(cmd);
ResultSet rset = pstmt.executeQuery(cmd);
rset.next();
blob = ((OracleResultSet)rset).getBLOB(2);
File binaryFile = new File(fileName);
System.out.println("Document length = " + binaryFile.length());
FileInputStream instream = new FileInputStream(binaryFile);
OutputStream outstream = blob.getBinaryOutputStream();
int size = blob.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;
while ((length = instream.read(buffer)) != -1)
outstream.write(buffer, 0, length);
instream.close();
outstream.close();
conn.commit();
closeConnection(conn);
catch (Exception ex)
System.out.println("Error =- > "+ex.toString());
private Connection getConnection(String dataBase)
Connection conn = null;
try
DriverManager.registerDriver(new OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:@oraclu5:1600:dwz110","so_cs","so_cs");
catch (Exception ex)
System.out.println("Error getting conn"+ex.toString());
return conn;
private void closeConnection(Connection conn)
if (conn != null)
try
conn.close();
catch (Exception se)
System.out.println("Error closing connection in get last imei"+se.toString());
Works fine:
Here is the display servlet: Works when main class inserts file
package mypackage1;
import java.io.InputStream;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.Writer;
import java.sql.Connection;
import oracle.jdbc.*;
import oracle.jdbc.OracleResultSet;
import oracle.sql.BLOB;
import org.apache.log4j.Logger;
import Util_Connect.DataBase;
public class DisplayLOB extends HttpServlet
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
static final Logger logger = Logger.getLogger(DisplayLOB.class);
public void init(ServletConfig config) throws ServletException
super.init(config);
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
//response.setContentType(CONTENT_TYPE);
//PrintWriter out = response.getWriter();
Connection conn = null;
PreparedStatement pstmt = null;
try
conn = getConnection("wizard");
//out.println("<html>");
//out.println("<head><title>DisplayLOB</title></head>");
//out.println("<body>");
//out.println("<p>The servlet has received a POST. This is the reply.</p>");
InputStream is=null;
oracle.sql.BLOB blob=null;
response.setContentType("application/msword");
//response.setContentType("audio/mpeg");
OutputStream os = response.getOutputStream();
String term = "1";
String query = "SELECT docdetail FROM testlob WHERE docno = 1";
pstmt = conn.prepareStatement(query);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
blob=((OracleResultSet)rs).getBLOB(1);
is=blob.getBinaryStream();
int pos=0;
int length=0;
byte[] b = new byte[blob.getChunkSize()];
while((length=is.read(b))!= -1)
pos+=length;
os.write(b);
}//try
catch (Exception se)
se.printStackTrace();
finally
try
pstmt.close();
catch (Exception ex)
System.out.println("Error closing pstmt "+ex.toString());
//out.println("</body></html>");
//out.close();
private Connection getConnection(String dataBase)
Connection conn = null;
try
conn = DataBase.getPoolConnection(dataBase);
catch (Exception se)
logger.fatal("Error getting connection: ",se);
return conn;
private void closeConnection(Connection conn)
if (conn != null)
try
conn.close();
catch (Exception se)
logger.error("Error closing connection in get last imei",se);
Here is JSP/Servlet
<%@ page import="org.apache.log4j.*"%>
<%@ page contentType="text/html; charset=ISO-8859-1" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
<title>Wizard SMS Interface</title>
<link rel='stylesheet' type='text/css' href='main1.css'>
<script language='JavaScript' src='copyright.js'></script>
</head>
<pre>
<%
//HTTP 1.1
response.setHeader("Cache-Control","no-cache");
//HTTP 1.0
response.setHeader("Pragma","no-cache");
//prevents caching at the proxy server
response.setDateHeader ("Expires", 0);
Logger logger = Logger.getLogger("co.za.mtn.wizard.administration.admin01.jsp");
%>
</pre>
<body>
<FORM ACTION="/WizardAdministration/uploadfile"
METHOD="POST"
ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="example">
<INPUT TYPE="SUBMIT" NAME="button" VALUE="Upload">
</FORM>
</body>
</html>
<font> <b>Copyright ©
<script>
var LMDate = new Date( document.lastModified );
year = LMDate.getYear();
document.write(display(year));
</script>
Mobile Telephone Networks.
<p align="left"><i><b><font face="Georgia, Times New Roman, Times, serif" size="1"></font></b></i></p>
package co.za.mtn.wizard.admin;
import java.io.InputStream;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.Writer;
import java.sql.Connection;
import oracle.jdbc.OracleResultSet;
import oracle.sql.BLOB;
import org.apache.log4j.Logger;
import Util_Connect.DataBase;
public class UploadFile extends HttpServlet
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
//static final Logger logger = Logger.getLogger(UploadFile.class);
public void init(ServletConfig config) throws ServletException
super.init(config);
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
String headerName = null;
Enumeration en = request.getHeaderNames();
try
while ( en.hasMoreElements() )
Object ob = en.nextElement();
headerName = ob.toString();
System.out.println("Value for headerNAme is >"+headerName+"<");
String aaa = request.getHeader(headerName);
System.out.println("Value for aa is >"+aaa+"<");
catch (Exception ex)
System.out.println("Error in extracting request headers"+ex.toString());
Connection conn = getConnection("wizard");
BLOB blob = null;
try
conn.setAutoCommit(false);
String cmd = "SELECT * FROM so_cs.testlob WHERE docno = 1 FOR UPDATE";
PreparedStatement pstmt = conn.prepareStatement(cmd);
ResultSet rset = pstmt.executeQuery(cmd);
rset.next();
blob = ((OracleResultSet)rset).getBLOB(2);
//File binaryFile = new File("h:\\callcenterpilot.doc");
//System.out.println("Document length = " + binaryFile.length());
//FileInputStream instream = new FileInputStream(binaryFile);
response.setHeader("Content-Type","application/vnd.ms-word");
String contentType = request.getContentType();
System.out.println("Content type received in servlet is >"+contentType+"<");
ServletInputStream instream = request.getInputStream();
OutputStream outstream = blob.getBinaryOutputStream();
int size = blob.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;
while ((length = instream.read(buffer)) != -1)
outstream.write(buffer, 0, length);
instream.close();
outstream.close();
conn.commit();
closeConnection(conn);
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
catch (Exception ex)
System.out.println("Error =- > "+ex.toString());
//out.println("</body></html>");
//out.close();
private Connection getConnection(String dataBase)
Connection conn = null;
try
conn = DataBase.getPoolConnection(dataBase);
catch (Exception se)
System.err.println("Error getting connection: "+se.toString());
return conn;
private void closeConnection(Connection conn)
if (conn != null)
try
conn.close();
catch (Exception se)
System.err.println("Error closing connection in get last imei"+se.toString());
This is what the display servlet is showing when the JSP/Servlet insert the document
-----------------------------7d31422224030e
Content-Disposition: form-data; name="example"; filename="H:\(your name) Skills Matrix.doc"
Content-Type: application/msword
�� ࡱ � > �� � � ���� � � ���������������������
Tks
Andrehello,
there are multiple documents out there, describing the oracle reports server setup. try doc.oracle.com for documentation.
also it is part of the online-documentation.
you need to install 9iAS enterprise edition. the server is pre-configured and will listen to the url http://yourserver/dev60cgi/rwcgi60.exe
passing only this url you will get a help-screen, describing the syntax.
regards,
the oracle reports team -
Convert external documents to PDF and print
Hi,
I have a SAP script and with some help from SDN I am at point where I can convert this SAP script to PDF using the function module below
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = BINFILESIZE
* BIN_FILE =
TABLES
otf = DATAB[]
lines = PDFTAB[].
Now my requirement is, let's say I have an external doc(word or excel) residing on my PC. I have complete path of this file in my hand. I want to convert this file to PDF and append it to the above PDFTAB[] and print to the printer 'TDDEST' as a single document.
Thanks,Hi,
use this code passing in v_url the complete path
START-OF-SELECTION.
SET SCREEN 100.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS'.
SET TITLEBAR 'T1'.
*running down the pbo for the first time,
*create the controls and their containers
IF my_main_container IS INITIAL.
CREATE OBJECT my_main_container
EXPORTING
container_name = 'CUSTOM_CNTL'
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
*create PDF Viewer object
CREATE OBJECT my_pdf_viewer
EXPORTING
parent = my_main_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
*could not create PDF Viewer
ENDIF.
*my_pdf_viewer->LANGU = 'IT'.
DATA: view_buttons_active TYPE char01 VALUE 'X',
v_url TYPE char255.
IF my_pdf_viewer->acrobat_vs_reader = ''.
view_buttons_active = 'X'.
ENDIF.
*create SAP toolbar for PDF Viewer
CALL METHOD my_pdf_viewer->create_toolbar
EXPORTING
tool_buttons = 'X'
view_buttons = view_buttons_active
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
*could not create toolbar
ENDIF.
*Open the PDF document
IF NOT my_pdf_viewer->html_viewer IS INITIAL.
CLEAR v_url.
v_url = file.
CALL METHOD my_pdf_viewer->open_document
EXPORTING
url = v_url.
IF sy-subrc <> 0.
SET SCREEN 1000.
MESSAGE i208(00) WITH 'Documento non presente: riprovare'.
ENDIF.
ELSE.
MESSAGE e208(00) WITH 'Impossibile aprire il documento'.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module EXIT-PROCESSING INPUT
text
MODULE exit-processing INPUT.
fcode = ok_code.
CLEAR ok_code.
CASE fcode.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " EXIT-PROCESSING INPUT
Maybe you are looking for
-
Can anyone help me please?
-
1 Source Account to Multiple HFM Accounts?
Is it possible to map a single source account to multiple hfm accounts in FDM? Currently, I have a 1 for 1 mapping. Source Account 1 => HFM Account 1 I have a situation where I would like to have a 1 to many mapping. Source Account 1 => HFM Account 1
-
How to view presentation in portrait mode?
I just bought Keynote for iOS, to present some of my app mockups, but was sadly surprised to learn that I can't rotate a presentation from landscape to portrait mode. My canvas is 640x960. Anyone know if Apple is aware of this, or if there is a worka
-
I'm trying to buy an app, but I have to put the answers to my security questions, and I don't temember them! And I don't have a verifying account to restablish my questions. I don't know what to do!
-
RFC Server (exe file)
I notice the list of process at windows task manager it have my rfc process = the number of click that i do on sap My question is : If i click 100 time or more does it will crack my system ? Does it can open connection and then close when it end of