Developing Web Applications With Ant by Richard Hightower - HTML preview
Download the book in PDF, ePub, Kindle for a complete version.
HelloWorld.jsp
HelloWorld.jsp exists to display the message it gets from the Greeting reference that HelloWorldServlet mapped into that session. The HelloWorld.jsp code looks like this:<jsp:useBean id="greeting" type="xptoolkit.model.Greeting"
scope="session"/>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1><%=greeting.getGreeting()%></h1>
</body>
<jsp:useBean id="greeting" type="xptoolkit.model.Greeting"
scope="session"/>
<h1><%=greeting.getGreeting()%></h1>
Notice that the jsp:useBean action grabs the Greeting reference that we put into the session with HelloWorldServlet. Then, we print out the greeting with the JSP scriptlet expression <%=greeting.getGreeting()%>.
This sums up what the Model 2 Hello World Web application does. We discuss the other JSP, HelloApplet.jsp, after we examine the applet subproject. For now, the next section explains why the servlet could forward HelloWorldJSP to the JSP HelloWorld.jsp.
