简体   繁体   中英

Creating a webpage that retrieves data from a java program and displays it

I was just wondering if such a thing was feasible to implement, and maybe a general overview of the steps required.

Basically, I have a webpage that contains a form. When the user clicks on submit, I'd like to send the data to a java program that I've created, which will in turn process the form data and return some output to the webpage.

The java program itself is pretty simple (it returns some simple strings), but it should be constantly running and waiting for form submissions and returning output.

So far, I have the webpage set up, and the java program runs correctly in eclipse. But besides that, I'm kinda lost as to what to do next and how to link the two together.

There are a few different ways of doing this, each with its own pros and cons. Different people will suggest different frameworks and techniques.

It sounds as if you are still earning the ropes and your problem is fairly simple. I would suggest that you download a copy of Apache Tomcat . It is what we call a servlet container (it also has a built-in webserver). That will take care of the "constantly running and waiting for form submissions" part of your problem.

Next you'll have to write something that accepts the form submissions. The easiest way to get started is to write a Servlet, even though on larger apps you'll probably wouldn't want to use servlets directly. You can Google for a Servlet tutorial, or check out one of the many books available on the subject - see https://softwareengineering.stackexchange.com/questions/29918/what-are-some-good-books-on-java-servlets-and-jsp .

You can then deploy the Servlet into your Tomcat servlet container and let it do the hard work for you.

It will take some time to wrap your head around all the bits and bobs because it is quite different from standalone apps, so be patient. You have just started the journey as a web developer. Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM