The code in Listing 2-1 is the functional equivalent to the servlet code shown in Listing 2-2. Note Recall that JSP pages get translated into servlets. However, the servlet code shown in Listing 2-2 is not the result of translating the JSP in Listing 2-1 into a servlet. The JSP translator generates a servlet that performs the same function as the servlet shown in Listing 2-2 but with different Java code . Listing 2-2: A servlet functionally equivalent to the JSP page in listing 2-1 import java.io.*; import javax.servlet.*; public class HeyItsYou extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType(”text/html”); HttpSession session = req.getSession( false ) ; PrintWriter out = res.getWriter(); out.println(”“); out.println(”“); out.println (”

Hey, it sey, it s,”); out.print(”String you = “); out.println((String) session.getAttribute( you )); out.println(user); out.println(”

“); out.println(”“); out.println(”“); } } The JSP page is smaller than the servlet, and most users agree that the JSP is easier to understand and maintain. Many others also agree that writing out HTML (or XML, of course) by way of out.println() statements is a major drag because a large page can have hundreds of out.println() statements. Hence, the bottom line is that, while JSPs and servlets often accomplish the same task, you ll still need servlets from time to time to do what JSPs cannot. Enterprise JavaBeans Enterprise JavaBeans (EJB) define an architecture that enables developers to create reusable, server-side components called enterprise beans. Enterprise beans typically reside on the application server or may have their own dedicated server. Of course, you can read much more about EJB in the following chapters. Please note that enterprise beans are not JavaBeans! One difference is that calling a JavaBean (from a servlet or JSP page) involves intra-process communication, whereas calling an EJB (from a servlet or JSP page) involves inter- process communication. You can read about other differences in the following chapters. Java Messaging Services Java Messaging Services (JMS) is an API that invokes asynchronous messaging services such as broadcast and point-to-point (client-to-client) messages.
We know it is important decision to make, effects your wallet, and the quality of your web site, so relax and visit shared web hosting.

Leave a Reply