wood burning stoves 2.0*
The moose likes JSP and the fly likes Calling a JAR file from JSP or from a PHP page or another option? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Calling a JAR file from JSP or from a PHP page or another option?" Watch "Calling a JAR file from JSP or from a PHP page or another option?" New topic
Author

Calling a JAR file from JSP or from a PHP page or another option?

Mohit Mathur
Greenhorn

Joined: Nov 07, 2011
Posts: 2
I have a JAR that is a simple command line program/utility that converts an image file to another image format. I need to integrate this into a website where users upload image files and the files are converted to another image format. All the pages for the site are written in PHP and all image files are stored on the file system (not in a database). What is the recommended approach to integrate this JAR into the website - by calling a JSP from a PHP page or by calling the JAR directly from PHP...or another recommended way to integrate the JAR into the website?

Ideally, I would like to have the JAR called (with the required parameters) to convert each image file as soon as it has finished uploading.

I was planning on creating a script that would be called by a CRON job to scan for new/changed files or folders and for the conversion utility to run on those files or folders, but this doesn't provide the desired user experience. We'd like to minimize the time between when an image is uploaded to when it is converted to another image format. Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

A JSP is simply a template for creating an HTML page so I don't see how JSP enters into this at all.

What I'd explore is creating a web service from the Java code, and have the PHP call the web service.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mohit Mathur
Greenhorn

Joined: Nov 07, 2011
Posts: 2
Bear, I like the recommendation. Though if I go down this route, should I design the webservice to only require a parameter of the file path of the image file to convert (since the file will be uploaded to the server and I want the WebService to perform the conversion on the files that reside on the server)? Or would you recommend that the PHP passes the image file to be uploaded to the WebService and the WebService handles the process to upload the image file and then the conversion.

Any recommendations on designing a WebService that performs file I/O on the hosting server would be appreciated. Thanks.
 
 
subject: Calling a JAR file from JSP or from a PHP page or another option?
 
Similar Threads
157 Question Help and Resourses
Problem with jar
Getting Resin to ignore PHP script so that webserver deals with request
How to store image, audio, video & text files POSTed to JSP page?
integrate sturts application with PHP/Ruby