A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %>

Similar documents
Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty

Servlets. An extension of a web server runs inside a servlet container

JavaServer Pages (JSP)

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab.

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session

COMP9321 Web Application Engineering

ServletConfig Interface

CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, JSPs 1

Advanced Internet Technology Lab # 4 Servlets

COMP9321 Web Application Engineering

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

Servlets by Example. Joe Howse 7 June 2011

CIS 3952 [Part 2] Java Servlets and JSP tutorial

Web applications and JSP. Carl Nettelblad

Integrating Servlets and JavaServer Pages Lecture 13

Model View Controller (MVC)

Develop an Enterprise Java Bean for Banking Operations

JAVA SERVLET. Server-side Programming INTRODUCTION

Welcome To PhillyJUG. 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation

&' () - #-& -#-!& 2 - % (3" 3 !!! + #%!%,)& ! "# * +,

Stateless -Session Bean

CSC309: Introduction to Web Programming. Lecture 10

COMP9321 Web Application Engineering

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

JavaServer Pages. What is JavaServer Pages?

UNIT 6:CH:14 INTEGRATING SERVLETS AND JSPTHE MVC ARCHITECTURE

Advance Java. Configuring and Getting Servlet Init Parameters per servlet

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC)

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks

More JSP. Advanced Topics in Java. Khalid Azim Mughal Version date: ATIJ More JSP 1/42

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle

Component Based Software Engineering

Introduction. This course Software Architecture with Java will discuss the following topics:

JSP. Common patterns

Integrating Servlets and JSP: The MVC Architecture

CE212 Web Application Programming Part 3

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

1. Introduction. 2. Life Cycle Why JSP is preferred over Servlets? 2.1. Translation. Java Server Pages (JSP) THETOPPERSWAY.

01KPS BF Progettazione di applicazioni web

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP:

JAVA. Web applications Servlets, JSP

Java Server Pages JSP

Servlets and JSP (Java Server Pages)

To create a view for students, staffs and courses in your departments using servlet/jsp.

DEZVOLTAREA APLICATIILOR WEB CURS 7. Lect. Univ. Dr. Mihai Stancu

JSP Scripting Elements

Advanced Web Technology

Web. 2 Web. A Data Dependency Graph for Web Applications. Web Web Web. Web. Web. Java. Web. Web HTTP. Web

********************************************************************

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

COMP201 Java Programming

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4

Java E-Commerce Martin Cooke,

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Session 20 Data Sharing Session 20 Data Sharing & Cookies

Servlet and JSP Review

JSP. Basic Elements. For a Tutorial, see:

Fast Track to Java EE 5 with Servlets, JSP & JDBC

Servlet Basics. Agenda

Servlet Fudamentals. Celsina Bignoli

ADVANCED JAVA COURSE CURRICULUM

JAVA SERVLET. Server-side Programming ADVANCED FEATURES

Basic Principles of JSPs

Java TM. JavaServer Faces. Jaroslav Porubän 2008

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실

JSP - ACTIONS. There is only one syntax for the Action element, as it conforms to the XML standard:

CS433 Technology Overview

JAVA 2 ENTERPRISE EDITION (J2EE)

Questions and Answers

Session 8. Introduction to Servlets. Semester Project

Session 9. Introduction to Servlets. Lecture Objectives

ユーザー入力およびユーザーに 出力処理入門. Ivan Tanev

Accessing EJB in Web applications

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System

A Novel Technique to Improve the Performance of Licensed Software in Client/Server Network Environment

An implementation of Tree Panel component in EXT JS 4.0

Chapter 2 How to structure a web application with the MVC pattern

JavaServer Pages. Juan Cruz Kevin Hessels Ian Moon

Web based Applications, Tomcat and Servlets - Lab 3 -

Université du Québec à Montréal

Servlet 5.1 JDBC 5.2 JDBC

Programming on the Web(CSC309F) Tutorial 9: JavaServlets && JDBC TA:Wael Abouelsaadat

20/08/56. Java Technology, Faculty of Computer Engineering, KMITL 1

CISH-6510 Web Application Design and Development. JSP and Beans. Overview

The Struts MVC Design. Sample Content

SWE642 Oct. 22, 2003

Integrating Servlets and JSP: The Model View Controller (MVC) Architecture

Session 21. Expression Languages. Reading. Java EE 7 Chapter 9 in the Tutorial. Session 21 Expression Languages 11/7/ Robert Kelly,

Java Server Pages. JSP Part II

Java Server Pages, JSP

Module 4: SERVLET and JSP

One application has servlet context(s).

SERVLET AND JSP FILTERS

Java Servlets. Preparing your System

AJP. CHAPTER 5: SERVLET -20 marks

J2ME With Database Connection Program

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans

Transcription:

A JSP A.1 JSP Servlet Java HTML JSP HTML Java ( HTML JSP ) JSP Servlet Servlet HTML JSP MyDate.jsp <%@ page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %> <%! String[] youbi = {" ", " ", " ", " ", " ", " ", " "; %> <% Calendar cal = Calendar.getInstance(); %> <html><head></head><body> <%= cal.get(calendar.year) %> <%= cal.get(calendar.month)+1 %> <%= cal.get(calendar.day_of_month) %> <%= youbi[cal.get(calendar.day_of_week)] %> <%= cal.get(calendar.hour_of_day) %> <%= cal.get(calendar.minute) %> <%= cal.get(calendar.second)) %> </body></html> Servlet MyDate.java A.2 JSP JSP : <%@ page %> <%@ page %> JSP contenttype.html,.txt contenttype Servlet JSP import Java java.util.* Java A p.1

