1 / 11

Best Practices and Example JSP Application Development

This document outlines the essential structures and best practices for developing web applications using JavaServer Pages (JSP). It covers crucial components, including directives, declarations, expressions, and scriptlets, providing examples to illustrate each concept. The document emphasizes the utilization of directives to organize JSP pages effectively and includes practical examples of how to implement them in a web application context. Learn how to structure your JSP pages for optimal performance and maintainability in web application development.

deon
Download Presentation

Best Practices and Example JSP Application Development

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. JSP Example and Best Practices Minpo, Jung

  2. Web Application Architecture

  3. Patterns for Web Application Development Servlet model

  4. Moving to JSP Model 1

  5. Moving to JSP Model 2

  6. JSP Processing

  7. Structure of a JSP Page • JSP page = directives + declarations + expressions + scriptlets

  8. Directives • An example of the page directive <%@ page import="java.util.Date, java.io.*“ extends="myJSPpage“ buffer="32k" autoflush="false" %> <jsp:directive.page import="java.util.Date, java.io.* " extends="myJSPpage" buffer="32k" autoflush="false" /> <%@ include file="/legal/disclaimer.html"> <jsp:directive.include file="/templates/footer.html" />

  9. Declarations <%! int balance = 0; %> <%! public int getAccountBalance() { return balance; } %> <jsp:declaration> int balance = 0; </jsp:declaration> <jsp:declaration> public int getAccountBalance() { return balance; } </jsp:declaration>

  10. Expressions • Hello, my name is <%= getName() %>. How are you? • out.println("Hello, my name is "+ getName() + ". How are you?"); • <% StringBuffer sb = new StringBuffer(); • sb.append("Hello, my name is ""); • sb.append(getName()); • sb.append(". How are you?); • out.println(sb.toString()); • %> <jsp:expression></jsp:expression>

  11. Scriptlets • <% for (int n=0; n<10; n++) { • out.println(n); • out.println("<br>"); // Line break • } • %> • <jsp:scriptlet> • for (int n=0; n<10; n++) { • out.println(n); • out.println("<br>"); // Line break • } • </jsp:scriptlet>

More Related