Simple applet

J

John Duke

I'm new to this, and need a little help getting pointed in the right
direction.

I have a c++ program running on a standard windows box. It's a simple
app, not running in a browser.

I want to send two numbers to an applet? servlet? via the internet and
have it return the sum to the c++ program.

The server in question is running Red Hat 9, and supports servlet 2.2+
and jsp 1.2+.

What tools should I use to develop the servlet? applet?
How exactly do I get that c++ program to interface with it?

Book recommendations, web links, general answers or advice are all
welcome and appreciated.

Many thanks,
John
 
K

kaeli

I want to send two numbers to an applet? servlet? via the internet and
have it return the sum to the c++ program.

I don't know about C++, but java has an http request object that one can
use to "talk" to web servers. C++ probably has one, too.

--
 
A

Andrew Thompson

John Duke wrote:
...
I want to send two numbers to an applet? servlet? via the internet and
have it return the sum to the c++ program.

I think you are better off looking into
servlets, as an applet can no longer
access the params of a request.
(Early Java versions could)

But.. this _is_ an exercise, right?
...It seems like a damn fool way to
'add two numbers'.
 
J

John Duke

You mean everyone doesn't do it this way? =)
Yes, the app in question is Huge, Ancient and Not To Be Replaced, but
I must alter it to communicate with a servlet I will write on a Red
Hat 9 server. If I can do what I described, then I can finish this
project.

Thanks, and please, if anyone has further advice/references, please do
post.

Regards,
John
 
B

Berlin Brown

John said:
You mean everyone doesn't do it this way? =)
Yes, the app in question is Huge, Ancient and Not To Be Replaced, but
I must alter it to communicate with a servlet I will write on a Red
Hat 9 server. If I can do what I described, then I can finish this
project.

Thanks, and please, if anyone has further advice/references, please do
post.

Regards,
John

You are not doing this for work(college?), ideally network computing
doesnt work well with simple addition. Global creditcard transactions,
network filesystems, video on demand.... addition... no.
 
B

Berlin Brown

Berlin said:
You are not doing this for work(college?), ideally network computing
doesnt work well with simple addition. Global creditcard transactions,
network filesystems, video on demand.... addition... no.

Sorry for being the puss.

C++ doesnt have all the network utilites that java has(out of the box
anyway). I would find some raw sockets code somewhere for your socket
program:

void main() {

socket _s;

// blah, setup tcp socket....(a little rusty)

_s.family = TCP
_s.port = 8080
_s.host = ntohl("http://servlet")

_s.connect();

// I personally would do a write to the servlet
// you may want to read the docs on proper HTTP/1.0 transactions
// they are real simple, dont be scared.
_s.write("POST" + "\r\n")
_s.write("no1=blah" + "\r\n");
_s.write("no2=blah" + "\r\n");

while() {


read_input_data_from servlet

I personally would read in XML, see below

}

close_socket();

}

-- java

doPost() {

x = getParameter("no1");
y = getParameter("no2");

// assuming you sent the proper transmission
//
response_type = "text/xml";

PrintWriter _out = ___Servlet_.getOutputStream();?

_out.println("<?xml version="1.0"?><axml res=" x + y "></axml>");
}

You get the idea?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top