jsp - part 2 - CNT 4714 JSPs – Part 2 Page 1 Dr Mark...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CNT 4714: JSPs – Part 2 Page 1 Dr. Mark Llewellyn © CNT 4714: Enterprise Computing Spring 2011 Introduction to JavaServer Pages (JSP) – Part 2 Department of Electrical Engineering and Computer Science University of Central Florida Instructor : Dr. Mark Llewellyn [email protected] HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cnt4714/spr2011 CNT 4714: JSPs – Part 2 Page 2 Dr. Mark Llewellyn © How A JSP Is Processed • Much like a servlet, a JSP must first be processed by a web server before it can be displayed in a web browser. The web server must support JSPs and the JSP page must be stored in a file with a .jsp extension. The web server translates the JSP into a Java servlet, compiles the servlet, and executes it. The result of the execution is sent to the browser for display. Web Browser Web Server Host Host Machine File System Servlet Engine Web Server generate response process servlet send a request URL HTML page returned How A JSP Is Processed JSP Translator get JSP file get servlet generate servlet CNT 4714: JSPs – Part 2 Page 3 Dr. Mark Llewellyn © More On JSP Scripting Constructs • There are three main types of JSP constructs: scripting constructs , directives , and actions . • Scripting elements allow you to specify Java code that will become part of the resultant servlet. • Directives enable you to control the overall structure of the resultant servlet. • Actions enable you to control the behavior of the JSP engine. • We’ll look in more detail at all of these, starting with the scripting constructs. CNT 4714: JSPs – Part 2 Page 4 Dr. Mark Llewellyn © Scripting Constructs • There are three main types of JSP scripting constructs that can be used to insert Java code into a resultant servlet: expressions , scriptlets and declarations . Recall that there are also comments and escape sequences . • A JSP expression is used to insert a Java expression directly into the output. It has the following form: <%= java expression %> • The expression is evaluated, converted into a string, and set to the output stream of the servlet. CNT 4714: JSPs – Part 2 Page 5 Dr. Mark Llewellyn © Scripting Constructs • A JSP scriptlet enables you to insert a Java statement into the servlet’s jspService method which is invoked by the service method. A JSP scriptlet has the following form: <% java statement %> • A JSP declaration is for declaring methods or fields into the servlet. It has the following form: <%! java declaration %> • HTML comments have the form: <!-- HTML comment--> • If you don’t want the comment to appear in the resultant HTML file, use a JSP comment which has the form: <%-- JSP comment--> CNT 4714: JSPs – Part 2 Page 6 Dr. Mark Llewellyn © Scripting Example ComputeLoan.html CNT 4714: JSPs – Part 2 Page 7 Dr. Mark Llewellyn © Scripting Example ComputeLoan.jsp Java statements Java expression CNT 4714: JSPs – Part 2 Page 8 Dr. Mark Llewellyn © Scripting Example CNT 4714: JSPs – Part 2 Page 9 Dr. Mark Llewellyn © Scripting Example CNT 4714: JSPs – Part 2...
View Full Document

Page1 / 32

jsp - part 2 - CNT 4714 JSPs – Part 2 Page 1 Dr Mark...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online