Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generic Question regarding servlets

Status
Not open for further replies.

ack123

IS-IT--Management
Nov 8, 2001
11
0
0
US
Hello to all, Could someone simply answer whether servlets are class files that reside on the server and are compiled on the server? So using the example of servlets residing on an iplanet webserver, would a servlet be considered a class file which is compiled by the servlet engine of the webserver? And what would be the definition of a module? Would a module be considered a small file that is made up of Java code which is invoked through JSP? Any information regarding these questions is greatly appreciated.
 
In deployment a servlet is a class file. It is misleading to say that it is "compiled" by the Web Container though. The servlet class file is passed to the JVM which interpretates it. The interpretation may involve compilation, in the case of a JIT, but this is not necessary and is abstracted from the developer. All you need to know is that you put your servlet's class file on the appropriate directory of the Web Container and it works.

I am confused by your term "module". In Java their is no component that is known simply as a module. Are you talking about a web application deployed as a .war file?
 
Thanks! This helps out tremendously.
With regards to the 'modules' (3rd paragraph) modules are referred to and this was a little confusing. I was wondering if sun was trying to define JSP as something similar to perl modules? Again, this is what was confusing to me. Any information is greatly appreciated.
 
Basically, without going into a dissertaton, a JSP is simply an HTML file with special Java tags.

Technically, a JSP page is picked up by the Web Container and translated in a Java file. The java file is then compiled into a class file and loaded in the JVM. Once this is complete the JSP page enters into the normal Servlet lifecycle (init(), 0 or more service() calls, and destroy()).

With each request (or at specified intervals) the Web Container will check to determine if changes have taken place in the JSP page. If so, the servlet will be destroy and the process will start all over again.

JSP pages hide the developer from the complexities of Servlets (though they are not really complex) and make coding mostly static HTML pages much easier.
 
Thanks again for your information, this helps me out greatly. I have one more question that seems cryptic to me and this regards the servlet directory. Without getting into too much detail, I see a form page that passes the form information into a servlet . When I check out the /servlet/servlet1 directory on the webserver I see all kinds of files. How does the server, or the servlet know what to do with the information being passed from the form page. Would a JSP file on the webserver know where to send the info that is passed from the form? Again this seems cryptic and any information is tremendously appreciated.
 
All this information is stored in the web application deployment descriptor, named web.xml. The deployment descriptor contains information as to what servlets are to be deployed, any initialization parameters, what url(s) the servlet maps to, and a number of other things. In your example the url will map directly to one servlet in the Web Container (and this mapping is in the web.xml). Thus the form is posted to a single servlet to be processed.

Again, a JSP is just a servlet in disguise. You don't need to explicitly map urls or touch the deployment descriptors for JSP pages, this is all handled for you by the Web Container.
 
Thanks again for all your information, this has been a tremendous help to me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top