How to pick up file to Import from server instead of client PC??
I have this code that picks up a file from client machine and processes the file . The code works fine when deployed on local tomcat deployment. But on remote server deployment , behaves differently . its looking for the file on the server How can I change the below code to look for the file on the client ??
Please help .. any suggetion will be greately appreciated..
Java code :
public String importProdCredit() throws Exception {
FileReader in = null ;
StringTokenizer st = null;
String record = null;
String[] fieldValue = new String[30];
BufferedReader br = null;
int x = 0 ;
FacesContext ctx = FacesContext.getCurrentInstance();
//HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
HttpServletRequest request = (HttpServletRequest) ctx.getExternalContext().getRequest();
Date currentDatetime = new Date(System.currentTimeMillis());
String StartTime = formatter.format(currentDatetime);
int maxMemSize = 900000;
long maxReqSize = 1000000000;
//String fileDir = "/home/working/tmp/";
boolean writeToFile = true;
//String fileName = "deals.txt";
String from = "";
String files = "";
String tmpStr = "";
String comment = "";
int num = 0;
// Check that we have a file upload request
boolean isMultipart = FileUpload.isMultipartContent((HttpServletRequest) request);
ServletOutputStream out = null;
// OPEN FILE
fileName = fileName.replaceAll("\"", "\\") ;
// added code for export pc_
File inputFile = new File( fileName );
try{
in = new FileReader(inputFile);
br = new BufferedReader(in);
} catch (FileNotFoundException ex ) {
ex.printStackTrace();
genUtils.displayError("Invalid file name or file does not exists");
return "-1";
JSP:
<%@ taglib uri="/WEB-INF/fmt-1_0.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/jsf_core.tld" prefix="f" %>
<%@ taglib uri="/WEB-INF/html_basic.tld" prefix="h" %>
<%@ taglib uri="/WEB-INF/c-1_0.tld" prefix="c" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href='<%= request.getContextPath() + "/theme/Master.css" %>' rel="stylesheet" type="text/css">
<link type="text/css" rel="stylesheet" href='<%= request.getContextPath() + "/theme/prodcredit.css" %>'>
<title>Trade Ledger Ajustment Import</title>
</head>
<body>
<script language="JavaScript">
<!--
javascript:window.history.forward(1);
//-->
</script>
<f:view>
<h:form id="TradeAdjustmentImportForm" >
<table width="900" class="tableform" >
<caption class="searchcaption" > Production Credits Deals File Import : <h:messages id="Messages" errorClass="errors" globalOnly="false"/> </caption>
<tbody>
<tr class="formtr" >
<td class="td" style="color: red"><strong>Enter File to Import</strong></td>
</tr>
<tr class="formtr">
<td nowrap align="left">
<h:outputText id="fileImportTxt" value="File Name : " />
<h:inputText id="fileName" value="#{ProdCreditUtilities.fileName}" styleClass="field-value" />
</td>
<td nowrap align="left">
<h:commandButton id="importFile" image="images/import.gif" styleClass="commandButton" action="#{ProdCreditUtilities.importProdCredit}" type="Submit" immediate="false" />
</td>
<tr><td> </td></tr>
</tbody>
</table>
BufferedReader br = null;
int x = 0 ;
FacesContext ctx = FacesContext.getCurrentInstance();
//HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
HttpServletRequest request = (HttpServletRequest) ctx.getExternalContext().getRequest();
Date currentDatetime = new Date(System.currentTimeMillis());
String StartTime = formatter.format(currentDatetime);
int maxMemSize = 900000;
long maxReqSize = 1000000000;
//String fileDir = "/home/working/tmp/";
boolean writeToFile = true;
//String fileName = "deals.txt";
String from = "";
String files = "";
String tmpStr = "";
String comment = "";
int num = 0;
// CHECK THAT WE HAVE A FILE UPLAOD REQUEST
boolean isMultipart = FileUpload.isMultipartContent((HttpServletRequest) request);
ServletOutputStream out = null;
// OPEN FILE TO DO PROCESSING
fileName = fileName.replaceAll("\"", "\\") ;
// added code for export pc_
File inputFile = new File( fileName );
try{
in = new FileReader(inputFile);
br = new BufferedReader(in);
} catch (FileNotFoundException ex ) {
ex.printStackTrace();
genUtils.displayError("Invalid file name or file does not exists");
return "-1";
JSP file
<f:view>
<h:form id="TradeAdjustmentImportForm" >
<table width="900" class="tableform" >
<caption class="searchcaption" > Production Credits Deals File Import : <h:messages id="Messages" errorClass="errors" globalOnly="false"/> </caption>
<tbody>
<tr class="formtr" >
<td class="td" style="color: red"><strong>Enter File to Import</strong></td>
</tr>
<tr class="formtr">
<td nowrap align="left">
<h:outputText id="fileImportTxt" value="File Name : " />
<h:inputText id="fileName" value="#{ProdCreditUtilities.fileName}" styleClass="field-value" />
</td>
Can you help me change this code to work with <input type="file">
I am not that familiar with JSP and HTML . I am a database coder trying to get this fixed.
Your help is greatly appreciated.
Thanks
Ricky
Similar Messages
-
How to transfer mp3 files to 4s from a PC without itunes?
How to transfer mp3 files to 4s from a PC without itunes?
No can do. Closest you can do is to use iCloud and iTunes Match. Otherwise, for mp3 files you will have to import them to iTunes on the computer and then sync them to the phone.
-
How to upload a file in bdc from application server
how to upload a file in bdc from application server
Hi
Check if this is useful and reward.
PERFORM UNIX_UPLOAD.
FORM unix_upload.
DATA : lv_string(600) TYPE c.
lv_string = p_fname. "p_fname is the filename in path
OPEN DATASET lv_string FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
MESSAGE 'File Not Found' TYPE 'I'.
LEAVE PROGRAM.
ENDIF.
DO .
READ DATASET lv_string INTO gs_gfile.
IF sy-subrc NE 0 .
EXIT.
ENDIF.
APPEND gs_gfile TO gt_gfile .
CLEAR gs_gfile .
ENDDO.
CLOSE DATASET lv_string.
CLEAR lv_string.
DATA: lc_split TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
LOOP AT gt_gfile INTO gs_gfile .
SPLIT gs_gfile AT lc_split INTO
gs_ipfile-field1
gs_ipfile-field2.
ENDLOOP.
ENDFORM. "unix_upload
here gs_ipfile is the same structure as your input file to upload
and
gs_gfile is the work area of the internal table containing characters as :
TYPES : BEGIN OF ygs_gfile ,
data(600) ,
END OF ygs_gfile .
*Internal table declaration for input file as text
gt_gfile TYPE STANDARD TABLE OF ygs_gfile INITIAL SIZE 0 ,
*Work area declaration for input file
gs_gfile TYPE ygs_gfile .
Thanks and Regards
A Swarna -
How did my stored files get converted from 'open with Adobe READER' to 'open with Adobe ACROBAT'? How can I get them re-set to open with 'Adobe Reader'?
Please reply to my e-mail: [email protected]It sounds as if you downloaded Adobe Acrobat Pro. If you did, uninstall it. Then repair Adobe Reader.
The free Acrobat account has no connection to any of this. -
How do I transfer files and data from my Samsung Galaxy tab 2 to my Macbook Air?
How do I transfer files and data from my Samsung Galaxy tab 2 to my Macbook Air? The Macbook does not even recognize the device. I get an error message. I follow the instructions on the message, which tells me to install "Kies" and Android file transfer. This does not help. What do I do?
See:
iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device -
How do I transfer files and pictures from my blackberry to my mac
how do I transfer files and pictures from my blackberry to my mac. My mac does not seem to recognize my blackberry as a devise
Sounds like a question for Blackberry.
Check your manual or the Blackberry support site, or Google. -
I have a analog to DV converter that I have had for years, but I have not used it for awhile, and I am using a newer MAC. How do I get it to import from my converter. When I go to import in iMovie it is only showing the built in camera. Help...
Does the iOS device connect to other networks? If yes that tend to indicate a problem with your network.
Does the iOS device see the network?
Any error messages?
Do other devices now connect?
Did the iOS device connect before?
Try the following to rule out a software problem:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Power off and then back on your router
.- Reset network settings: Settings>General>Reset>Reset Network Settings
- iOS: Troubleshooting Wi-Fi networks and connections
- Wi-Fi: Unable to connect to an 802.11n Wi-Fi network
- iOS: Recommended settings for Wi-Fi routers and access points
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device.
If still problem and it does not connect to any networks make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
Apple Retail Store - Genius Bar -
How can I send files via Bluetook from my Tour to other phones?
How can I send files via Bluetook from my Tour to other phones?
I have even been able to pair to the other device, but I don't see the option to send/copy/move files through Bluetooth.
I can only send my Address book via bluetooth.
Please help!!Hi and Welcome to the Community!
See this KB:
KB05409 Transfer a file using Bluetooth technology between two BlackBerry smartphones
Substitute, in the KB, the appropriate instructions for your other device in place of the KB section for the receiving device. Be aware that RIM only supports BT file transfer between BBs...with other devices is technically unsupported. But, it usually works, as long as the two devices are paired, trusted to each other, and each have all of the correct BT services enabled for the configuration of the other device.
Good luck and let us know!
Occam's Razor nearly always applies when troubleshooting technology issues!
If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
Join our BBM Channels
BSCF General Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
How to find the file that delete from time capsule?
How to find the file that delete from time capsule?
I mean I saved JPEG file in Time capsule and unfortunately delete the file. Can I get it back
IF.... .no other backups have occured since you deleted the file, you might be able to retrieve it using an application like Disk Warrior. It's about $100 as I recall, and there are no guarantees that it will work.
DiskWarrior 4 - The Disk Utility for Mac Disk Repair, Mac Directory ...
Any of the free or low priced utilities that you might see or try will not be able to retrieve a deleted file from a Time Capsule.
If any backups have occured since you deleted the file, the deleted file has almost certainly been overwritten. No way to retrieve it in that case. -
How do I transfer files and apps from my 3rd generation iPod touch to my 5th generation iPod Touch?
See:
iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device -
Copy a .swf file from server side to client using signed applet
Hello All,
I already have my applet signed and its working pretty well. However I want to know how can I import a .swf file into clients machine. The .swf file initially is on server side, my applet checks whether this .swf file exists already on client machine. If not it copies it to his machine.
I know how to chk if the file already exits on client machine but I am not sure how to copy this .swf file to his machine if its missing.
May be I need to set some input buffers from server side and then copy them to his machine.
Can some one throw some light on this issue ??Hello to all Java Code Masters out thr,
I am trying to copy a .swf file from server side to client side, however I am unsuccessful in writing the correct data. By correct data I mean that , the data does gets saved on the client side in the .swf file, and the size of the .swf file on client side is as expected, but some how I don't know why the data is not the same as expected.
I tried opening up both the swf file, one which is on server side and the other which is on client side. And both looked different in the notepad.
When I opens up the client side .swf file on browser it shows nothing while the .swf file on server side worked fine.
Here is a snap shot of the two .swf files when opened in notepad:
clientside.swf
坃ࡓ죃鱸뷤瀉�ᡚ穸s歒斷뛉쭬ⶲ뉯緤░뉋쭬틲��毳띵뺤畮祮୹釯烉쉍‼➀Ƿℵ㼤ꦅ㼌⡉⁈ș㖩䈼ꦓɊጵꨘ妆ၸ쇠鳳ﯯ龜괯䪅�쿾칿칷컹緶履殖㋿罣쯻杬�懨�E�翂䶙幷鿠︡拡ﬦ댨꾖政ᯋὣꯤ糥䧩缿䨗捫嶺깼瘶羋⯞勹쪾癞ঞ頁韧୘롻ⱖ撯貊攗閩㫙↳萰Ⳁ⼈쳂荡᧰ﻶ顠꓈鸎싔㿄㰧柂䪄러䂀좹㏠ꕊ㌏힟䘜㦴⌙⍈㽾ꙴ㿯렑㽔serverside.swf
CWS�� x��� p��ZxzS�Rk�e��l��-o��}�%K�l�������]��ku���nu��nyy���pM�< �'�5!$����I
(H �
5<B
��J5��Yx��������/����J������w����}���
k�2c��lg���a��\�%��serverside.swf is what I expect to be saved, but clientside.swf is what i get.
Below is a code snippet which I am trying :
public void writeswftoclient(String swfcontent) {
String userHome = System.getProperty("user.home" );
String ImoracleDirectory = userHome + "\\MyFolder";
File fdirectory = new File(ImoracleDirectory);
if(!fdirectory.isDirectory()) {
fdirectory.mkdir();
String playlist = ImoracleDirectory + "\\clientside.swf";
File fplaylist = new File(playlist);
try {
Writer output = null;
output = new BufferedWriter(new FileWriter(fplaylist,true));
*System.out.println(swfcontent);*
*output.write(swfcontent);*
output.close();
catch (Exception e) {
System.out.println("Cannot create or write to the playlist");
}In above code I am trying to write the string swfcontent, which contains the data shown above in serverside.swf, to clientside.swf.
Interesting thing is that I am doing System.out.println(swfcontent); just before writing the data to clientside.swf using output.write(swfcontent);. And System.out.println does print the write data on the java console. However I dont know out of what reason the data doesnt get written correctly on the client's computer.
Kindly help me in this plzzzzzzzzzz. -
Import from Server Tabular Project creating a new Tabular DB?
Hi,
I have a Tabular database on a server want to make some changes to it, for that I have imported Tabular DB through BIDS and trying to makes changes, and what I see is every time I import the tabular DB its creating a New DB on the server with <DBName><UserName><GUID>.
Is this the Tabular Model behavior or an I missing anything here?
How to make the changes to the existing Tabular?
ThanksHi SQL_Gun,
According to your description, you want to modify an existing tabular database. Right?
In Analysis Services Tabular mode, once the "Import from Server" project is created, the Workspace database will appear in the Analysis Services instance specified in the
Workspace Server property. The name cannot be set in the Properties window. The default setting of Workspace database is the project name, followed by an underscore, followed by the username, followed by an underscore, followed by a GUID. In this
scenario, I suggest open the original project which created that tabular database. Modify the project and redeploy it.
Reference:
Workspace Database (SSAS Tabular)
If you have any question, please feel free to ask.
Simon Hou
TechNet Community Support -
How to open a file created at the server through form/report at client end
How to open a file created at the server through form/report at client end
Dear Sir/Madame,
I am creating a exception report at the server-end using utl file utility. I want to display this report at the client end. A user doesn't have any access to server. Will u please write me the solution and oblige me.
Thanks
Rajesh JainOne way of doing this is to write a PL/SQL procedure that uses UTL_FILE to read the file and DBMS_OUTPUT to display the contents to the users.
Cheers, APC -
How to run ear file in java application server
i want how to run .ear file in java application server
1. i m created ear file
2. i m created jar file (bean,home,remote)
3.i m created war file(in the form of jsp)
but till now i couldnt run ear file
how to run
please hel meYou must create :
1.Jar file
2.War file
And then put them into an ear file
Exemple : myapp.ear contains
myappEJB.jar
myappWEB.war
META-INF/application.xml
and application.xml looks like this :
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>myapp</display-name>
<description>Demo application</description>
<module>
<ejb>myappEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>myappWAR.war</web-uri>
<context-root>/myapp</context-root>
</web>
</module>
</application>Good luck -
How can i dispaly an Error Message from Server Side To form
Hi All,
How can i dispaly an Error Message from Server Side To form side .
i try several ways nothing succed.
i put the error in stack and after call the procedure from form i added
Qms$Trans_Errors.Display_Messages;
and because it is an error not informantional error the error screen displayed and enter
in infinite loop acts like flashing .
can any one help me please i use C/S Headstart6i and Designer 6i
thanks alot
radihi,
thanks alot lauri.
yr code work only using information message but in error message its still the same .
the error window still flash and enter in infinite loop of executeing the same triggers.
thanks again
radi
Maybe you are looking for
-
Need help with jdbc and cursor
Hi all, I know I can specify a cursor to be scrollable with cs = conn.prepareCall("{call server.procedure(?,?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); but my problem is that this cursor is returning 2 oracle cursors and I nee
-
Drivers for Windows 7 64-bit for HP Pavilion 15-p125ng
Can any one help me with Drivers for Windows 7 64-bit for HP Pavilion 15-p125ng? I'll be very grateful for any answers This question was solved. View Solution.
-
Unable to connect to localhost Windows 7 x64, CF9 x64
I've been following along with the Lynda.com tutorial on ColdFusion Builder. Everything went smoothly until the part where I'm supposed to attach CFB to the localhost. The Lynda.com presenter is on a Mac. I am running 64-bit Windows 7 and 64-bit Cold
-
Add storage location field into report COOIS
When i check the Production order Storage Location is showing under Goods receipt Tab.When i execute the order COOIS Storage location field is empty. Where and what to configure to pull storage location into report COOIS? Thanks Rafi
-
Forgot the answers to my security questions how do I recover the answers
Forgot the answers to my security questions how do I recover the answers