Web Server

There are numerous available web servers. I used to suggest using our UNIX machine (running Tomcat) to deploy your servlets, but due to lack of control
(getting newer versions of the servlet to run, etc), I now suggest that you download Eclipse (and for the last lab Tomcat also) and run it on your own machine.
I will be running that configuration on mine so you can send me a war file (more on that later) once yours is running fine on your own server. Here is access to downloads for your own use:

Although we are not using the J2EE Application Server, there are notes in the J2EE Tutorial Chapter 3 with nice diagrams of how J2EE servers are set up (local same page)

Linking Servlets and JSPs (Three Ways to Redirect the User)

There are different ways to connect your servlets and JSPs.

  1. Indirectly: Simply provide a link

    "A web component indirectly invokes another web resource when it embeds a URL that points to another web component in content returned to a client." ShowCartServlet.java (gets a session too).
    response.encodeURL( ... )

  2. response.sendRedirect

    Another alternative, if you are moving to a page that does not need the current servlet anymore, is to invoke sendRedirect on the response object and pass it the next servlets URL. (Core Servlets (page 125) and page 9 (of 30). For example, after someone fails to log in, you might want to direct them to an application form:
    response.sendRedirect("http://localhost:8080/myWarDir/ApplicationForm");
    For examples: See O'Reilly Course 6 Lesson 8

  3. include and forward

    The page (Web App Life Cycle) in the tutorial is quite useful for linking JSPs.

    This is a nice chapter - it ties a lot of things together. The Web App Life Cycle section shows code for how one servlet can tell the next one information about the context through a RequestDispatcher . Here is another link about sharing information and an example of its use invoking other web resources and transferring control (forward and include)
    Note use of dispatcher.include(request, response); and dispatcher.forward(request, response);

    To see what is happening here, Marty Hall has a nice link to some example code on his Request Forwarding snippet
    For examples: See O'Reilly Course 6 Lesson 13


  4. ( which? )

The J2EE API (1.4 local)