JSF :: Upload File With Path Stored In Database?
May 20, 2014
I'm using jsf 2 to upload file, first I upload the file in a system directory, then trying to store the path to database with other information, my stuck is that when submitting I upload the file successfully, find it in the right place, find the other information such as description, file name ... in database but don't find the path. this is my managed bean :
package mbeans;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.List;
[code]...
View Replies
ADVERTISEMENT
Dec 1, 2014
In my web application i want to upload file to drop-box. I am getting file name from browser.Is it possible to upload file to drop-box with only file name.
Below the drop-box upload code with java.
File inputFile = new File("New Text Document.txt");
System.out.println("inputFile.getAbsoluteFile(): " + inputFile);
FileInputStream inputStream = new FileInputStream(inputFile);
try {
DbxEntry.File uploadedFile = client.uploadFile("/magnum-opus.txt",
DbxWriteMode.add(), inputFile.length(), inputStream);
System.out.println("Uploaded: " + uploadedFile.toString());
} finally {
inputStream.close();
}
In the above code the place New Text Document.txt we have to provide total path of file.
View Replies
View Related
Jun 30, 2014
I have a code that uploads files in server after browsing folders and files then get the paths of files but I have a problem in getting the paths
List items = upload.parseRequest(request);
Iterator iterator = items.iterator();
while (iterator.hasNext()) {
FileItem item = (FileItem) iterator.next();
if (!item.isFormField())
{ fileName = item.getName();
root = getServletContext().getRealPath("/");
path = new File(root + "/uploads");
[Code]...
list1 must has paths that I want but I do not get the paths of upload files
View Replies
View Related
Oct 22, 2014
Creating a file upload servlet to accept a CSV and parse for insert into a database, however, whenever I click submit, it always seems to open a new tab/window. Below is the method I have that builds the upload form: (Using GWT 2.4)
private void buildUpload(){
LayoutContainer headerContainer = new LayoutContainer(new ColumnLayout());
headerContainer.setStyleAttribute("padding", "5px");
add(headerContainer);
NamedFrame hiddenFrame = new NamedFrame("uploadFrame");
final FormPanel form = new FormPanel(hiddenFrame);
[Code] .....
Is there something I'm missing? or something I've added that makes it open a new tab/window?
View Replies
View Related
Apr 2, 2015
How to display pdf file which is stored in mysql database by using jsp and servlet ....
View Replies
View Related
Oct 25, 2013
I did an application with jframe which i store member personal info like name, surname etc.But when i save it to Mysql database the values are ??????.I have changed database and table and columns collation to utf8, i checked java encoding it's utf-8 but the problem remains.i have spent hours in google search but nothing that works.
View Replies
View Related
Sep 17, 2014
I am new to Java Stored Procedures. There is a PL/SQL package in our legacy application(Oracle 9i) which pulls data from Oracle 8i source database through a DB link. Now we have upgraded our databas to Oracle 11g R2 from 9i. So the DB lint to Oracle 8i will no longer work in 11g. Hence I have created a Java stored procedure that establishes JDBC thin connection to the source 8i database. I have loaded the java stored procedure in the database using loadjava and have created a call specifaction.
I have called this java stored procedure inside the PL/SQL package. Now while executing the PL/SQL package, it takes the default driver ojdbc6.jar to establish JDBC connection and fails to connect to the 8i database giving ArrayIndexOutOfBounds Exception. While running the code in the linux application server with classes12.jar the code succeeds. But when the same is called in the database it fails.
1. How can I make my PL/SQL call use classes12.jar while calling the Java Stored Procedure?
2. How can I load the jar file(which includes my classes and the classes12.jar) into the datase as one object? (When I tried to load the whole jar, in database the classes and dependent jar loaded separately)
3. Is there a way to use classpath while calling the Java Stored Procedure like how we do from Unix?
View Replies
View Related
Dec 26, 2012
I am using Oracle Database. My images are stored in database in ORD Image format.
ORD Image = > [URL] .....
I am fetching image and displaying in JSP.
I want to resize image stored in database.
I found Java Advanced Imgaing API and Looking for JSP implementation example.
[URL] ....
OrdHttpUploadFile uploadPhoto = null;
OracleResultSet ors=null;
OracleCallableStatement ocstmt = null;
OrdImage ordImage=null;
OrdImage image=null;
[Code] ....
View Replies
View Related
Jul 2, 2014
We have web based application (Oracle DB, Weblogic middle tier) and a applet based application running on the browser.
We have a requirement to Load images from the database (stored as blob) to the client browser and the users can do the lookup on images when needed.
We need this to perform well, so there is no delay for the user experience. We have 2 options:
1. Load the images from the database to the Application Server and keep it. When the client request from the browser comes, download it from the application server.
2. Load the images (asynchronosly) when the user logs into the application and download them to the Client machine? Is this possible? Especially give that it is stored in the database as binary objects?
And then load for the user from the client box itself, upon request.
If 2nd option is possible, which once is recommended?
View Replies
View Related
Jan 19, 2015
I was asked to create an Android App with SQLite Database. I had referred some example and tutorial which can be found from the internet but 1 thing that is still unsolved.
The default path for Android SQLite is //data/data/<Your-Application-Package-Name>/databases/<your-database-name> which can be found in Eclipse DDMS after connecting the phone to the computer or the emulator is on.
I had tried many example and tutorial and yet I can only access to "data" file only and the rest (/data/<Your-Application-Package-Name>/databases/<your-database-name>)are never appeared on my screen. This is one of the website (URL....) I learnt to create my database app.
I had follow the steps exactly for many times but I still can't find the path. The app is running fine as it will show saved data/"contact" although I restart the apps(Which mean it did save my data but I just can't find where did it saved). What's wrong with my Eclipse?
View Replies
View Related
Nov 14, 2014
I upload a file and save it like the following
byte[] uploadedFileBuf = new byte[(int) uploadedFile.length()];
saveFileSystem(excelUpload + getLocalFileName(acad_year, stuid), uploadedFileBuf);
private boolean saveFileSystem(String filename, byte[] data){
try{
FileOutputStream fos = new FileOutputStream(filename);
fos.write(data);
fos.close();
[Code]...
I can not read it use
HSSFWorkbook WorkBook = new HSSFWorkbook(new FileInputStream(filename));
View Replies
View Related
Jan 21, 2015
I need to upload a file in R, I can do it with a CSV file or excel ect. The file I received is already in R format .Rdata.It is a file called surveydata.rdata.The two data frames are surveydata.4.num.frame and surveydata.4.lab.frame.The surveydata.4.num.frame is what I need.I can click on it in Rstudio to see the data but I can't load it to run an analysis.How can I upload this?
View Replies
View Related
Mar 22, 2014
I'm having some problems styling the PrimeFaces upload tag <p:fileUpload /> in my application.
In my xhtml code I have the following:
<p:fileUpload id="fileUpload" fileUploadListener="#{filters.upload}"
allowTypes="#{filters.uploadTypes}" invalidFileMessage="#{filters.uploadBadType}"
sizeLimit="#{filters.uploadSize}" invalidSizeMessag="#{filters.uploadBadSize}"
update="fileUpload fileTable filterTab uploadMessage hiddenNum hiddenPhoto uploadError footer
namePhotSystem checkOverwrite"
description="Select Text File" disabled="#{filters.fileuploadDisabled}" fileLimit="1"
fileLimitMessage="You are only allowed to upload one file at a time"
styleClass="fileUploadClass" label="Choose the File to Upload" auto="true" />
This all works correctly, both the AJAX update and on the server, but I'm unable to get the button or buttons displayed in the way I need.
By including the following in my CSS:
.ui-fileupload.fileUploadClass {width:428px;}
.ui-icon-plusthick {display:none;}
.ui-button-text {width:200px; height:20px;}
the first sets the width of the button bar, and by looking at the HTML code generated by PrimeFaces, I discovered that the second hides the "+" to the left of the "Choose" button, which here has been replaced by the text "Choose the File to Upload". However, this text is displayed on two lines, with the word "Upload" on the second. I want the whole text to be on one line, but no matter what I do, I cannot get this to work properly. The third line of my CSS code does indeed reduce the height of the button, but the width does not work at all, and the last part of the text is simply lost. How do I put all the text on one line and adjust the width of the button?
Another question is that when I remove the auto="true" attribute from the tag, which I had originally, the "Upload" button is displayed to the right of the "Choose" button, and when a file is chosen but not yet uploaded, it is displayed below the button. This is a capability that I might still want, however, I am unable to style the display, and in particular the progress window to the right of the file name and size. All the files I want to upload are relatively small text files, and I want to adjust this window or even hide it completely. How is this done?
Incidentally, because the files are all quite small, I have disabled the display of the "Cancel" button, so either only the "Choose" button is shown, or the "Choose" and "upload" buttons.
View Replies
View Related
Apr 16, 2014
I am trying to implement a file upload functionality. One of the requirement is to display a 'Please Wait!!!' message to the user while the upload is going on. My project currently uses JSF 1.2, Tomahawk, JQuery 1.9, JQuery UI 1.10. I am aware that this can be accomplished using a4j with richfaces, however I am not supposed to add any new library to the existing project. how this can be done?
View Replies
View Related
Nov 25, 2013
Our client has a user facing web application running on Jboss. There is a separate admin application (in its own ear) but deployed on same Jboss server on which user facing web application is running.
They need a screen to upload large amount of data into database. Their original files were in excel with size > 60 mb. We suggested following to them:
a. Change upload format to CSV - this brought down file sizes to 25-30 mb
b. Upload process will be MDB - asynchronous processing of data so that admin web app does not stop responding
We also suggested following to them:
a. Host admin app on a different machine so that user facing site does not respond slow during data processing
b. We can provide incremental upload feature and they should upload files in the chunks of 4-5 mb, specifically if they have user a web page to upload such files - they don't buy this argument though.
c. Data processing can be a separate script instead of a part of admin web application. They can FTP files to a designated location and this script will process those files.
I have following questions:
Q1 - Have you seen upload of such large datafiles to a web application? I see sites like Zoho CRM or Salesforce do not support such data imports and mostly fail or not respond.
Q2 - Is there a set of guidelines/best practices to upload large data files of this nature? How do insurance companies or others with enormous set of data accomplish such tasks (what is the architecture of such programs)?
View Replies
View Related
Apr 1, 2014
I have a JSF page (called MainPage) with a commandButton: clicking on it, I open a modal panel with a <Rich:fileUpload> component, related to a listener in corresponding bean.
When I start to upload a file, page MainPage starts to refresh, but I would like to prevent this because it's not necessary.
I tried to "play" with <Rich:fileUpload> property values, but nothing seems to work and I don't know what to do anymore.
Here is file upload component
<rich:fileUpload fileUploadListener="#{pannelloUploadBean.uploadListener}"
id="#{cid}_input"
ajaxSingle="true"
immediateUpload="true"
listHeight="200px"
listWidth="458px">
[Code] .....
View Replies
View Related
Apr 16, 2015
I am not all secure on the execution of the fileupload Primefaces.
The uploading execution occurs normally, but I would like to have a counter that control's the received files. The problem is that sending files go by so fast by this method that appears to be running in parallel. My question is whether this behavior is normal while sending files.
If it is not, where may be the error. If it is normal what can i do to make the counter really take the right value?
I'm using the scope of the "bean" type of view, but when im trying to run the session the problem also occurs depending on the file size.
If my files are very small, the execution is very fast and I cant follow the counter. If I clean the code the execution usually occurs no matter the size of the files.
@ManagedBean (Name = "bean")
@ViewScoped
public class BeanUpload {
private int counter;
@PostConstruct
public void init () {
counter = 0;
[Code] .....
The result on the console for 3 files is:
COUNTER EX: 1
COUNTER EX: 1
COUNTER EX: 1
If I run the code in debug mode on the console this is the result:
COUNTER EX: 1
COUNTER EX: 2
COUNTER EX: 3
Versions: Mojarra 2.1. Primefaces 5.1.15
View Replies
View Related
Dec 4, 2014
How to upload file to google drive using java. my java code is.
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, jsonFactory, CLIENT_ID, CLIENT_SECRET, Arrays.asList(DriveScopes.DRIVE))
.setAccessType("online")
.setApprovalPrompt("auto").build();
[Code] ....
So in that file object(java.io.File fileContent = new java.io.File("document.txt");) asking complete file path. But in file upload we can get only file name not path.
View Replies
View Related
Sep 3, 2009
I have a requirement where a large file (100 -200MB) is uploaded from the client to a content management system. I am using a servlet with Apache Commons File Upload API. Apache FileUpload has 2 ways of handling files,
1) Non-Streaming
2) Streaming
Currently I use the Non-Streaming approach where the servlet stores the file in a temp location and upload the same into the content management system - This is taking lot of time so I am trying to implement Streaming API.
Content Management API supports streaming in 2 methods,
a) SetContent - Takes the file's ByteArrayOutputStream as input -> This gives OutOfMemoryException because the file being large
b) AppendContent - Takes the file's ByteArrayOutputStream as input -> This method can be called multiple times to upload the large file but I dont know how to do this. The Apache File Upload gives InputStream of the file and I need to split that into chuncks and append into the content management system.
How to convert InputStream to 4KB ByteArrayOutputStream so that I can use the AppendContent method in content management API?
View Replies
View Related
May 6, 2014
I am facing a problem while executing a task. My task is to make such a code which will search for my source code file (abc.java) in all directories and then displays the code in textarea inside frame and along with that i also have to display the path of the file in text field. I have coded something but i am really not getting anywhere near my task.
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*
public class Lab extends JFrame {
[Code] ....
View Replies
View Related
Apr 26, 2014
I have this program to see the occurrences of a character in a string stored in a text file. My text file has the following contents (as shown below):
P-P-N-N-L-V
N-R-U-S-R-Q
K-Q-E-L-E-A
A-J-B-G-E-F
F-E-L-Q-R-R
U-F-J-V-I-M
P-I-Q-K-B-K
U-N-L-F-O-B
M-A-N-M-H-O
P-Q-J-D-N-I
G-U-O-D-F-I
Q-M-M-B-C-Q
N-B-I-L-E-J
S-A-T-Q-H-U
C-L-G-U-J-M
R-P-V-M-A-A
C-R-A-V-L-B
M-U-Q-K-M-Q
E-I-C-H-V-J
J-N-N-K-R-P
As you notice, each character is seperated by a hyphen (serving as its delimiter). I want to only go through 10 lines in the text, instead of all 20 of them. So, I wrote the program in such a way that I intend to reach into the indices of each character in the text file. Since there are six characters in each line so that means there are 6 indices - and there are 10 lines I only want to go through. So, 6 indices times 10 lines equals 60 indices. Hence, there are only 60 indices I need to go through. In that manner, it's like I have gone through only 10 lines through that way.
It compiled perfectly fine but upon running it, I ran through an error in the black DOS screen that says
"java.lang.ArrayIndexOutofBoundsException: 6 ".
How do I work around that?
The code I wrote is shown below...
import java.io.*;
import java.util.*;
public class hotandcoldclusterdeterminer_test {
public static void main (String args [])throws IOException {
[Code]....
View Replies
View Related
Jul 27, 2014
I am trying to write to a text file with information stored like this.
brick 500
stone 500
And so on. Here is the code I am using to write to the file.
switch(record){
case "brick":
x.format("%s%n", "brick " + value);
closeFile();
break;
case "log":
x.format("
%s%n", "log " + value);
closeFile();
break;
When I write like this, putting deletes the first line. What I can look into or other functions that would be useful?
View Replies
View Related
Dec 22, 2013
I already used properties file without problems for localizing information. In that case the property file was stored as a resource in a package; and I used the Class ResourceBundle to manage the operations and the ClassLoader to access to the file.
Actually I need to use property files “To save the configuration of the application”.In this case I need also to update information stored inside the file.property, and I used the same procedure as before to manage it (ClassLoader to get data- also for writing).
I had problems in this case: that the data was never modified inside the properties file. I investigate, and now I think that the problem comes from writing in the property file that is located in the .jar file. For what I know, it is impossible to change resources putted in the .jar files.
I found a solution: to store the properties files out the jar files; and in this way all is good. But it would be more comfortable to store inside.
My question is : if a file property used to “save the configuration of the application “ have to be put out of jar, or is there another way ??
View Replies
View Related
Apr 26, 2014
I have this program to see the occurrences of a character in a string stored in a text file. My text file has the following contents (as shown below):
Quote
P-P-N-N-L-V
N-R-U-S-R-Q
K-Q-E-L-E-A
A-J-B-G-E-F
F-E-L-Q-R-R
U-F-J-V-I-M
P-I-Q-K-B-K
U-N-L-F-O-B
M-A-N-M-H-O
P-Q-J-D-N-I
G-U-O-D-F-I
Q-M-M-B-C-Q
N-B-I-L-E-J
S-A-T-Q-H-U
C-L-G-U-J-M
R-P-V-M-A-A
C-R-A-V-L-B
M-U-Q-K-M-Q
E-I-C-H-V-J
J-N-N-K-R-P
View Replies
View Related
May 12, 2014
What I do wrong when I trying to set path to file in my jar app. I have application which work with xml file. I have next project structure:
/project_root_directory
|_ /lib
|_ /resources/file.xml
|_ /src
So, I need to set correctly path to my jar file, because when I running it from IDE, it works nice. By default it seems:
private File file;
private StreamResult streamResult;
file = new File("resources/file.xml");
streamResult = new StreamResult(file);
And methods where I can modify the DOM structure via transformer in end of methods:
transformer.transform(source, streamResult);
So, I trying set path to file:
private URL url;
...
file = new File(url.getPath());
streamResult = new StreamResult(file);
But it didn't not work, because when I trying to get resource by next condition
url = getClass().getResource("resources/file.xml");
url = getClass().getResource("resources/file.xml");url = getClass().getResource(url = getClass().getResource("resources/file.xml");resources/file.xml");
url - is null
Okay..
I tried next solution
InputStream input = getClass().getResourceAsStream("resources/file.xml");
There, I got also null....
Also, I tried made absolute path
filePath = file.getAbsolutePath();
file = new File(filePath);
streamResult = new StreamResult(file);
But it also didn't work. There I got message seems like: "Can't find resource /User/user1/Desktop/program1/resources/file.xml" - but that's really absolute path to a file.
Also, I tried made it via System.getProperty
String filename = "file.xml";
String workingDir = System.getProperty("user.dir");
finalfile = workingDir + File.separator + "resources" + File.separator + filename;
file = new File(finalfile);
I also made unit test which completed with "green light", but in jar its wrong with message "Can't find resource /User/user1/Desktop/program1/resources/file.xm" ....
View Replies
View Related
Apr 9, 2015
I would like to understand how does multipart/form-data works during file upload scenario's, Does it chunks the data from client to server while transferring the files ?
View Replies
View Related