I started working on this because I think that the need for it will
continue to grow.  I'm aware of the Sun FAQ that gets posted weekly, but
I was thinking that something a little more detailed might do some
good.  Please take a look at this, and let me know what you think...
It's far from complete, but I wanted to get it out because these always
work much better when there's a community effort... :-)

--
Within C++ is a smaller, cleaner language
struggling to get out.
It's called Java.

Thomas Moore
[EMAIL PROTECTED]        Home Account
Software.Engineer         [EMAIL PROTECTED]
phone://732.462.1880:268  NJ Patterns Group Home Page
employer://Celwave, RF    http://members.home.net/twmoore/cjpg
The Java Servlet FAQ
0. About This FAQ
1. Introduction To Servlets
2. Just The FAQs - Answers to common questions
3. Servlet Engine Specific Questions
4. Other Servlet Resources
---
Section 0 - About This FAQ

0.1 Why did you write this FAQ?
    Servlets are a very popular topic right now.  They enable Java
    programmers to write powerful applications for that thin and
    ubiquitous client, the web browser, without the overhead or
    implementation issues that are still inherent in today's
    browsers.  The backgrounds of people seem to be a mix of
    experienced Java appication/applet programmers and experienced
    perl/C/C++/etc. CGI programmers (as well as people fairly new
    to the field in general).  The parties each bring their own skill
    sets to the table.  This FAQ is meant to be a starting point
    for both groups, as well as serving as a general introduction
    to the technology.
    Besides, servlets (not unlike Java itself) can be somewhat of a
    moving target.  There are enough changes in the works, and enough
    new information being introduced, that a single resource pointing
    to that information would be very useful.

0.2 What does this FAQ cover?
    This FAQ consists of answers to some of the topics that come up
    most frequently on Sun's Servlet-Interest mailing list, as well
    as contributions from servlet programmers.  It is meant to be a
    quick source for general information as well as a pointer to
    more in-depth resources.

0.3 What isn't in this FAQ?
    First, this FAQ is not a tutorial on Java, servlets, or anything else.
    There are countless FAQs on the Java programming language, and people
    who have questions regarding Java programming in areas other than
    servlets are encouraged to look to them for answers.  This is also not
    meant to take the place of in depth resources and tutorials.  There
    are several books on the market today, as well as several websites, that
    step new programmers through learning the servlet interface.  See the
    section on Other Resources for more information.

0.4 I disagree with something the FAQ says.  How can I correct it?
    Send corrections/opinions/flames to [EMAIL PROTECTED]

0.5 You don't say anything about <foo>.  I think the FAQ should have this
    information.  What should I do?
    See Question 0.4
---
Section 1 - Introduction to Servlets

1.1 What is a servlet?
    A servlet is an application or a script that is written in Java and
    executed on a server, as opposed to on a client.  It is analagous to
    CGI, although servlets are more than simply CGI scripts written in Java.
    See question 1.2 for more detail.

1.2 How is a servlet different from CGI?
    CGI (the Common Gateway Interface) is a protocol that allows clients
    using web browsers to send information to and retrieve information
    from servers via programs set up on the server.  CGI provides a set of
    methods that can parse information coming from a web browser.  The
    information can then be handled by the program, often written in C, C++,
    or (perhaps most commonly) perl.  It is frequently used to generate
    "dynamic" web content, that is, it generates HTML on the fly, which
    is displayed on the client's browser as if it were a standard .html
    file located on the server.
    Servlets are similar in that, in their most common form, they allow
    for dynamic interaction between a web browser and programs on the
    server, accepting data via http and sending back HTML code.  However,
    servlets are not simply CGI programs written in Java.  It is possible to
    cross the two technologies, but it generally involves using something
    to intermediate between the OS and the Java VM (often a shell script).
    Servlet technology makes this intermediary scripting unnecessary.
    Sevlets run on a server engine, often running within, or in cooperation
    with, the server's Web software.

1.3 Are servlets better than CGI?
    This is something of a religious question (See "Holy Wars" in the
    Jargon File).  It is somewhat akin to asking whether C++ or Java
    Servlets offer several advantages over CGI.  They fall into two
    main categories:  design and performance.
    In terms of design, Java is an object oriented language.  While it
    is not impossible to construct badly designed Java programs, the
    language itself encourages adherence to object oriented
    principles.  While this is not the place to carry on Java/C++/
    Smalltalk/etc. debates, I will just say in general that Java
    (and servlets in particular) enable and encourage handling
    requests with a cascade of specialized objects.  It makes it less
    likely that a programmer will do everything in one big script.  This
    segmented design can lead to easier revision and maintainence, and
    encourages software reuse.
    For performance, servlets are only instantiated when the client
    first accesses the program.  That is, the first time any client
    hits the URL that is used to access the servlet, the servlet
    engine instantiates that object.  All subsiquent accesses are done
    to that instance.  This keeps the response time of servlets lower
    than that of CGI programs, which must be run once per hit.  Also,
    becasue a servlet is instantiated only once, all accesses are put
    through that one object.  While this does cause issues with regard
    to current threads of execution, the programmer can address them
    by having certain objects be unique to a user's session and others
    shared (with synchronized concurrency locks where necessary) among
    all users.  Java's simple multithreading syntax makes this fairly
    easy.

1.4 What servlet engines are available?  What servlet engines will
    work with my web server?
    There are several servlet engines available.  The one you select
    will be determined by you web server platform, your budget, and/or
    your personal preferences.
    <insert table here with hardware/web server/engine/non-commercial
    cost/commercial cost>

1.5 What discussion forums are there for servlets?
    The servlet mailing list hosted by Sun is currently the largest
    single forum for discussing servlet related issues.  It has its
    own FAQ, but it does stand to mention that the list has
    historically been a very valuable resource for programmers, with
    both a high signal-to-noise ratio and a fast response time to
    member's questions.  Please consult the list's FAQ before posting,
    and remember that your emails go out to the entire list membership
    - people who subscribed specifically to get servlet related
    information.
--
Section 2 - Just The FAQS

2.1 How do I upload a file?
    Form based file upload requires a couple of steps.  The server
    must supply (and the client must support) encoding type
    multipart/form-data.  Most current browsers do, but it's not a
    guarantee.  Secondly (and this is usually the trickiest part),
    your servlet has to parse the binary data and do something with it
    (e.g., write it to a file on the server).  The intrepid programmer
    is referred to RFC 1867 for cluefulness on how to parse this
    data.  Less brave souls can use either Jason Hunter's
    implementation of a MultipartRequest (available from
    www.servlets.com), or CParseRFC1867 (available
    from www.servletcentral.com).  Note that the source code is
    available for both of these examples, but both assume that you
    will be writing the file to a file on the server.  Other uses
    (e.g. storing the file as a binary object in a database) will
    require adaptation.

2.2 How can I get a servlet to send EMail?
    [This section will mention some of the more popular Java email
    packages, and will make cautious mention of Jason's use of the
    internal sun package, since that seems to be a topic of
    discussion/flame]

2.3 What is the Session object and how do I use it?
    [This section will mention what a session is, how it works, and
    rudiments on how to use it to do different things, e.g., hold
    objects like database connections or specific data generated
    during the session]

2.4 What is servlet chaining?  How do I chain servlets?
    [This section will explain the difference between chaining
    servlets and forwarding requests]
--
Section 3 - Servlet Engine Specific Questions

3.1 Sun's Java Web Server

3.2 Live Software's JRun

3.3 Apache JServ

--
Section 4 - Other Servlet Resources

4.1 What web based sources talk about servlets?

4.2 What are some good books about servlets?

4.3 Where can I get my servlets hosted?




Reply via email to