Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java and the Web CSE 3330 Southern Methodist University.

Similar presentations


Presentation on theme: "Java and the Web CSE 3330 Southern Methodist University."— Presentation transcript:

1 Java and the Web CSE 3330 Southern Methodist University

2 Standard Model of the Web Client Internet Web server Basic Request/Response Model Client makes a request for a static resource Web server responds with the static resource HTTP is the standard protocol

3 Generating Dynamic Content Request can contain “parameters” / “key- value” pairs of information Web server can use this data to generate dynamic content (Response) Web server isn’t just serving up static content anymore – may be taking request params and accessing a database or other service to generate content for the user.

4 Anatomy of a Servlet /webapps – TestServlet WEB-INF – web.xml – classes » TestServlet.java » TestServlet.class

5 TestServlet.java public class TestServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); /* Display some response to the user */ out.println(" "); out.println(" TestServlet "); out.println(" "); //replace YourName below with your real name. out.println(" Hello There, YourName "); out.println(" "); out.close(); }

6 web.xml <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> TestServlet TestServlet /TestServlet


Download ppt "Java and the Web CSE 3330 Southern Methodist University."

Similar presentations


Ads by Google