How PHP script can be called using Java Applet - java

I want to access user's scanner using PHP script. I know this can be done by using PHP script on Linux based machine.
I want to put this script on the server and wanted to run it via Java Applet I don't know Java much also I am not sure if this task can be done by this way.
Please suggest if this is correct way and How to proceed on it.
Thanks for your time!

Can the scanner PHP code be operated purely via parameters in the URL? If so, then a Java applet could connect to those URLs passing parameters as necessary, and if the PHP script returns information in the HTML output stream (as if it were returning a web page), then the applet can parse the page it 'downloads' from that URL to get the information out. Not elegant, but do-able.

Related

How to call a .sh file function through html GUI?

I am using HTMl to develop a GUI where in I want to give a call to a function existing in .sh file.
Can any one please suggest suitable option as I tried to call function in different ways but didn't worked out.
You cannot do this from HTML. HTML describes what a page looks like; it doesn't "execute" anything.
You might be able to translate your shell script into JavaScript, which can be embedded in an HTML page, depending on what the shell script does.
If you have a web server, CGI is a protocol (not a network protocol) which allows the web server to run specially-written executables (including scripts) in response to requests to certain web addresses. You can then include a form that submits to an address that triggers your script, or send the request from JavaScript.

Is it Possible to Run Shell Script in Browser

Sorry if you are thinking this as Basic question. I am Having shell scripts which accepts Some parameters as Inputs to Run the Script.
Is it Possible to Pass these Parameters through Web form and Run the Shell script through Browser.
How to implement this using java if Possible. or any other technology is Best.
Thanks in Advance. Looking forward for your valuable Advice's.
Edit:-
Hi All,
Currently I am having an GUI which runs Scripts on Client Computer by accepting Some parameters. I want to keep those Shell Scripts on Server and Run by passing parameters using Web form. Sorry if my language is difficult to understand.
You would need to use a Java Applet with heightened security privileges and a JavaScript API so that JavaScript in the page could read the form data and pass it to the applet. The client computer would need to have the Java plugin and whatever shell you were using installed, and the user would have to accept the above-normal-security-level access rights the applet asked for.
This isn't in the least bit practical for the WWW and is rather a stretch for a controlled network.
You can run a script using a signed applet.

Remotely calling Java from php

I have a java program that runs on a couple different computers and I want to be able to be able to access them remotely. I don't need to do anything crazy, just some very basic input output (get and set type stuff). I could write a client type application and set each program to a server with RMI and do it that way but I will not always be on the same computer and do not want to have to carry the .java file around with me.
I'd prefer to write a simple php webpage that I can access from anywhere and have some very basic buttons that could send the commands to the different Applications and receive back some output.
Problems is that it would probably impossible to get my host to load anything other then php onto the server where I'd host my webpage.
Does anyone have any ideas? I've tried googling it and found a couple things out there that sort of sound like what I need but the more I look into them they seem to not be what I wanted after all.
If you really want to do this right I'd suggest looking at a Java web framework (I use Play! myself) to create a RESTful web service and then sending requests from your PHP code that will fetch JSON data.
A framework like Play will make it very easy to get a REST web service running. Just create some wrappers that invoke your existing java code and call renderJSON to output the result.
From the PHP code you'll issue the request using curl and then read the response using json_decode which will turn it into a handy php variable.
This also has the advantage that either end can be changed without the other noticing, as long as the json data format is kept the same.
Based on the way you described your setup you'll probably run into routing issues trying to reach your Java apps from your PHP host. I'd recommend you try something else: have your Java apps frequently check with your PHP app if there are any updates. You can simply use a Java URL connection and a timer:
http://download.oracle.com/javase/6/docs/api/java/util/Timer.html
http://download.oracle.com/javase/6/docs/api/java/net/URL.html

Wrap a CLI Java application in an Applet

I have a CLI Java application that takes a filename as an argument, and outputs its result to STDOUT.
I don't have the source code for this application, and it performs logic that needs to be executed client-side as part of a web app.
Is it possible to create an Applet wrapper around this application, and then send input and retrieve the result via JavaScript? If so, how would I go about doing this?
Yes it is possible, though note that to redirect output streams requires a trusted applet AFAIR.

Sending HTML Form Data to Java

I have a Java program that I'm trying to interact with over the web.
I need to gather form data from the user on a Drupal site that I don't have any control over, send it to the Java program, and send the output back to the user. The Java program needs to load a lot of libraries every time it's run, so it needs to be up waiting for data from the user.
It'd be best for me to just have an HTML form for the input. What's the simplest way to deal with HTML form data using Java?
Also, I'm trying to call the Java program from a shell script. I want the program running in the background though so the libraries are loaded in advance. So ideally, I could use the server I set up for both applications.
Thanks for any help.
It sounds like you really just want to write a servlet (or use a higher level web framework, but a servlet would work fine). That makes it very easy to get web form data - you just ask for values by name, basically.
You could then "script" the application using curl, wget or something similar to make requests to the servlet.
Apologies if this doesn't answer your question - I'm finding it slightly tricky to understand exactly what you're trying to do, particularly as there are multiple layers of web UI involved, as far as I can see.
The easiest way to make POST requests with java is to use the Apache HttpClient or the more recent HttpComponents libraries.

Categories

Resources