heyas, i am curious about servlets, and their intercommunication with other classes. I have bought a book called "A programmers guide to servlets, jsp and enterprise javabeans" by Lennart Jorelid. The introduction claims: "Servelts are pieces of business logic that may be plugged into any server process that accepts a binary or textual request stream.. " however my interest is in more practical examples and i was hoping if you guys could clarify some things for me: 1) is a servlet like a 'server application'? does it have a specific extension or is it just .class. 2) is a server-side program like tomcat required for running these servlets? 3) does it have access restrictions, or should i be able to use jdbc etc with a servlet? 4) can anything communicate with a servlet? for instance, an applet, on application, jsp etc? if so, can they make requests for serialized objects to be streamed through to it? the reasoning for my increasing interest is firstly to expand my knowledge on java. secondly, it is because i have written an applet which is currently in a 'sandbox' and thus cannot make use of jdbc. for that reason i was hoping to have a servlet for the database communication, which would generate a whole lot of objects based on an sql database -code to which i have already, sucessfully written. I then want my applet (when downloaded on a persons machine) to have all the objects that the servlet generated, so that the communication stops, and then the applet can make standalone queries and graphs based on the objects its recieved. please remember i have coded every relevant part of this, except at current the applet runs within a frame of an application (so that jdbc can be used) and obviously there is no server-client communication, but rather just a stand-alone application. So my final questions are as follows: -from what i have described, are servlets relevant? -does my understanding of the use seem on or off track? -would this be the best way to achieve the applet to server-jdbc communication? thanks in advance for all your thoughts and suggestions -twans
1 - Yes Servlet is a server side component which runs on Server. Its just like a class in java and has the .class extension. 2 - Yes we need a WebServer(Tomcat etc) or Application Server(JRun,Weblogic etc) to run Servlets. 3 - Yes you can use JDBC or any type of java code which you can use in a java class file. 4 - Yes Servlets can communicate to JSPs and Servlets of course,EJBs
posted 16 years ago
so i was on the right track thanks for your reply. just for my last question. About whether this method is the most EFFECTIVE one, would you agree? Is it the only method of communication with applets? cheers -twans
just for my last question. About whether this method is the most EFFECTIVE one, would you agree? Is it the only method of communication with applets?
There are many options for applets to communicate with server side components and to say that one is more effective than others really depends on what the applet does. You can avoid a web container altogether if you wish by using an RMI server. Applets can also communicate directly with EJBs, Web Services, or a custom object server over sockets. The big problem you have with any applet is really the security restrictions placed on them, known as the sandbox. There are ways around the restrictions though if the user of the applet agrees.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
posted 16 years ago
great. Thanks for the clarification guys. appreciate it.
Just to clarify....you want to have a web-app/applet combo that when the user accesses it, the servlet will do all the work and the applet will just display the info and allow the user to interact with it with (what sounds like) no more data being retrieved from the server. I just did something just like this. The user hits a URL with some parameters, the server does a bunch of stuff in the backgorund (that could take 30 seconds or even a minute to finish). The user sees a wait page during this time. Once hte data is retrieved/processed, the user is redirected to a .jsp that contains an applet. The applet tag code has all of the data in it for the applet to load and use. Once the applet comes up with the data, the user can interact with it but the apple tactually makes no more requests of the server to get more dta - all the data is in the containing JSP (HTML). This sounds like what you want to do. If so, and if you have further questions about this, just ask! Brian