Implementing File Upload component + Java Mail
Guys,
Brief Intro : I have a form with some input fields. Upon submission of the form all the necessary information is submitted ro R/3 system and a mail is send to lets say administrators. I have Java Mail program for sending emails.
My requirement : I want the users to give the FileUpload option in the form so that they can select the file and that file should be attached to email whcih I am sending upon form submission.
Questions:
1) How to check the path of the file where it gets uploaded.
2) Does it get uploaded on the Server where I deploy my application.
3) Any Solution/suggestion on how to implement the requirement stated above.
Regards,
<b>Chintan Virani.</b>
Hi Chintan...
File Uplaod UI Element is just to get the file path of the file from the client or presentation server i.e. our pc. Rest code to store the data is done in action of the upload button (not the browse button). So no file is formed automatically.
Unless you write the code to read the file from the path selected, you cannot get the data bytes and unless you mention the path no file is made in the server.
Better would be that you keep a file template in the mimes folder and at runtime you write to this file.
The path of the file in the mimes folder is
temp
webdynpro
web
local
<ProjectName>
Components
<Component Package>
<File Name>
This file can be attached to your mail as an attachement.
Further reference...
Re: how to create a file i mimes/ components folder
Regards,
Mahesh K.
Similar Messages
-
How to use file upload component inside a portlet
Hi
Thank you for reading my post.
does file upload works inside portlets ?
can some one help me with a sample code , does it need some tricks ?
Thank youany help is welcomeLegolas,
You could try your own implementation. Someone was able to implement a file upload with Creator 2004Q4 and the O'Reilly Servlet. See http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=50186.
You will have to configure O'Reilly Servlet's "MultiPart Filter" in your application. Creator 2 uses a same approach (a filter) to accomplish this. Given that the file upload component is not supported on portlets, this leads me to the following: I don't know anything about portlets and portlet containers, but I'd check first for some architechtural restriction in the portlet subsystem that avoids the use of a filter for a file upload. If think this could be the only thing that will restrict you to implement your own file upload.
Hope this helps.
Antonio -
Screen hangs when user types in some text in file upload component
Dear All
I am using file upload component in webdynpro java in a custom application and added some validation logic on the file
selected. This is being used to upload jpeg files to KM repository. Now the issue is if user types some text in the file
upload input field and click on upload button the screen hangs and it goes to infinite loop. It seems that the framework is not able to accept and check the arbitrary value entered by user.
Can anyone tell me how this can be sorted out?
Thanks
SudipHello Sudeep,
I have also faced the same issue and to me it seems an issue with the UI element itself. Please follow the following threads for more information:
[http://help.sap.com/saphelp_nw04s/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm]
and
[File Upload UI Element going in Infinite loop;
[upload UI element;
Hope this may be of some use.
Regards,
Gaurav -
Validator for file upload component is not working !!
This validator method for a file upload component is throwing a java.lang.NullPointerException.
public void fileUpload1_validate(FacesContext context, UIComponent component, Object value) {
long size= fileUpload1.getUploadedFile().getSize();
if (size>65535){
throw new ValidatorException(new FacesMessage("Your image is too big!"));
Any help to solve this problem is very much appreciated.
Thanks.Hi i have a fileUpload in a pop-up and the methods are :
public void fileUpload1_validate(FacesContext context, UIComponent component, Object value) {
try {
com.sun.rave.web.ui.model.UploadedFile uploadedFile = ((Upload)component).getUploadedFile();
long l_filesize = uploadedFile.getSize();
if ( l_filesize > 1000000)
throw new ValidatorException(new FacesMessage("File Size should be less than 1000000 bytes! It is" + l_filesize));
else {
String tipo = uploadedFile.getContentType();
if ( tipo.compareTo("application/word") == -1 )
if ( tipo.compareTo("application/rtf") == -1 )
if ( tipo.compareTo("application/pdf") == -1 )
throw new ValidatorException(new FacesMessage("Error : los tipos de archivo aceptados son PDF, WORD y RTF"));
} catch (Exception ex) {
this.mauvaisFichier = true;
error(ex.getMessage());
public String botonValidar_action() {
if ( !this.mauvaisFichier )
if ( this.fileUpload1.getUploadedFile() != null )
if ( this.fileUpload1.getUploadedFile().getSize() > 0 )
try {
this.getSessionBean1().getComunicacion().setArchivo( new javax.sql.rowset.serial.SerialBlob(this.fileUpload1.getUploadedFile().getBytes() ) );
this.getSessionBean1().getComunicacion().setTipoArchivo( this.fileUpload1.getUploadedFile().getOriginalName().substring(this.fileUpload1.getUploadedFile().getOriginalName().length() - 3 ) );
} catch(Exception e){
e.getMessage();
return null;
I have to put a boolean value because the first time, validation code doesn't function ( the method botonValidar_action() is called ) correctly. The error message appears but empty.
If I try next time then it's ok.
Thx for any issue. -
Htmlb table - File upload component
Hi all,
Is it possible to use the file upload component in a table view (htmlb for java) column?
Rgds,
SubuHi,
Here is one thought, there is onCellClick event for the Tableview, use that for the required column and add the file upload component as the event handler method in the onCellClick method.
Link on table view events:
<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/eb/220a415a47f06fe10000000a1550b0/content.htm">Table view attributes and events</a>
Link on OnCellClick:
<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/37/3d8b41b4b3b25fe10000000a1550b0/content.htm">onCellClick</a>
Check the following link:
<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/63/9c0e41a346ef6fe10000000a1550b0/frameset.htm">File upload</a>
Hope it helps.
Regards,
Vivekanadan
Message was edited by: Vivekanandan -
File upload component in JStudio Enterprise
Dear all,
I am not sure that File Upload Component is supported in JStudio Enterprise 8.1 or not. I see that Netbeans has one: http://www.netbeans.org/kb/55/vwp-about_components.html.
So I thought JStudio Enterprise may have one similar. If so, can anyone tell me how to do that please?
Regards,
KaiFileUpload component is not supported in Java Studio Enterprise. The FileUpload is a component that conforms to the spec recognized by Java Studio Creator line of products (which is now Visual Web Pack) and will not work in JSE.
You can use NetBeans 5.5 and install Visual web pack (for javafaces support), enterprise pack (which provides all capabilities of JSE) and uml on top of it. It would give you a single install with all add-ons. -
File upload component and text area issue
Hi guys,
I have static text, text area and button on the same page. Text area binded to session bean value and all works fine (I can input text into text area and press button to save changes).
After adding file upload component to the same page I have got a problem - now after page refreshing the non english characters inside text gets trashed.
Other non english characters - inside static text components remains the same - the problem relates only to text area.
It looks like file upload component code has an encoding related bug. Is that a known issue?
And may be somebody have a workaround?
Thanks.Hi Rom@n,
I did some checking and this issue is currently logged as: 6442528. It is scheduled to be available in the next patch release. I'm sorry I don't have a time frame for the patch since it is still waiting for other fixes.
Sorry for the inconvience.
Lark
Creator Team -
Hot to call processValueChange() method of the file upload component?
When the value changes (when I choose a new file to upload) in the file upload component the processValueChange() method is not called.
I am planing to show the preview of the image to be uploaded using the processValueChange().
Thanks.Is there a bug connected with this issue?
Thanks. -
Irritating bugs in file upload component !!
Bug 1
During a postback operation the text (file path name) in the file upload component is cleared ! When a resubmit of a form is required, the user has to re-browse the file again.
Bug 2
The processValueChandge() method is never called when the value in the file upload component is changed (and the mouse is clicked outside the component).
Any suggestions or workarounds are very much appreciated.
Thanks.I can't answer to Bug 1. That is, I don't have any solutions. If you want to submit this, go to http://developers.sun.com/prodtech/javatools/jscreator/support/index.html and look at the section titled Bug Report /Feature Request
Bug 2
The processValueChandge() method is never called when
the value in the file upload component is changed
(and the mouse is clicked outside the component).This is not a bug.
processValueChange methods are server side methods and do not get called until the page is submitted to the server. Clicking outside the component will not cause the page to get submitted. If you want a client-side action (such as when focus is lost) then you can add some JavaScript.
The file upload does not have a process value change method, it is an action method and thus has a uploadFileButton_action method. This method gets called when the upload button is clicked. -
I can not find a function in the Upload class that will allow me to access the browse button
child component nor can I see any mention of the file upload component in the
master stylesheet of the defaulttheme jar.
what am i missing here guys?Dear Manjunath Jayaram,
You don't think it is a problem that one can not access the child of a
composite component ???
I am sorry if you don't appreciate the problem but I can not state it any more plainly.
"I can not find a function in the Upload class that will allow me to access the browse button
child component nor can I see any mention of the file upload component in the
master stylesheet of the defaulttheme jar". -
Myfaces's file upload component
I used the myfaces's file upload component in my web application. But this component needs to set the form's enctype attribute to "multipart/form-data". But after I have set this attribute, my other components in the form seemed doesn't work anymore. Is there any way to solve this problem? Thank you
Some people seem to be running into this. Doing these steps should fix the problem:
Right click the component library node "Basic" and choose "Manage Component Libraries". That opens the Component Library Manager window. Verify that the "On Palette" property is checked for "File Upload".
Hope it helps,
Lark -
File Upload Pluggable Java Component / Java Bean
Dear Colleague,
I integrated the File Upload java bean into one of my Forms 9i forms. I also had it up and running (!!!), but after I rebooted the machine, I no longer receive the File Upload dialog window as I did originally. When I press the button which starts the File Upload, it never displays the window to select a file. My trigger is as follows:
begin
/* Initialize the Java Bean */
FileUploader.init('DOCU_BLOCK.FILE_UPLOADER','LOAD_CALLBACK_TRIGGER');
/* Make sure the file is compressed on upload */
FileUploader.setCompressed(true);
/* Do the load to the c:\rolic\RKMS_documents\ directory on the server */
FileUploader.UploadFile (:PARAMETER.file_destination);
/* Error Handling */
exception
when FileUploader.FileUploaderEx then
message (FileUploader.GetError);
end;
I have the "uploadclient.jar" file in my folder: C:\oracle9iDS\forms90\java
I list the "uploadclient.jar" file in the forms config file, formsweb.cfg as follows:
archive_jini=f90all_jinit.jar, uploadclient.jar, RKMS_images.jar
and I reference the uploadserver.jar in the default.env file as part of the CLASSPATH as follows:
CLASSPATH=c:\oracle9iDS\jlib\debugger.jar;c:\oracle9iDS\jlib\ewt3.jar;c:\oracle9iDS\jlib\share.jar;c:\oracle9iDS\jlib\utj90.jar;C:\oracle9iDS\forms90\java\UploadServer.jar
=========================================================
- Why did this work before I rebooted and now no longer???
- Any tips? Ideas?
=========================================================
The uploadclient.jar file also successfully loads as shown in the Java Console:
Oracle JInitiator: Version 1.3.1.9
Using JRE version 1.3.1.9 Java HotSpot(TM) Client VM
User home directory = C:\Dokumente und Einstellungen\Randy
Proxy Configuration: no proxy
JAR cache enabled
Location: C:\Dokumente und Einstellungen\Randy\Oracle Jar Cache
Maximum size: 50 MB
Compression level: 0
Loading http://quantum:8888/forms90/java/f90all_jinit.jar from JAR cache
Loading http://quantum:8888/forms90/java/uploadclient.jar from JAR cache
Loading http://quantum:8888/forms90/java/RKMS_images.jar from JAR cache
connectMode=HTTP, native.
Forms Applet version is : 90290HI,
I'm facing nearly same problem.
When i press a button in my form to enable client to select image from there local computer, following code executes ( WHEN-BUTTON-PRESSED)
declare
exSetup EXCEPTION;
hButton ITEM := Find_Item('UPLOAD.SELECT');
begin
if (:upload.output_dir is null) then
MsgBox.Show(MsgBox.STOP_ALERT,FileUploader90,'Error: A output directory on the middle tier must be specified');
raise exSetup;
end if;
FileUploader.UploadFile(:UPLOAD.output_dir);
/* (:UPLOAD is a control block and output directory is a text field char 1000 having initial property = D:\IMAGE) */
exception
When FileUploader.FileUploaderEx then
MsgBox.Show(MsgBox.STOP_ALERT,FileUploader90,'Error During Upload: '||FileUploader.getError);
When exSetup then
null;
end;
There is no compiliation error.
Runtime error is " Error During Upload: Desitnation directory does not exists or is not writeable ".
Infact destination directory D:\IMAGE exists and is readable/writable to any one ??
Any Help possible -
File upload using java code ....?
Hi,
I have used below code to upload files into Tomcat server .
Every thing is working fine , but when i try to upload file size more then 400kb i am getting the Exception is :::::::::*javax.servlet.ServletException: javax/servlet/jsp/SkipPageException*
Let me know if any thing require to change on the below code to upload big size files..
String contentType = request.getContentType();
//out.println("Content type is :: " +contentType);
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
//out.println(boundary);
String file = new String(dataBytes);
saveFile="C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\StorageFolder\\Files\\UserData\\"+saveFile;
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
FileOutputStream fileOut = new FileOutputStream(saveFile);
//fileOut.write(dataBytes);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
The above code is working file for small file size only ,if the file size exceeds 400kb then it will through a
*javax.servlet.ServletException: javax/servlet/jsp/SkipPageException *Hi,
yeah i have included above code in Try{} catch {} block even though i am getting an exception if file size exceeds 400kb . ..
when i try to upload a file more than 400kb i am getting the below exception .
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax/servlet/jsp/SkipPageException
* org.apache.jasper.servlet.JspServlet.service(JspServlet.java:273)*
* javax.servlet.http.HttpServlet.service(HttpServlet.java:803)* -
hi,
When i use fileupload component in my page, Turkish characters is not renderind and i see them as question mark. Changing page encoding is not working and solving my problem, too.
any suggestion would be appreciated.
Regards...I got exact the same problem, but with Chinese characters display. Does that means we can only use upload with English characters? Any solutions in the future?
Thanks, -
How to implement File Upload/DownLoad in OA page
Hi All
I have to implement the File download feature of OA Framework in my Custom OA page when i click the button.
In developer's Guide i gone through this but i did'nt get what to set in
File View Attribute,
File Name Override,
File MIME Type,
and View Attribute
Please Suggest
Best regardsThe information is there in the dev guide
File View Attribute - The view attribute that maps to the column that stores the file content.
File Name Override - The file name to save to when you select the File Download link and choose the Save option in the File Download window to save the file. The default file name that appears in the File Name field of the Save As dialog window is derived from the value returned from the view
attribute specified by the View Attribute property. The value of the File Name Override property overrides that default file name and is especially useful if the view attribute returns instructional text, such as "Click on this link to download the file". If the File Name Override property is not defined, then
the file name to save to is the value returned from the view attribute.
File MIME Type - The MIME type of the file. See the Runtime Control example below if you do not want to specify a static value for this property.
Data Type - The data type of the File View Attribute. The BLOB datatype is now supported for File Download as of OA Framework 11.5.10D.
Maybe you are looking for
-
Unable to load the following resource: Error: too many columns- form won't
Hi .. Can you please suggest on the following error, which i am facing the issue while opening data form in Hyperion Planning 11.1.1.4 . Unable to load the following resource: Error: too many columns- form won't Regards, Vasu
-
How to add a new column as "Warehouse name" in Goods Receipt PO screen?
Hi, Experts I hope to add a new column or just "display" warehouse name besides Whse column in Goods Receipt PO. How can I do? Thanks
-
?harddrive error; skipping all tracks and not being recognised in itunes
I have a 3rd generation ipod which has been working fine until recently. I was transferring some music on to my ipod using a usb 1.0 cable (my laptop doesn't have usb2.o or firewire), and the ipod battery died midway through the file transfers. On re
-
Hi experts, how would you define : a high criticity interface ? a medium ? a low ? Kind regards, Jamal
-
I have a simple problem. I need to use a method in a class file. However, the class file name could change. I have tried the following: - import java.io.*; import java.util.*; import java.lang.*; public class WebTest { public static void main( S