: <% %> <% %> Java ScriptletTest.jsp <%@ page language="java" contenttype="text/html; charset=windows-31j" %> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-31j"> <title> </title> </head> <body> <h1> </h1> <% double r = Math.random(); if ( r < 0.5 ) { %> <span style= color:red > </span> <% else { %> <span style= color:green > </span> <% %> </body> </html> Servlet JSP : <%= %> <%= %> Java String : <%! %> <%! %> Servlet Tomcat Servlet timeout : <%-- --%> <%-- --%> CommentTest.jsp <%@ contenttype="text/html; charset=windows-31j" %> <html> <head><title> </title></head> <body> <h2> </h2> <%-- --%> <!-- --> </body> </html> : <%@ include %> <%@ include file = " " %> file URL Java A p.2

A.3 8 6 Servlet request HttpServletRequest doget dopost 1 response HttpServletResponse doget dopost 2 out PrintWriter response.getwriter() session HttpSession request.getsession() config ServletConfig getservletconfig() application ServletContext getservletcontext() out JspWriter PrintWriter PrintWriter A.4 JavaBeans JavaBeans Java set get public foo setfoo, foo getfoo set, get java.io.serializable implements java.io.serializable Java A p.3

Bean TestBean.java package beans; import java.io.serializable; public class TestBean implements Serializable { private int foo, bar, baz; public int getfoo() { return foo; public void setfoo(int foo) { this.foo = foo; public int getbar() { return bar; public void setbar(int bar) { this.bar = bar; public int getbaz() { return baz; public void setbaz(int baz) { this.baz = baz; public int getans() { return (foo+bar)*baz; Bean foo, bar, baz 3 ans Bean package beans A.5 Servlet JSP Bean Servlet JSP Servlet JSP Servlet JSP FooBarBaz.html FooBarServlet.java Bean Ans.jsp Java A p.4

FooBarBaz.html <html><head><title> Form</title></head> <body> <form action= FooBarServlet method= post > <br> 1<input type= text size= 10 name= param1 ><br/> 2<input type= text size= 10 name= param2 ><br/> 3<input type= text size= 10 name= param3 ><br/> <input type= submit value= > </form> </body> </html> FooBarServlet.java import java.io.ioexception; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import beans.testbean; public class FooBarServlet extends HttpServlet { @Override public void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { TestBean bean = new TestBean(); // bean.setfoo(integer.parseint(request.getparameter("param1"))); bean.setbar(integer.parseint(request.getparameter("param2"))); bean.setbaz(integer.parseint(request.getparameter("param3"))); request.setattribute("mybean", bean); getservletcontext().getrequestdispatcher("/ans.jsp").forward(request, response); Java A p.5

Ans.jsp <%@ page contenttype="text/html; charset=windows-31j" %> <%-- FooBarServlet Bean --%> <jsp:usebean id="mybean" scope="request" class="beans.testbean" /> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-31j"> <title> </title> </head> <body> <h1> </h1> <table border= 1 > <tr><th> </th><th> </th></tr> <tr><td>foo</td><td><jsp:getproperty name="mybean" property="foo" /></td></tr> <tr><td>bar</td><td><jsp:getproperty name="mybean" property="bar" /></td></tr> <tr><td>baz</td><td><jsp:getproperty name="mybean" property="baz" /></td></tr> <tr><td>ans</td><td><jsp:getproperty name="mybean" property="ans" /></td></tr> </table> </body> </html> A.6 Bean Java Servlet JSP Bean JSP Bean Bean <jsp:usebean /> jsp:usebean Bean id scope class type Bean Bean Bean class Bean <jsp:usebean id="beanname" scope="scope" class="classname" /> jsp:usebean (scope) 4 Java A p.6

page JSP request request session JSP Servlet Servlet request.getattribute(beanname) Bean Servlet request.getsession().getattribute(beanname) Bean application Tomcat Web JSP/Servlet Servlet getservletcontext().getattribute(beanname) Bean <jsp:getproperty /> <jsp:getproperty name="beanname" property="propertyname" /> name Bean id beanname Bean propertyname <jsp:setproperty /> <jsp:setproperty name="beanname" property="propertyname" value="somestring" /> <jsp:setproperty name="beanname" property="propertyname" value="<%= expression %>" /> name Bean id beanname Bean propertyname value value <jsp:setproperty name="beanname" property="propertyname" /> request.getparameter(propertyname) value property * <jsp:setproperty name="beanname" property="*" /> request Parameter Bean A.7 Servlet JSP Servlet JSP Servlet Servlet JSP Servlet JSP Servlet ServletContext getrequestdispatcher RequestDispatcher Java A p.7

/ Web RequestDispatcher Request Response forwad URL URL HttpServletResponse sendredirect sendredirect URL response.sendredirect(urlstring); HttpServletResponse encoderedirecturl response.sendredirect(response.encoderedirecturl(urlstring)); request Web URL : <%@ page %>, <% %>, <%= %>, <%! %>, <%-- --%>, <%@ include %>,, JavaBeans, java.io.serializable, <jsp:usebean />,, <jsp:getproperty />, <jsp:setproperty />, forward, sendredirect, Java A p.8