Servlets and a Pre-Existing Program (Beginner)

I have a pre-existing java program which needs input from a webpage, specifically a drop down box.

What is the best way to pass the information from the webpage to the program? Each user selects a value from 1 to 10, puts an ID in a text box and clicks submit. I then need to collect these values in an array f[].

Sorry for the huge delay in replying, I will try and explain it a bit better.

The program is a package/framework type of thing called jMetal. It simulates Multiple Objective Evolutionary Algorithms. During the run of an algorithm it calls a method evaluate(solution) for each solution.

Each time it tries to evaluate a solution, represented by a 940bit binary string, I want to use that string to produce an image file consisting of java2d objects and display it on the website.

A number of users then use the drop down box to rate the image, and enter a userID i will use to identify them. I then need to pass this information back to the java program and when all the users have responded, let the evaluation method complete.

Questions:

I have sorted out the image design in java and it writes it to a file. Is it possible to move this code to a servlet/jsp or something and have it generate the image straight to the webpage?

In a more general sense, what would be the best way to connect the information generated by the webpage with the jMetal program? The process has to occur as quickly as possible, automatically if doable.

Again sorry it took me so long to reply, any recommendations or advice would be appreciated.

So this program is a stand-alone program running somewhere? And you want people to be able to bring some page up in a browser that sends a data element to that program?

If so, there's no need to refactor your program at all. Write a separate small web app that collects the user input, and that web app can communicate with the existing program through any of the Java messaging technologies: RMI or JMS, for example.

Thanks for the recommandation of JMS or RMI, they definitly look the right thing.

As for jMetal, it comes with a number of premade 'problems' to be run witht he algorithms and a framework for writing your own. I am simply creating a problem that takes user input in the evaluation stage, not making any changes to the jMetal framework itself.

Thanks for the help.

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12890

5

posted Apr 02, 2008 08:29:00

0

takes user input in the evaluation stage,

Can we please get to the point! HOW does input from the user get into jMetal

Bill

Vincent Cas
Greenhorn

Joined: Mar 09, 2008
Posts: 19

posted Apr 02, 2008 09:40:00

0

It doesn't.

The problems presented don't need or use user input, the evaluate method performs calcualtions dependent on the problem to assign values to each of the objectives of a solution.

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12890

5

posted Apr 02, 2008 12:59:00

0

Now I am reallllly confused - the original post said:

I have a pre-existing java program which needs input from a webpage,

Bill

Vincent Cas
Greenhorn

Joined: Mar 09, 2008
Posts: 19

posted Apr 03, 2008 03:40:00

0

Sorry, the first post wasn't clear enough, hopefully I described it a bit better in the fourth one.

Sorry for the confusion.

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12890

5

posted Apr 03, 2008 06:29:00

0

The 4th post contains the words:

In a more general sense, what would be the best way to connect the information generated by the webpage with the jMetal program? The process has to occur as quickly as possible, automatically if doable.

To me this implies that jMetal can accept data/inputs somehow. How does this happen?

Bill

Vincent Cas
Greenhorn

Joined: Mar 09, 2008
Posts: 19

posted Apr 03, 2008 07:19:00

0

Ok,

jMetal doesnt accept input at the moment.

Currently jMetal provides a number of evolutionary algorithms which can be linked with pre-created problems.

When an algorithm is run the information needed for the solutions to a problem is generated randomly, no user input or input data is needed.

I am attempting to create a problem that uses user input for the evaluation of the solutions. In all the other problems the data here is generated by equations or rules using the details of each solution.

Does this clear it up?

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12890

5

posted Apr 03, 2008 11:53:00

0

So you are really interested in presentation of the jMetal output with collection of user evaluations by some other process - NOT jMetal. Can you see how the statement:

connect the information generated by the webpage with the jMetal program?

sounds like something entirely different?

It appears you will be writing some sort of HTML page with a graphic visualization of the jMetal output and a Form element to collect the user's ID and evaluation.

Creating Forms in HTML and interpreting the request the form creates with a servlet is very standard stuff covered in just about any servlet tutorial, nothing new needs to be invented.