This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See thread to our JSP forum (up at the top of the main Saloon page). Can somebody there please clue Tim into some good beginner's resources?
Sticking with Java, does it really need to be a stand-alone app, or are you willing to adopt a more web-friendly solution?
If you code your logic into a encapsulated, reisable class (you know, that whole OO thing) such that it could be called both from a stand-alone app or a servlet (or any other Java class for that matter), your job will be much much easier.
Not only that, but it's just good OO design. [ September 20, 2006: Message edited by: Bear Bibeault ]
The stand alone app I have created works fine from a DOS box, it's just not pretty. I could write into the app some Swing code to make a nice GUI. But thats not what I'm trying to figure out.
Here is another example: If I create an app or class to add 3 values together I can, in DOS, type 'Java appName 1 2 3' and the values are passed to the app from DOS. The sum of these 3 values would be returned to DOS using the Print command and a 6 will be displayed.
OK thanks. So the way I have coded it only accepts input via the command line.
What I am trying to do is have the code be accessed by various front ends. At the moment I want it to be accessed from a Web page. Later I would indeed like to port it to a Cell phone. So I thought that if I created an app to 'do the math' I could then get various front ends to access it.
The first thing is to get it to talk to a web page. Can you tell me how I can achieve this?
Originally posted by Bear Bibeault: Npoe, first thing to do is to create the UI-agnostic class that does the work, Until you do, there's nothing to tie your web UI to.
Here's a UI Agnostic class that happens to have one UI built in; the main method.
This class can be called from the command line but it could also be instanciated from a servlet.
This has the separation that Bear talked about. The UiAgnosticThing object has no idea that it's being run in a servlet app and doesn't care. It would work just find if called from a Swing app or from its built in main method from the command line.
Likewise, the servlet has no idea how UiAgnosticThing works. It could be making database calls, webservice calls, system calls, etc... The servlet app doesn't care, it just knows that it can instanicate it and call it's methods.
Help? [ September 20, 2006: Message edited by: Ben Souther ]
I am not sure I am going to address your question in the way you intend. But if you were to have a jsp page which had embedded on it a java applet, you could communicate from the jsp page to the java applet in the following manner:
- The jsp page has a variable it wishes to pass to the applet - When it constructs the web page, it puts the variable into the html. Every applet has "params" which are part of the applet description: