-1

I created a quiz maker app in java as a windows application but I don't know how to publish its quizes output as html file or as web application?

  • You mean you want to output the results of the quizzes to an HTML file? Like export results to HTML and view the file in browser? Or do you mean you want the GUI of your app to be displayed in a browser as a website with a Java backend? – mr haven Aug 16 '19 at 19:47
  • Hi thanks for your answer. To be displayed GUI in a browser as an web application. I didn't make it by using of servlet and jsp .However It's not a java web application but it's a simple java application. – vasht Aug 23 '19 at 12:07
  • If HTML, which is static, you will need to generate some JS too, to make it dynamic – Mawg says reinstate Monica Sep 2 '19 at 13:52
2

The short answer is yes but here is some more context.

So you want to make a web app for the results.

You have a java app which is native windows. First note is Java is platform independent and can be compiled to Windows, Linux, Mac, etc. So the fact that it is windows doesn't mean much. What matters is that what you built would be the server for the web app.

All websites need a server to serve the html to the browser even if the website is purely static, eg a simple single html file. The server itself simply needs to support HTTP to serve the static HTML files. There are often times two servers involved with a web app. One to simply serve the static HTML site to the browser. A second to serve the data, usually as JSON with a RESTful API. This can all be done with one as well, its up to you.

Basically you need your Java app to be able to do one of two things:

A: serve dynamically generated html to the browser .

This is what JSP is about. You can do this all with just Java and bit of HTML. This is probably the easier route to take but not as popular.

B: serve the data as JSON/XML with an HTTP endpoint

This is what RESTful is about and is generally more work for more mojo. If you choose this option you would need to make a static website with Javascript code to make an AJAX request to get the data from the endpoint you made in Java. Then the JS code would build the GUI using the data. This is the more popular option now days as you can use all the fancy popular platforms such as Angular, React, Vue, Ember, etc. The other benefit is your web app does not need to care in the least bit that the server was written in Java giving you the flexibility to write the same endpoint in any other language or platform.

Whichever of the two options you choose you still need to be able to serve the results of the quiz over HTTP with a Java servlet engine:

A: Apache Tomcat

The most popular one by far and easiest to use IMHO.

B: Wildfly

If you need to get your game on.

C: Do some shopping

There are a bunch out there . . .

Once you have chosen an HTTP server, you need a good web platform. There are way too many to choose from so I'll just recommend Spring.io because it's my favorite and massively used in the Java community. However you should really do your homework on this one.

If your app has the logical code and GUI written in the same Java app, you would need to extract the Logical code out. Then the native windows Java app simply imports the core logic and implements it how you do now. The web server Java code would import the same logical code and implement the results part so it can serve the results as an HTTP endpoint. It would not be easy to make a web server and native GUI in the same app.

Once you have your servlet engine and a good web platform you can start serving HTML to the browser. Good luck and remember persistence is key and patience is a virtue. Enjoy the journey.

| improve this answer | |
  • Maybe take a look at Googles Firebase too . . . – mr haven Aug 23 '19 at 22:25
  • 1
    thank you very much for your perfect response. May be explain this statement in your context: What matters is that what you built would be the server for the web app. do you mean my app can work as a web app? – vasht Sep 1 '19 at 12:38
  • No your app would be the server that somehow "provides" the web app to the browser. Web apps are only HTML/CSS/JS which is what the browser runs. So no Java is not what runs in the browser. – mr haven Sep 3 '19 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.