Convert java program to javascript for a webapp?

Essentially what you're describing is a CMS. I don't think something like GWT would help here.

If you don't want to use an off-the-shelf solution I propose the following workflow:

Adding an article

1) User logs in to private area of website for content creators

2) User creates a new article

3) User inputs information

4) User saves article

5) Information is stored. (This can be on disk as some format like JSON or XML in a DB or Keystore, whatever.)

Rendering an article

1) The application will get the article URL somehow. The servlet or REST endpoint would handle this

2) That URL is translated into the name of the article (name/id/short name, whatever)

3) The article is looked up in the database by name/id

4) The data from the article is merged into the template to create HTML

5) The output HTML is sent to the user

It is also possible that you could just create the HTML in step #5 of the workflow for #5 and then look it up from the disk path (or wherever) later. This would make it harder to change the site's template later. A hybrid approach, where pre-rendering is used and regenerated when the site is changed would be pretty good, but might be a premature optimization.

Some things you might want to look at:

  • Spring - Not my favorite but good for MVC apps like this one. Will help you out with some of the concepts especially if you use Spring Boot. If you go with this approach then Spring Security is a must.

  • If you want REST endpoints then you might want to look at JAX-RS and some of the implementing projects like Resteasy or Jersey. This could make it easier to write the service for retrieving rendered templates much easier.

  • Personally I'd look at EE6 over Spring, but that's because I'm more familiar with EE. For security/authentication/authorization I've had some success with Apache Shiro.

  • For templating in Java I like FreeMarker. This would allow you to take the data input by the user and render it in the template without having to mash up your own files. The template can be changed irrespective of the content.

Just some thoughts. I don't think leveraging GWT is going to help you out much here.

/r/java Thread