I am making an Uploader Which uploads Audio File
Now i want following things to be done:
Once File is Uploaded to Server an Applet should start on ServerSide
Name & other details of Uploaded content should be passed to Applet
Applet will process somethings on Audio & then PAss the Result to DB( Or Servlet )
My Question is that How to achieve such Applet-Servlet communication on Server Side.
It is Just similar to that of some Site which allows user to Upload Image & then They Process something (i.e. add Watermark, Resize extract detail etc) & then gives results. & I am trying same things ,but on Audio with the help of Applet & JSP-Servlet Which i have created.
Thanks in Advance.
Related
I am working on a web application of Data Compression Library. What it does is that it takes an Input file and downloads it on localhost for processing. Downloading is done by using the UploadedFile service of tapestry. After taking this file, a C++ executable is invoked when the form is submitted in the browser. The output of the C++ program is the compressed file that is generated in the same directory as of the downloaded original file. Now what I have to do is, to make the compressed file available for download for the user. I am redirecting the user to another page after the form is filled.
The same goes for decompression, i.e, a form is filled in which file is selected and the file is downloaded to localhost. Decompression is performed via the C++ program and file is generated. User is redirected to another page.
How do I make this file available for download? It should be like a button is displayed and when the user clicks on it, the Save File as pop up should be displayed.
On Java side, just implement an event handler (maybe associated to click events on the download button displayed) returning an instance of the org.apache.tapestry5.StreamResponse interface.
You can find some examples on Tapestry's wiki: https://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile.
In simple words, Client will give image PATH in my textarea all those images should be saved in my server DB. Please give some code or idea to achieve this.
Note: Client may put more than one image URL in the textbox. I want to send all the images to the server.
You should tell us ,which clint are you useing.And if there is any framwork,like struts or others.
I have a requirement to load big images into chrome browser, in pieces from the server and after it finishes downloading the file completely, if the user wants to look at the file again, then the browser should load it from its cache.
I have done the following to achieve this:
I have written a HTML file and I will be displaying the big image using 'img' tag.
Whenever the user requests for the image file, I'll make a HEAD request to the server enquiring about the content-length and last-modified-date.
The server replies back with the information based on the request and I divide the size of the file into 10 pieces and then make 10 sequential requests to fetch the image file. (Using for loop).
After chrome downloads the entire file and the next time user wants to look at the file, then I am making chrome to send If-Modified-Since query to the server.
If the server responds back with the code 304, then chrome will understand that it has to fetch the file from its cache.
I am facing the following problems:
1. I am getting about 100 bytes per response. Where should I store it and how should I make my img tag understand that it the client is still downloading the file.3
2. How should I recognize the file from the pool of files present in chrome's cache ?
3. The next time someone comes to view the same image, from where should I display the content from ?
Please Help. Can anyone also provide me with some example code or a link to some sample code.
Thanks and Regards,
Akshay Sahu
I got the way to perform this operation.
I am downloading all the bytes of a file in range and using File API of HTML 5 I am creating a file in the user HDD. Therefore, experiencing a complete resume download experience.
Thanks and Regards,
Akshay Sahu.
I have a java application that will take the image as an input and output another image. I have a website with a popular host (PHP+MYSQL Hosting). I want to create a page on the website with PHP with a form where a user can upload an image which will then pass the image onto the Java application.
What I am planning on doing is when then user uploads the image, it gets stored in a folder on the web server. I will then call the java app on the server passing the url of the image as an argument and then the java app will output another image, let’s say, to a result folder. The PHP page after the execution will then display the result image on the browser.
Now my questions are:
Is it possible to execute java apps on popular webhosts (for example mine is WebHostingBuzz.com)?
The java app is fairly heavy as it does a lot of image processing. Should I offload the java app to another web server? If yes, are there any services that will run my java app?
(Optional) It’s a demo of my java app and I don’t want to store the images people upload. Is there a way where I can directly pass the uploaded image to the java app and output the image generated directly instead of storing it on the web server? I would prefer this because, if the image is big, I can make PHP stop the execution after a timeout.
How do I communicate with the java app from PHP for info on its execution, for example When PHP calls the java app, the page has to wait till the app finishes processing? I want the java app to send a response to the PHP page saying that the processing is completed and the page is redirected or refreshed accordingly.
I hope you get the idea, please suggest the technologies that I can use to implement this and also if you have a better idea, post it!
Thanks!
Now my questions are: Is it possible to execute java apps on popular webhosts (for example mine is WebHostingBuzz.com)?
It's technically possible. But the hosting has to install JRE at the host and give the PHP user sufficient OS-level and filesystem-level permissions. So you're really dependent on the hosting whether they provide this opportunity. Best is to just contact their support team and ask it.
If it is supported, you could just use shell_exec().
$result = shell_exec("java -jar /path/to/imageprocessor.jar " + $imagepath);
if ($result) {
// Shell execution succeed.
} else {
// Shell execution failed.
}
For asynchronous communication / background processing, the client has to fire an ajaxical request.
If it is not supported, consider porting Java to PHP. The GD image library has pretty a lot of functions which may be of use.
Google App Engine allows to host Java (and Python) web applications. The SDK and the basic account is free of charges. With the SDK, you could develop and test the application locally and then simply deploy to App Engine (NetBeans and Eclipse plugins are available).
Then the PHP app could send the data in a HTTP POST to the Google App Engine application and get the result in the response data.
Or the data is stored first in a database blob and a processing job is put in a task queue (a 'message queue'). This has the advantage that the PHP client request will return immediately after the data has been POSTed. Then, the PHP application could poll for the result data while Google App Engine processes the image. The PHP side would be more responsive this way.
Wouldn't it be easier to make your java app a web app, that PHP could call via an url in wich he would put the url of the image so java can download it?
like http://yourjavaserver/imageprocessing?imgurl=IMAGE_URL
and the java servlet would reply with the image file itlsef.
You can look for "java hosting" on google, to find a host for this, but it's more expensive than PHP hosting. Maybe the best choice would be to get a dedicated server which could host both PHP and java applications...
I think your best bet here is with your java app running as cron(or a deamon) that can load the file details from the database. This will require a (one or more) page-refresh on the users part after the generation is complete, at which point your script can recall the image from the database/filesystem.
I do not think you will be able to do this in real-time due to timeout restrictions on the PHP webpage. However, you could write a java applet that can take the file and process it before sending it to the server (or depending on how you intend to use it, perhaps you do not need to upload it after the transformation?).
How can I access Java applet data before it displays on my browser?
The applet usually downloads the data from the server using the HTTP protocol, so there is nothing stopping you from using the same URL outside of the applet. The only questions is: What happens with the data? The browser can only download and save it to disk. If you want to process the data, you either need Java (and the applet) or, if the data is really simple, you can do some basic processing in JavaScript.
A third option is to process the data on the server and present it as HTML on a different URL.