0

Although currently still in the planning stages of implementation for our company website, we are considering different methods and technologies that successful at addressing scalability, performance, and security (as in people can't steal or easily reverse engineer our financial algorithms) concerns.

According to several posts here on stack overflow, it appears that since we have already completed a good deal of algorithms via Java for our desktop applications, accessing these algorithms via Java Servlets and JSON requests (as can be seen here and here) online might be a good choice, as it would save considerable time and money by not having to rewrite them in a different language.

Before moving forward however, I would like to know if the time and money saved by this approach would be worth it in the long run, and specifically, is accessing (java methods and array data) via JSON and Javascript both secure and scalable, compared to say rewriting all of them in straight javascript? Also, is support for applets and servlets ubiquitous, or is it possible that a good chunk of our user base would not be able to have access our website without having to download additional plugins?

In the ideal situation (minimizing learning new technologies), I would like to use technologies involving HTML5 canvass and JavaScript for all of the graphical stuff, but also be able to access small data via java algorithms (which will return an array with less than 100 indexes), however eventually on a large scale in terms of number of simultaneous users (no logins).

Is this a good option in terms of speed, compatibility, and security, or is there perhaps something that we overlooked?

4
  • Applets are not supported everywhere (and are also kind of dated). A servlet runs on your server, so your server is the only thing that needs to be able to run it. It sounds like you should make an HTTP (JSON is a good way to transmit your data over HTTP) api that exposes your internal algorithms in Java and use AJAX requests to your api from Javascript to access them. In other words, your client-side should be strictly Javascript with absolutely no Java, and your server-side should be strictly Java. Commented Jul 16, 2015 at 3:49
  • javapapers.com/ajax/getting-started-with-ajax-using-java Commented Jul 16, 2015 at 3:54
  • Thank you for the information. And it is to assume that such an approach scales as well? Is there any upper limit that I should know about, or perhaps ways to ensure thread safety that you know off the top of your head? Commented Jul 16, 2015 at 4:03
  • I'm not the right person to ask. I'm not familiar with servlets, and not a Java developer. To me, they do not seem like they would scale too well, due to starting a new process for each request (I could be mistaken about this). I think it would be better to use some sort of long-running HTTP server like Jetty or something. Again, I'm not really the right person to help with that decision. Commented Jul 16, 2015 at 4:07

1 Answer 1

0

Sounds like you're describing a fairly common architecture of web apps. The client side is in HTML/CSS/JS and is responsible for presentation and UI related logic and the backend does the heavy lifting. The communication between the two is done via HTTP requests, probably asynchronous (AJAX) to REST endpoints your server provides.

This is a proven method in terms speed,compatibility and security. Pretty much every website out there uses something like this.

To get started you'll need a REST server running, I recommend using Dropwizard which allows you to setup a RESTful server fairly quickly and easy. Although if you have special scalability requirements you might want to look at other frameworks.

Here's an example of how an REST endpoint looks like in Dropwizard.

@GET
@Timed
public Saying sayHello(@QueryParam("name") Optional<String> name) {
    return new Saying("Hello " + Name);
}

The name variable is being sent from the client side (JS/AJAX) and then you have a standard Java function where you can do whatever you want. Finally you return some kind of result (Saying) and parse the result on your client side.

Sign up to request clarification or add additional context in comments.

3 Comments

Ideally, I would like to find an initial framework that is easy to implement, can be used with java, and can satisfy small scale requirements initially (< 1000 users a day), then be upgraded later after a round of VC funding, for example. Is there perhaps one or two you could recommend? In your opinion, is Rest more of a limited yet easy to implement (low learning curve) solution, or more of a powerful yet painful to learn option?
And this would just let me (noob alert) write a Java Method, for example, then just send it some data, process, and return an array with the result, which could be processed via HTML canvas?
@NateNeuhaus REST is an architecture, not a product/framework and it's sounds like it's what you need. The concepts are fairly simple to understand. You can build a RESTful server with other frameworks such as Play! and Spring. I've added an example of how an REST endpoint looks like

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.