• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Calling PHP from Servlet

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please guide me how to call PHP file from a servlet. I found php code which can create file on my server directory. But i want to call that php code from my servlet. Php code is in the php file named UpLoad_File.php
I also want to pass the file name as a parameter to php file. Also is it possible after executing PHP code the control return back to servlet.. is that possible...Thanks
 
Mohammad Ali
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please guide me how to call PHP code from a servlet... thanks
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure it can be done -- anything's possible with enough work. The question is whether it should be done, and I'm going to argue that the answer is "no". To call this PHP code, you're presumably going to have to recreate the PHP server environment (which would mean setting environment variables in a script) then use Java's Runtime.exec() method to execute the PHP interpreter from that script, and then recover the input and output streams and communicate back and forth with that process. That seems like a lot of work -- not to mention a slow, inefficient, and fragile way to do things. Why not just use a standard Java file-upload component?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recently found this discussion on integrating PHP with Java servlets.
Bill
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic