Urgent - Upload a file from Client to Server.
Need to load a file from the client machine to the Server running 9iAS Rel. 1 on a HP Unix Machine.
We are using Forms 6i. We have looked into the File Upload Utility demo code provided with Forms 6i - but have been unsuccessful in reusing it. PLS HELP
Duplicate post.
Upload a file from client to server by forms in E-Bussiness Suite R12
Re: Upload a file from client to server by forms in E-Bussiness Suite R12.
Similar Messages
-
To upload a file from client machine to server machine
Hi everybody!
Could anyone plz help me. I am struck in a problem
I want to transfer a file from client's machine to server but I am not able to upload
It is tranferring the file only to the local machine
I am using orielley package It is transferring files only to my local machine but not to the server .Can anyone correct it. It's very urgent
how to write the relative path for server
I am using this path and it is not uploading
MultipartRequest multi = new MultipartRequest(request, "../<administrator>:<dev2daask>@dev2:C:/123data/", 5 * 1024 * 1024);
Here is my code:
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.oreilly.servlet.MultipartRequest"%>
<%
try {
// Blindly take it on faith this is a multipart/form-data request
// Construct a MultipartRequest to help read the information.
// Pass in the request, a directory to saves files to, and the
// maximum POST size we should attempt to handle.
// Here we (rudely) write to the server root and impose 5 Meg limit.
MultipartRequest multi = new MultipartRequest(request, "../<administrator>:<dev2daask>@dev2:C:/123data/", 5 * 1024 * 1024);
out.println("<HTML>");
out.println("<HEAD><TITLE>UploadTest</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H1>UploadTest</H1>");
// Print the parameters we received
out.println("<H3>Params:</H3>");
out.println("<PRE>");
Enumeration params = multi.getParameterNames();
while (params.hasMoreElements()) {
String name = (String)params.nextElement();
String value = multi.getParameter(name);
out.println(name + " = " + value);
out.println("</PRE>");
// Show which files we received
out.println("<H3>Files:</H3>");
out.println("<PRE>");
Enumeration files = multi.getFileNames();
while (files.hasMoreElements()) {
String name = (String)files.nextElement();
String filename = multi.getFilesystemName(name);
String type = multi.getContentType(name);
File f = multi.getFile(name);
out.println("name: " + name);
out.println("filename: " + filename);
out.println("type: " + type);
if (f != null) {
out.println("length: " + f.length());
out.println();
out.println("</PRE>");
catch (Exception e) {
out.println("<PRE>");
out.println("</PRE>");
out.println("</BODY></HTML>");
%>you have not understood my point
how does this code will run on servlet when I want to upload a file from client's
machine to server machine
what I am doing is I am giving an option to the user that he/she can browse the file and then select any file and finally it's action is post in the jsp form for which I have sent the code
All the computers are connected in LAN
So how to upload a file from client's machine to server's machine
Plz give me a solution -
Transfer file from client to server using http
HI friends,
I want to transfer files from client to server...I tried that with the help of socket and rmi..........
But Http is only the best mechanism for my application..........
Without using servlets, how to transfer files with the help of http.....
Any help would be appreciated.......Google is your friend, and appearently www.jguru.com also:
http://www.jguru.com/faq/view.jsp?EID=160 -
How to upload file from client to server in servlets.
actually in my application i have to upload file from client m/c to server.
it is not possible through file i/p stream as fileStreams does not work on network. Please mail me if you have any solution to this.
Thank's in advance............Haii roshan
Pls go through this thread..
http://forum.java.sun.com/thread.jspa?forumID=45&threadID=616589
regards
Shanu -
Unload file from client to server in APEX
Hi All!
I have a file on a client computer.
I have my APEX application.
Do you know how to unload file from client computer to server in my APEX application ?
Best regards,
RomanSee if these links help:
http://download-east.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm#CJAHDJDA
http://concept2completion.net/c2/wwv_flow_file_mgr.get_file?p_security_group_id=727128741744148&p_fname=fileDownload.pdf
Doug -
How to upload file from client to server in jsp
hello , In my application i have a requirement to upload picture and from it save to picture one with origional size and another with 100 * 100 size
Hi,
Give destination path is server address. for that u use
application.getRealPath("/");
It will return the server path.
-regards
Anna -
Trasnfer File from Client to server
I am making a server printer where all the system can take print out from the Printer installed on the server
i am not able to send file from the client to the Server. I am Attaching the code Please Help me it is my college project.
Server.java*
import java.io.*;
import java.lang.*;
import java.net.*;
import java.util.*;
import java.io.File;
class Server
static final int PORT = 26548; //Server Listening port
static String path;
public static void main(String args[])
System.out.println("Starting Server");
receive();
public static void receive()
while ( true )
try
//Create a socket
ServerSocket srvr = new ServerSocket(PORT);
Socket skt = srvr.accept();
String clientname= skt.getInetAddress().getHostAddress();
int clientport=skt.getPort();
long time = System.currentTimeMillis();
path= "C:\\Ankit Gupta\\Programs\\"+clientname+"\\"+time+" test.pdf";
System.out.println("File Recieved from : "+clientname+" : "+clientport);
//HttpServletRequest req;
//String remoteHost = req.getRemoteHost();
//String adr = getRemoteUser();
FileOutputStream fos = new FileOutputStream(path);
BufferedOutputStream out = new BufferedOutputStream(fos);
BufferedInputStream in = new BufferedInputStream( skt.getInputStream() );
//Read, and write the file to the socket
int i;
System.out.println("Receiving data...");
while ((i = in.read()) != -1)
out.write(i);
out.flush();
in.close();
out.close();
skt.close();
srvr.close();
System.out.println("Transfer complete.");
printfile();
catch(Exception e)
System.out.print("Error! It didn't work! " + e + "\n");
try
Thread.sleep(1000);
catch (InterruptedException ie)
System.err.println("Interrupted");
} //end infinite while loop
public static void printfile()
delete();
public static void delete()
try
Thread.sleep(5000);
catch (InterruptedException ie)
System.err.println("Interrupted");
System.out.println("Deleting file");
File f = new File(path);
// Make sure the file or directory exists and isn't write protected
if (!f.exists())
throw new IllegalArgumentException("Delete: no such file or directory: " + path);
if (!f.canWrite())
throw new IllegalArgumentException("Delete: write protected: "+ path);
// If it is a directory, make sure it is empty
if (f.isDirectory())
String[] files = f.list();
if (files.length > 0)
throw new IllegalArgumentException("Delete: directory not empty: " + path);
// Attempt to delete it
boolean success = f.delete();
if (!success)
throw new IllegalArgumentException("Delete: deletion failed");
Client.java_
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class Client extends JFrame {
static final int PORT = 26548; //Server Listening Port
static File file;
static final String HOST = "10.35.9.152";//Server Address
JTextField m_fileNameTF = new JTextField(25);
JFileChooser m_fileChooser = new JFileChooser();
Client() {
m_fileNameTF.setEditable(false);
JButton openButton = new JButton("Open");
openButton.addActionListener(new OpenAction());
JPanel content = new JPanel();
content.setLayout(new FlowLayout());
content.add(openButton);
content.add(m_fileNameTF);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(content);
this.setSize(400,200);
class OpenAction implements ActionListener {
public void actionPerformed(ActionEvent ae) {
int retval = m_fileChooser.showOpenDialog(Client.this);
if (retval == JFileChooser.APPROVE_OPTION) {
file = m_fileChooser.getSelectedFile();
m_fileNameTF.setText(file.getAbsolutePath());
send(file.getAbsolutePath());
public static void main(String[] args) {
JFrame window = new Client();
window.setVisible(true);
public static boolean send( String filename )
try
System.out.println("Connecting to Server");
Socket skt = new Socket(HOST, PORT);
//Create a file input stream and a buffered input stream.
FileInputStream fis = new FileInputStream(filename);
BufferedInputStream in = new BufferedInputStream(fis);
BufferedOutputStream out = new BufferedOutputStream( skt.getOutputStream() );
//Read, and write the file to the socket
int i;
System.out.println("Connected to Server");
System.out.println("Sending data...\n");
while ((i = in.read()) != -1)
out.write(i);
//System.out.println(i);
System.out.println("Transfer complete.");
//Close the socket and the file
out.flush();
out.close();
in.close();
skt.close();
return true;
catch( Exception e )
send(file.getAbsolutePath());
return false;
}Edited by: Ankit__Gupta on Jul 24, 2009 1:59 AMthe network is working perfectly fineThe network is timing out your connect attempts so there is something wrong somewhere.
catch will give the error msg or the entire try block. but will it give for the exact line?Suppose you try it yourself and find out?
by the way i m catching the exception i m just not printing it.Yes I am aware of that, thanks, I can read, and that's exactly what I commented on, and by the way Java forces you to catch the exception, so there's no virtue in that. On the contrary. Catchingand ignoring the exception is why its taken five days to debug this simple problem. Never do that. -
Urgent - Uploading a file from HTML
How to dynamically set the value of a file (full path of the file with filename) to the tag input type=file?
In the usual scenario the user will select the file from the "Browse" button. Is this possible to set the value without choosing from "Browse" button?Urgent? You were in so much of a hurry, you didn't notice you posted a question about HTML in a Java programming forum.
-
How to upload file from client to server
Can someone please help.
User needs to browse file on his desktop and upload file using browse button. This file should then be uploaded to the server. I am using javascript in the front end and servlet in the back.
Any help will be highly appreciated.
Thanks,
IndrasishJakarta Commons FileUpload is the standard way of doing the file uploading these days. You can find source, binaries and documentation at the Jakarta Site http://jakarta.apache.org/ . The Commons has a number of subprojects, so start with the Commons libraries, then find FileUpload.
Brian -
JSP to Upload file from client machine to Web Server!
Hi,
I want to upload a file from client machine to web server in order to send it as email attachment, How can I do it? After uploading the file the class should give me the path where the file is stored on the web server and the file name in return!
I know the HTML <file> field but dont know how to copy it on web server, HTML Part will be:
<FORM ENCTYPE="multipart/form-data"
method="POST" action="My.jsp">
<INPUT TYPE="file" NAME="mptest">
<INPUT TYPE="submit" VALUE="upload">
</FORM>
Please help!
Thanks,
- RahulYou can use cos.jar provided by O'Reilly from http://www.servlets.com/cos/. Take a look at com.oreilly.servlet.multipart.* classes.
Package is provided with source, classes, documentation and, of course, ready-to-use jar file.
It is really usefull and - ready! -
firefox 7.0 - Can not upload the file from local machine to server...gives "error 404 : file not found"
you have not understood my point
how does this code will run on servlet when I want to upload a file from client's
machine to server machine
what I am doing is I am giving an option to the user that he/she can browse the file and then select any file and finally it's action is post in the jsp form for which I have sent the code
All the computers are connected in LAN
So how to upload a file from client's machine to server's machine
Plz give me a solution -
Error while uploading the file from Allpcation server in LSMW-7th step
Hi Experts,
what should be the specific CODE PAGE should be maintained while uploading the file from application server in LSMW-7th Step
Thanks in advance,
KSRHi
I mean that there is any seperate CODE PAGE which comes at the bottom of screen while uploading the file from the application server in 7th step.
Is there any specific CODE PAGE to be maintained...
Thanks in advance
Oarsk -
Upload tab-delimited file from the application server to an internal table
Hello SAPients.
I'm using OPEN DATASET..., READ DATASET..., CLOSE DATASET to upload a file from the application server (SunOS). I'm working with SAP 4.6C. I'm trying to upload a tab-delimited file to an internal table but when I try load it the fields are not correctly separated, in fact, they are all misplaced and the table shows '#' where supposedly there was a tab.
I tried to SPLIT the line using as separator a variable with reference to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB but for some reason that class doesn't exist in my system.
Do you know what I'm doing wrong? or Do you know a better method to upload a tab-delimited file into an internal table?
Thank you in advance for your help.Try:
REPORT ztest MESSAGE-ID 00.
PARAMETER: p_file LIKE rlgrap-filename OBLIGATORY.
DATA: BEGIN OF data_tab OCCURS 0,
data(4096),
END OF data_tab.
DATA: BEGIN OF vendor_file_x OCCURS 0.
* LFA1 Data
DATA: mandt LIKE bgr00-mandt,
lifnr LIKE blf00-lifnr,
anred LIKE blfa1-anred,
bahns LIKE blfa1-bahns,
bbbnr LIKE blfa1-bbbnr,
bbsnr LIKE blfa1-bbsnr,
begru LIKE blfa1-begru,
brsch LIKE blfa1-brsch,
bubkz LIKE blfa1-bubkz,
datlt LIKE blfa1-datlt,
dtams LIKE blfa1-dtams,
dtaws LIKE blfa1-dtaws,
erdat LIKE lfa1-erdat,
ernam LIKE lfa1-ernam,
esrnr LIKE blfa1-esrnr,
konzs LIKE blfa1-konzs,
ktokk LIKE lfa1-ktokk,
kunnr LIKE blfa1-kunnr,
land1 LIKE blfa1-land1,
lnrza LIKE blfa1-lnrza,
loevm LIKE blfa1-loevm,
name1 LIKE blfa1-name1,
name2 LIKE blfa1-name2,
name3 LIKE blfa1-name3,
name4 LIKE blfa1-name4,
ort01 LIKE blfa1-ort01,
ort02 LIKE blfa1-ort02,
pfach LIKE blfa1-pfach,
pstl2 LIKE blfa1-pstl2,
pstlz LIKE blfa1-pstlz,
regio LIKE blfa1-regio,
sortl LIKE blfa1-sortl,
sperr LIKE blfa1-sperr,
sperm LIKE blfa1-sperm,
spras LIKE blfa1-spras,
stcd1 LIKE blfa1-stcd1,
stcd2 LIKE blfa1-stcd2,
stkza LIKE blfa1-stkza,
stkzu LIKE blfa1-stkzu,
stras LIKE blfa1-stras,
telbx LIKE blfa1-telbx,
telf1 LIKE blfa1-telf1,
telf2 LIKE blfa1-telf2,
telfx LIKE blfa1-telfx,
teltx LIKE blfa1-teltx,
telx1 LIKE blfa1-telx1,
xcpdk LIKE lfa1-xcpdk,
xzemp LIKE blfa1-xzemp,
vbund LIKE blfa1-vbund,
fiskn LIKE blfa1-fiskn,
stceg LIKE blfa1-stceg,
stkzn LIKE blfa1-stkzn,
sperq LIKE blfa1-sperq,
adrnr LIKE lfa1-adrnr,
mcod1 LIKE lfa1-mcod1,
mcod2 LIKE lfa1-mcod2,
mcod3 LIKE lfa1-mcod3,
gbort LIKE blfa1-gbort,
gbdat LIKE blfa1-gbdat,
sexkz LIKE blfa1-sexkz,
kraus LIKE blfa1-kraus,
revdb LIKE blfa1-revdb,
qssys LIKE blfa1-qssys,
ktock LIKE blfa1-ktock,
pfort LIKE blfa1-pfort,
werks LIKE blfa1-werks,
ltsna LIKE blfa1-ltsna,
werkr LIKE blfa1-werkr,
plkal LIKE lfa1-plkal,
duefl LIKE lfa1-duefl,
txjcd LIKE blfa1-txjcd,
sperz LIKE lfa1-sperz,
scacd LIKE blfa1-scacd,
sfrgr LIKE blfa1-sfrgr,
lzone LIKE blfa1-lzone,
xlfza LIKE lfa1-xlfza,
dlgrp LIKE blfa1-dlgrp,
fityp LIKE blfa1-fityp,
stcdt LIKE blfa1-stcdt,
regss LIKE blfa1-regss,
actss LIKE blfa1-actss,
stcd3 LIKE blfa1-stcd3,
stcd4 LIKE blfa1-stcd4,
ipisp LIKE blfa1-ipisp,
taxbs LIKE blfa1-taxbs,
profs LIKE blfa1-profs,
stgdl LIKE blfa1-stgdl,
emnfr LIKE blfa1-emnfr,
lfurl LIKE blfa1-lfurl,
j_1kfrepre LIKE blfa1-j_1kfrepre,
j_1kftbus LIKE blfa1-j_1kftbus,
j_1kftind LIKE blfa1-j_1kftind,
confs LIKE lfa1-confs,
updat LIKE lfa1-updat,
uptim LIKE lfa1-uptim,
nodel LIKE blfa1-nodel.
DATA: END OF vendor_file_x.
FIELD-SYMBOLS: <field>,
<field_1>.
DATA: delim TYPE x VALUE '09'.
DATA: fld_chk(4096),
last_char,
quote_1 TYPE i,
quote_2 TYPE i,
fld_lth TYPE i,
columns TYPE i,
field_end TYPE i,
outp_rec TYPE i,
extras(3) TYPE c VALUE '.,"',
mixed_no(14) TYPE c VALUE '1234567890-.,"'.
OPEN DATASET p_file FOR INPUT.
DO.
READ DATASET p_file INTO data_tab-data.
IF sy-subrc = 0.
APPEND data_tab.
ELSE.
EXIT.
ENDIF.
ENDDO.
* count columns in output structure
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
columns = sy-index.
ENDDO.
* Assign elements of input file to internal table
CLEAR vendor_file_x.
IF columns > 0.
LOOP AT data_tab.
DO columns TIMES.
ASSIGN space TO <field>.
ASSIGN space TO <field_1>.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
SEARCH data_tab-data FOR delim.
IF sy-fdpos > 0.
field_end = sy-fdpos + 1.
ASSIGN data_tab-data(sy-fdpos) TO <field_1>.
* Check that numeric fields don't contain any embedded " or ,
IF <field_1> CO mixed_no AND
<field_1> CA extras.
TRANSLATE <field_1> USING '" , '.
CONDENSE <field_1> NO-GAPS.
ENDIF.
* If first and last characters are '"', remove both.
fld_chk = <field_1>.
IF NOT fld_chk IS INITIAL.
fld_lth = strlen( fld_chk ) - 1.
MOVE fld_chk+fld_lth(1) TO last_char.
IF fld_chk(1) = '"' AND
last_char = '"'.
MOVE space TO fld_chk+fld_lth(1).
SHIFT fld_chk.
MOVE fld_chk TO <field_1>.
ENDIF. " for if fld_chk(1)=" & last_char="
ENDIF. " for if not fld_chk is initial
* Replace "" with "
DO.
IF fld_chk CS '""'.
quote_1 = sy-fdpos.
quote_2 = sy-fdpos + 1.
MOVE fld_chk+quote_2 TO fld_chk+quote_1.
ELSE.
MOVE fld_chk TO <field_1>.
EXIT.
ENDIF.
ENDDO.
<field> = <field_1>.
ELSE.
field_end = 1.
ENDIF.
SHIFT data_tab-data LEFT BY field_end PLACES.
ENDDO.
APPEND vendor_file_x.
CLEAR vendor_file_x.
ENDLOOP.
ENDIF.
CLEAR data_tab.
REFRESH data_tab.
FREE data_tab.
Rob -
Uploading large files from applet to servlet throws out of memory error
I have a java applet that needs to upload files from a client machine
to a web server using a servlet. the problem i am having is that in
the current scheme, files larger than 17-20MB throw an out of memory
error. is there any way we can get around this problem? i will post
the client and server side code for reference.
Client Side Code:
import java.io.*;
import java.net.*;
// this class is a client that enables transfer of files from client
// to server. This client connects to a servlet running on the server
// and transmits the file.
public class fileTransferClient
private static final String FILENAME_HEADER = "fileName";
private static final String FILELASTMOD_HEADER = "fileLastMod";
// this method transfers the prescribed file to the server.
// if the destination directory is "", it transfers the file to
"d:\\".
//11-21-02 Changes : This method now has a new parameter that
references the item
//that is being transferred in the import list.
public static String transferFile(String srcFileName, String
destFileName,
String destDir, int itemID)
if (destDir.equals(""))
destDir = "E:\\FTP\\incoming\\";
// get the fully qualified filename and the mere filename.
String fqfn = srcFileName;
String fname =
fqfn.substring(fqfn.lastIndexOf(File.separator)+1);
try
//importTable importer = jbInit.getImportTable();
// create the file to be uploaded and a connection to
servlet.
File fileToUpload = new File(fqfn);
long fileSize = fileToUpload.length();
// get last mod of this file.
// The last mod is sent to the servlet as a header.
long lastMod = fileToUpload.lastModified();
String strLastMod = String.valueOf(lastMod);
URL serverURL = new URL(webadminApplet.strServletURL);
URLConnection serverCon = serverURL.openConnection();
// a bunch of connection setup related things.
serverCon.setDoInput(true);
serverCon.setDoOutput(true);
// Don't use a cached version of URL connection.
serverCon.setUseCaches (false);
serverCon.setDefaultUseCaches (false);
// set headers and their values.
serverCon.setRequestProperty("Content-Type",
"application/octet-stream");
serverCon.setRequestProperty("Content-Length",
Long.toString(fileToUpload.length()));
serverCon.setRequestProperty(FILENAME_HEADER, destDir +
destFileName);
serverCon.setRequestProperty(FILELASTMOD_HEADER, strLastMod);
if (webadminApplet.DEBUG) System.out.println("Connection with
FTP server established");
// create file stream and write stream to write file data.
FileInputStream fis = new FileInputStream(fileToUpload);
OutputStream os = serverCon.getOutputStream();
try
// transfer the file in 4K chunks.
byte[] buffer = new byte[4096];
long byteCnt = 0;
//long percent = 0;
int newPercent = 0;
int oldPercent = 0;
while (true)
int bytes = fis.read(buffer);
byteCnt += bytes;
//11-21-02 :
//If itemID is greater than -1 this is an import file
transfer
//otherwise this is a header graphic file transfer.
if (itemID > -1)
newPercent = (int) ((double) byteCnt/ (double)
fileSize * 100.0);
int diff = newPercent - oldPercent;
if (newPercent == 0 || diff >= 20)
oldPercent = newPercent;
jbInit.getImportTable().displayFileTransferStatus
(itemID,
newPercent);
if (bytes < 0) break;
os.write(buffer, 0, bytes);
os.flush();
if (webadminApplet.DEBUG) System.out.println("No of bytes
sent: " + byteCnt);
finally
// close related streams.
os.close();
fis.close();
if (webadminApplet.DEBUG) System.out.println("File
Transmission complete");
// find out what the servlet has got to say in response.
BufferedReader reader = new BufferedReader(
new
InputStreamReader(serverCon.getInputStream()));
try
String line;
while ((line = reader.readLine()) != null)
if (webadminApplet.DEBUG) System.out.println(line);
finally
// close the reader stream from servlet.
reader.close();
} // end of the big try block.
catch (Exception e)
System.out.println("Exception during file transfer:\n" + e);
e.printStackTrace();
return("FTP failed. See Java Console for Errors.");
} // end of catch block.
return("File: " + fname + " successfully transferred.");
} // end of method transferFile().
} // end of class fileTransferClient
Server side code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.net.*;
// This servlet class acts as an FTP server to enable transfer of
files
// from client side.
public class FtpServerServlet extends HttpServlet
String ftpDir = "D:\\pub\\FTP\\";
private static final String FILENAME_HEADER = "fileName";
private static final String FILELASTMOD_HEADER = "fileLastMod";
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
IOException
doPost(req, resp);
public void doPost(HttpServletRequest req, HttpServletResponse
resp)
throws ServletException,
IOException
// ### for now enable overwrite by default.
boolean overwrite = true;
// get the fileName for this transmission.
String fileName = req.getHeader(FILENAME_HEADER);
// also get the last mod of this file.
String strLastMod = req.getHeader(FILELASTMOD_HEADER);
String message = "Filename: " + fileName + " saved
successfully.";
int status = HttpServletResponse.SC_OK;
System.out.println("fileName from client: " + fileName);
// if filename is not specified, complain.
if (fileName == null)
message = "Filename not specified";
status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
else
// open the file stream for the file about to be transferred.
File uploadedFile = new File(fileName);
// check if file already exists - and overwrite if necessary.
if (uploadedFile.exists())
if (overwrite)
// delete the file.
uploadedFile.delete();
// ensure the directory is writable - and a new file may be
created.
if (!uploadedFile.createNewFile())
message = "Unable to create file on server. FTP failed.";
status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
else
// get the necessary streams for file creation.
FileOutputStream fos = new FileOutputStream(uploadedFile);
InputStream is = req.getInputStream();
try
// create a buffer. 4K!
byte[] buffer = new byte[4096];
// read from input stream and write to file stream.
int byteCnt = 0;
while (true)
int bytes = is.read(buffer);
if (bytes < 0) break;
byteCnt += bytes;
// System.out.println(buffer);
fos.write(buffer, 0, bytes);
// flush the stream.
fos.flush();
} // end of try block.
finally
is.close();
fos.close();
// set last mod date for this file.
uploadedFile.setLastModified((new
Long(strLastMod)).longValue());
} // end of finally block.
} // end - the new file may be created on server.
} // end - we have a valid filename.
// set response headers.
resp.setContentType("text/plain");
resp.setStatus(status);
if (status != HttpServletResponse.SC_OK)
getServletContext().log("ERROR: " + message);
// get output stream.
PrintWriter out = resp.getWriter();
out.println(message);
} // end of doPost().
} // end of class FtpServerServletOK - the problem you describe is definitely what's giving you grief.
The workaround is to use a socket connection and send your own request headers, with the content length filled in. You may have to multi-part mime encode the stream on its way out as well (I'm not about that...).
You can use the following:
http://porsche.cis.udel.edu:8080/cis479/lectures/slides-04/slide-02.html
on your server to get a feel for the format that the request headers need to take.
- Kevin
I get the out of Memory Error on the client side. I
was told that this might be a bug in the URLConnection
class implementation that basically it wont know the
content length until all the data has been written to
the output stream, so it uses an in memory buffer to
store the data which basically causes memory issues..
do you think there might be a workaround of any kind..
or maybe a way that the buffer might be flushed after
a certain size of file has been uploaded.. ?? do you
have any ideas? -
How to deploy Forms, Reports and Menu from Client to Server machine
Dear Experts,
I have one requirement to deploy the Forms, Reports and Menu from client machine to server machine.
Deployment involves the following steps :
1. Firstly we have to search the selected file in a folder where the .fmx is present ( in Server machine) and take the back up of the the existing file in the server (Source and destination paths will be available).
Ex. If the existing FMB name is TEST.fmx then the backup file should be TEST_sysdate.fmx.
2. Secondly we have to transfer the file from the client folder (or from another folder of the same server) to the server folder where the back up exists.
Please help me to search/rename/copy/replace the _.fmx/.rdf/.rep/.mmx_ files from client to server.
We are using
9i Database.
10g Forms and reports.
SQL Developer tool.
OS is Windows (Client and Server).
Help me out to attach a file of front end screen which we are planning to develop. It will give a clear picture on this requirement.
Thanks :)
Edited by: 941175 on Jun 17, 2012 9:09 AM
Edited by: 941175 on Jun 17, 2012 9:12 AM
Edited by: 941175 on Jun 17, 2012 9:14 AM941175
Welcome to the forum. Please take a while to go through the FAQ to be found to the top right of the page.
Your issue is more to do with batch files rather than Forms. The only relation with Forms, as I see it, is that you will be using HOST/CLIENT_HOST to start a batch file with the file name to be deployed as a parameter passed to it.
You need to rewrite either a CMD batch file or a Powershell script to achieve what have set out to do.
For CMD batch files look up http://www.robvanderwoude.com/battech.php , or any of the other excellent resources available on the internet.
Regards,
Maybe you are looking for
-
WHY CAN'T I SIGN IN!?!?
Okay, I can't take this anymore. I've been trying to log into my skype account on my laptop for over a year and it won't do anything for no reason. Every single time I try it makes it more complicated then it needs to be so I log in with my microsoft
-
Dynamic images in an interactive form
Hi all, in adobe lifecycle designer I created a table that displays information of specific materials from mara. The table exists of four columns. Three of these columns display the material information (matnr, mtart, mbrsh) and one column should dis
-
My InDesign file keeps failing to export to PDF
I can't understand why my file won't export as a PDF. My printer needs my file to be a PDF.
-
How to install an acoustic piano plugin
Hello! I'm a new user of adobe audition CS5. I have an acoustig guitar, after recording it I'd like to make it sound in different ways. I've already found and installed some plugins that let me distort it so it sounds like an electrical guitar. Now,
-
Offline unlock key--how do I get one for a Premier Elements 13 component?
Offline unlock key--how do I get one for a Premier Elements 13 component?