This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mohit Mathur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mohit Mathur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic