Presentation is loading. Please wait.

Presentation is loading. Please wait.

Servlets Part 3. Topics Session Tracking ServletToServletCommunication-Servlet Chaining ServerSideIncludes AppletToServlet.

Similar presentations


Presentation on theme: "Servlets Part 3. Topics Session Tracking ServletToServletCommunication-Servlet Chaining ServerSideIncludes AppletToServlet."— Presentation transcript:

1 Servlets Part 3

2 Topics Session Tracking ServletToServletCommunication-Servlet Chaining ServerSideIncludes AppletToServlet

3 Server-Side Includes and Request Forwarding Server Side includes (SSI) allow you to embed servlet calls within an HTML document using tag. By convention, these documents should use the.shtml extension – indicating to the server that the HTML document includes SSI directives and should be passed to a specialized SSI servlet for processing. This special servlet (called SSIncludesServlet in Java Web Server) parses the tags. When the tag is included, the SSIncludesServlet loads the servlet specified by the tag and includes the servler output in the HTML page returned to the client.

4 Server-Side Includes and Request Forwarding Syntax of the servlet tag <servlet name=SERVLET_NAME code=CLASS_NAME codebase=CLASS_LOCATION_URL INIT_PARAM1=VALUE1 INIT_PARAM2=VALUE2 INIT_PARAM3=VALUEn >

5 Server-Side Includes and Request Forwarding HTML Page using SSI to add a header and a footer Servlet API Some of these servers support Java Servlet API Web Logic, IBM Visual Age..

6 Servlet Chaining Servlet chaining is the process of passing the output of one servlet to the input of another. This feature is similar to piping in UNIX. The client request is sent to the first servlet in the chain. Once the request has been processed by the servlet, it passes it soutput to the next servlet in the chain. This process continues through any number of servlets until the last servlet’s output is returned to the client. Servlet chain configuration is server-specific.

7 Applet To Servlet A servlet can generate a page with parameter values set to be passed to the embedded applet. Example: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = new PrintWriter ( response.getOutputStream()); out.write(" HTML Manipulation Example "); out.write("This applet receives data from the server via its PARAM tag"); out.write(" "); out.write("<param name=\"Data\" value=\""; ); out.write("\">" ); out.close(); }

8 Applet To Servlet See files MemberServlet.java and MemberApplet.java


Download ppt "Servlets Part 3. Topics Session Tracking ServletToServletCommunication-Servlet Chaining ServerSideIncludes AppletToServlet."

Similar presentations


Ads by Google