Should i use Applet or Servlet
All
I have created an applet before and understand how to use all the functionality in Swing. Everybody keeps telling me how Servlets are the new and better technology to use.
I have to build a GUI of a crossword puzzle, so that users can enter letters to show the puzzle etc.
What i dont understand!
Q1. Can you use the swing functionality in servlets? or how do you get buttons, panels etc in servlets?
Q2. In your opinion should I use the applet or servlet for my problem and why please?
I am newbie at this topic..go easy!
thanks in advance.
> What i dont understand!
> Q1. Can you use the swing functionality in servlets?
> or how do you get buttons, panels etc in servlets?
Servlets are server based objects that process the content on a server and return the processed data back to the user. The data processed is usually in text format so that the end browser may be able to display it. Swing functionality means that Java runtime must be installed in the client's computer, unlike servlets which just ned a web browser. Servlets, thus, cannot implement swing buttons, which are HTML components.
>
> Q2. In your opinion should I use the applet or
> servlet for my problem and why please?
>
If it is static content, why not? But if the users interact in real time, applets will do, yes, but servlets are better.
Jamwaa at 2007-7-12 19:00:35 >

> I have created an applet before and understand how to
> use all the functionality in Swing. Everybody keeps
> telling me how Servlets are the new and better
> technology to use.
BS. Right tool for the right job.
> I have to build a GUI of a crossword puzzle, so that
> users can enter letters to show the puzzle etc.
>
> What i dont understand!
> Q1. Can you use the swing functionality in servlets?
First, servlets are MVC controller, not MCV view like applets. If at all, you're talking about JSPs here.
Second: no. After all, a servlet or JSP will only serve HTML for the client's browser. You can do whatever HTML can do, and that does not include showing Swing widgets, unless embedding an applet.
> or how do you get buttons, panels etc in servlets?
See above.
> Q2. In your opinion should I use the applet or
> servlet for my problem and why please?
Applet because I'm pretty sure that you have webspace available, but no servlet containre or app server. Further, applet, because you know how it works. Lastly, applet, because visualization of your GUI in HTML might be a PITA.
thanks for your advice Java Gods. I am learning!
Go for Java Server Faces. http://www.coreservlets.com/JSF-Tutorial/Regards
Gantua at 2007-7-12 19:00:35 >

For something like this, the answer may well be both. You may well want a generic crossword doing applet, and feed it details of the specific crossword from a database or the like. The applet may invoke a servlet to fetch the data.
but the applet can retrieve data from the database. why use servlet for that?Message was edited by: crashEvans
> but the applet can retrieve data from the database.
> why use servlet for that?
>
Mainly because it can't.
The client may well be outside of your local network, and a firewall should definitely bar access to databases from such a client.
And, unless digitally signed and given special permission, applets are limited to their area on the browser window, and to accessing the web site from which they came. They aren't allowed access to local files or to database connections.
> but the applet can retrieve data from the database.
> why use servlet for that?
If you directly use an Applet, you will have to expose the port, user name and password in your applet so that anyone will be able to access all the data in any way that they want. This also means that your firewall will require another open port.
> All
>
> I have created an applet before and understand how to
> use all the functionality in Swing. Everybody keeps
ALL of it? You must be the only person in the world...
> telling me how Servlets are the new and better
> technology to use.
>
New doesn't always equate better. And even if it does it needs to be qualified as to WHAT it is supposedly better for.
> What i dont understand!
> Q1. Can you use the swing functionality in servlets?
no
> or how do you get buttons, panels etc in servlets?
>
servlets generate (typically) html or other text output.
> Q2. In your opinion should I use the applet or
> servlet for my problem and why please?
>
both can work, depending on what you want to achieve.
oh my god! How am i suppose to have discovered that?! any further info on using web based applets? I have created an applet which i plan on making webbased, and it accesses a database!
All applets are considered to be webbased.
If you mean, combined with servlet or JSP: no info, because no info is needed. What's the difference between an HTML page that was provided by a webserver, an HTML page that was provided by a servlet container, and an HTML page that e.g. was provided by a PHP server? Pretty much none.
So just make sure that the HTML looks like it's supposed to look like.
> oh my god! How am i suppose to have discovered that?!
> any further info on using web based applets?
>
> I have created an applet which i plan on making
> webbased, and it accesses a database!
You applet should only talk to one of your servlets and the servlet should talk to the database. In this way the database access information is never available to the client Applet.
http://www.unix.org.ua/orelly/java-ent/servlet/ch10_01.htm
Message was edited by:
sabre150