Running java on the server side?


T

tadamsmar

I am looking into eliminating Java applets from a hobby website of mine.

The web currently has 2 applets that accept some configuration data and then do some calculations and display the results.

I am wondering if I can create Html accepts the configuration data, sends it to the server where a java application can run to crunch the results and create an html page. Then, the html page can be displayed.

That way I can use the existing number crunching code in Java and have the interface all in Html and hopefully get rid of all the security issues of trying to run a program in the client.

I have pretty limited web development skills. Heck, I thought applet development would be most of the skill I would need for this hobby!

Also, and better ideas for making the web site easier to use? I don't know that this is the best solution.

The web site is www.poologic.com. The applets are the poologic calculator and the roi calculator.
 
Ad

Advertisements

A

Arne Vajhøj

I am looking into eliminating Java applets from a hobby website of mine.

The web currently has 2 applets that accept some configuration data and then do some calculations and display the results.

I am wondering if I can create Html accepts the configuration data, sends it to the server where a java application can run to crunch the results and create an html page. Then, the html page can be displayed.

That way I can use the existing number crunching code in Java and have the interface all in Html and hopefully get rid of all the security issues of trying to run a program in the client.

I have pretty limited web development skills. Heck, I thought applet development would be most of the skill I would need for this hobby!

Maybe you could replace the applet with some JavaScript?

You can run Java server side if your server supports it.

Most cheap web hotels targeting personal usage does not support Java.

Arne
 
S

Silvio

I am looking into eliminating Java applets from a hobby website of mine.

The web currently has 2 applets that accept some configuration data and then do some calculations and display the results.

I am wondering if I can create Html accepts the configuration data, sends it to the server where a java application can run to crunch the results and create an html page. Then, the html page can be displayed.

That way I can use the existing number crunching code in Java and have the interface all in Html and hopefully get rid of all the security issues of trying to run a program in the client.

I have pretty limited web development skills. Heck, I thought applet development would be most of the skill I would need for this hobby!

Also, and better ideas for making the web site easier to use? I don't know that this is the best solution.

The web site is www.poologic.com. The applets are the poologic calculator and the roi calculator.

You could do this easily with a servlet or two but to do that you would
need a server that you can deploy your servlet to.

If it is worth you some money and you can handle a Linux server you
could set yourself up with a DigitalOcean cloud server. They start at 5$
per month.

Cheers,

Silvio
 
R

Roedy Green

Also, and better ideas for making the web site easier to use? I don't know that this is the best solution.

The easiest thing to do would be to convert to a app which you run
locally. All you need is a main method tacked on. See
http://mindprod.com/jgloss/hybrid.html
for how.

Next hardest is convert to Java Web Start.
See http://mindprod.com/jgloss/javawebstart.html

Hardest is to write JSP or some other server side servlet code.
see http://mindprod.com/jgloss/jsp.html

The biggest problem is getting permission to meddle with server side
code. You may need to find a new ISP.
see http://mindprod.com/jgloss/ispvendors.html
 
A

Arne Vajhøj

The easiest thing to do would be to convert to a app which you run
locally. All you need is a main method tacked on. See
http://mindprod.com/jgloss/hybrid.html
for how.

Easy to replace a web page using applets with an application?

That depends a bit on what those applets are doing.

If they are interacting with the page, then it is not an
easy port.

Sure you can make the applet itself to an application, but if
the applet is used for navigation in a web page, then that is not
a full solution.

Arne
 
Ad

Advertisements

A

Arne Vajhøj

I am looking into eliminating Java applets from a hobby website of mine.

The web currently has 2 applets that accept some configuration data
and then do some calculations and display the results.

I am wondering if I can create Html accepts the configuration data,
sends it to the server where a java application can run to crunch the
results and create an html page. Then, the html page can be displayed.

That way I can use the existing number crunching code in Java and have
the interface all in Html and hopefully get rid of all the security
issues of trying to run a program in the client.

I have pretty limited web development skills. Heck, I thought applet
development would be most of the skill I would need for this hobby!

Also, and better ideas for making the web site easier to use? I don't
know that this is the best solution.

The web site is www.poologic.com. The applets are the poologic
calculator and the roi calculator.

Here's some outline code, there is no exception handling and there
are a million other ways of doing it but this covers the basics.

[getdata.html]
...
<form action="/pathToSomeServlet" method="post">
<input type="text" name="field1">
...
//more input fields
...
</form>


[SomeServlet.java]
...
protected void doPost(HttpServletRequest request, ...){

HttpSession session = request.getSession();
String field1 = request.getParameter("field1");
...
//get more parameters
...

List<Foo> list = processParams(field1, field2, ...);
//or
List<Foo> list = processParams(HttpServletRequest request);

...
session.setAttribute("results", list);
...
String forwardTarget = "/someJsp.jsp");
RequestDispatcher rd = null;
rd = getServletContext().getRequestDispatcher(forwardTarget);
rd.forward(request, response);
}


[someJsp.jsp]

List<Foo> results = (List<Foo>)session.getAttribute("results");

for(Foo f: results){
//render f
}

//etc

There are all sorts of frameworks out there, there are all sorts of
custom tags out there and there are a million naysayers and doom mongers
just waiting to pull any solution you come up with to bits.

My philosophy?

Keep It Simple
and
If it feels good ... do it

Simple is often good

But you could probably make it even simpler by:
- storing data in request instead of session
- use JSTL for display

Arne
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top