    All Examples  This Package

# Class examples.servlets.SurveyServlet

    java.lang.Object
       |
       +----javax.servlet.GenericServlet
               |
               +----javax.servlet.http.HttpServlet
                       |
                       +----examples.servlets.SurveyServlet

public class SurveyServlet
extends HttpServlet

This example servlet takes input from a form and writes it out to a simple text file. After the results are written to the file, the servlet returns a "thank you" to the user. This example has been modified from the SurveyServlet that is distributed with the JSDK2.0 - see note below.

Note: This servlet has been modified from the SurveyServlet that is distributed with the JSDK2.0 so that it does not implement the SingleThreadModel. WebLogic does not support the SingleThreadModel. This model is of limited value, and the original JavaSoft example illustrated here is bogus with respect to ensuring that output to the text file is guarded against simultaneous access from multiple servlet threads. Although the SingleThreadModel does prevent a sevlets engine from invoking a servlet instance with multiple threads simultaneously, the spec describes that the server may initialize any number of servlet instances. In this example these servlet instances would all access and write to the same file - possibly simultaneously, regardless of the SingleTreadModel interface. See the note in the WebLogic servlet developer's guide for more details.

##

SurveyServlet()

##

doPost(HttpServletRequest, HttpServletResponse)
  Write survey results to output file in response to the POSTed form.
init(ServletConfig)

##

SurveyServlet

     public SurveyServlet()

##

init

     public void init(ServletConfig config) throws ServletException

  Overrides:
    init in class GenericServlet

doPost

     public void doPost(HttpServletRequest req,
                        HttpServletResponse res) throws ServletException, IOException

  Write survey results to output file in response to the POSTed form. Write a "thank you" to the client.

  Overrides:
    doPost in class HttpServlet

    All Examples  This Package