1 / 9

JavaServer Pages (JSP)

Learn how to simplify the delivery of dynamic web content using JavaServer Pages (JSP). JSPs are an extension of servlet technology and are used when most of the content is fixed template data with a small portion generated dynamically with Java code.

tshannon
Download Presentation

JavaServer Pages (JSP)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaServer Pages (JSP) IST 411 Lecture 7 Spring 2004

  2. JavaServer Pages • JavaServer Pages are an extension of servlet technology • Simplify the delivery of dynamic Web content • JSPs used when most of the content sent to the client is fixed template data and only a small portion is generated dynamically with Java code

  3. JavaServer Pages • JSPs normally execute as part of a Web server • Server is referred to as the JSP container • When first request for a JSP, the JSP container translates it into a Java servlet • Errors compiling the new servlet are translation-time errors

  4. JavaServer Pages • Request / response mechanism and life cycle of a JSP is the same as that of a servlet • JSPs define jspInit and jspDestroy which are similar to servlet init and destroy • JSP expressions are delimited by <%= and %> <%= new java.util.Date( ) %> JSP container converts the result of every JSP expression into a String that is output as part of the response

  5. JavaServer Pages • JSPs support 3 comment styles: • JSP comments <%-- and --%> • XHTML comments <!-- and --> • May not be placed inside scriptlets • Comments from scripting language (Java comments) • // comment • /* and */

  6. JavaServer Pages • Declarations may be made for variables and methods • Variables become instance variable • Use Java syntax <%! int counter = 0; %>

  7. JavaServer Pages • Let’s Practice.

  8. Project 4 • Create a student database with student ID number, name, exam1 score, and exam2 score. • Using servlets: • Use a form to enter the data into the database • Retrieve the data and display each student’s average for the course

  9. Project 4 • Will need to use: dbResult = dbStatement.executeUpdate(query); • Will need to use the SQL command INSERT INTO INSERT INTO student (field1, field2) VALUES (‘Sue’, ‘Smith’)

More Related