JSP Introductions new1.pptx - JSP Java Server Pages Apr 3 2013 A \u201cHello World\u201d servlet(from the Tomcat installation documentation public class

JSP Introductions new1.pptx - JSP Java Server Pages Apr 3...

This preview shows page 1 - 7 out of 30 pages.

Apr 3, 2013 JSP Java Server Pages
Image of page 1
2 A “Hello World” servlet (from the Tomcat installation documentation) public class HelloServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String docType = " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " + "Transitional//EN\">\n "; out.println(docType + " <HTML>\n " + " <HEAD><TITLE>Hello</TITLE></HEAD>\n " + " <BODY BGCOLOR=\"#FDF5E6\">\n " + " <H1>Hello World</H1>\n " + " </BODY></HTML> "); } } This is mostly Java with a little HTML mixed in
Image of page 2
HelloWorld import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType(" text/html "); PrintWriter out = response.getWriter(); out.println(" <html> "); out.println(" <body> "); out.println(" <head> "); out.println(" <title>Hello CS764!</title> "); out.println(" </head> "); out.println(" <body> "); out.println(" <h1>Hello CS764!</h1> "); out.println(" </body> "); out.println(" </html> "); out.close(); } }
Image of page 3
4 Servlets The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java , with a little HTML mixed in The HTML is enclosed in out.println( ) statements JSP ( Java Server Pages ) is an alternate way of creating servlets JSP is written as ordinary HTML , with a little Java mixed in The Java is enclosed in special tags, such as <% ... %> The HTML is known as the template text JSP files must have the extension .jsp JSP is translated into a Java servlet, which is then compiled Servlets are run in the usual way The browser or other client sees only the resultant HTML, as usual Tomcat knows how to handle servlets and JSP pages
Image of page 4
JSP Introduction JavaServer Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. JSP have access to the entire family of Java APIs, including the JDBC API to access enterprise databases. JavaServer Pages (JSP) is a technology for developing web pages that support dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>.
Image of page 5
Why Use JSP?
Image of page 6
Image of page 7

You've reached the end of your free preview.

Want to read all 30 pages?

  • Fall '19
  • JavaServer Pages

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes