myapp/jsp/ex01.jsp http://localhost:8080/myapp/jsp/ex01.jsp $CATALINA_HOME/work/Standalone/localhost/myapp/jsp (; ) 1 1. ex01.jsp 2 ; 2. () 3. <%! %>



Similar documents
Web Servlet/JSP JSP

Servlet JSP JSP Servlet/JSP における 日 本 語 の 処 理 - 1

Part1 159 a a

B2-Servlet-0112.PDF

java_servlet2_見本

HTTP Web Web RFC2616 HTTP/1.1 Web Apache Tomcat (Servlet ) XML Xindice Tomcat 6-2

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

java_servlet2_見本

サーブレット (Servlet) とは Web サーバ側で動作する Java プログラム 通常はapache 等のバックグラウンドで動作する Servletコンテナ上にアプリケーションを配置 代表的な Servlet コンテナ Apache Tomcat WebLogic WebSphere Gla

コンピュータサイエンス 4. ウェブプログラミング

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

II 2 p.2 2 GET POST form action URL Aisatsu 2.1 Servlet GET GET : Query String QueryStringTest.java 1 import java.io.ioexception; 2 import java.io.pri

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

PowerPoint プレゼンテーション

オンラインテスト

Oracle9i JDeveloper R9.0.3 チュートリアル

新・明解Java入門

K227 Java 2

HTML/JSP/Servlet... 7 JSP... 7 Servlet Struts Struts Struts FormBean LoginForm

Web JavaScript Java Applet Flash ActionScript CGI (C, perl, ruby ) PHP Servlet, JSP (JavaServer Pages) ASP 7-2


1 ex01.sql ex01.sql ; user_id from (select user_id ;) user_id * select select (3+4)*7, SIN(PI()/2) ; (1) select < > from < > ; :, * user_id user_name

メディプロ1 Javaサーブレット補足資料.ppt

2 Java 35 Java Java HTML/CSS/JavaScript Java Java JSP MySQL Java 9:00 17:30 12:00 13: 項目 日数 時間 習得目標スキル Java 2 15 Web Java Java J

ストラドプロシージャの呼び出し方

untitled

untitled

JavaScript の使い方

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

コーディング基準.PDF

intra-mart Accel Platform — IM-Repository拡張プログラミングガイド   初版  

GulfStar1.5ユーザーマニュアル

HTML Java Tips dp8t-asm/java/tips/ Apache Tomcat Java if else f

Microsoft PowerPoint - Lecture_3

HTML Java Tips dp8t-asm/java/tips/ Apache Tomcat Java if else f

コンピュータサイエンス 1. ウェブの基本

ERP連携モジュールチュートリアル

ユニット・テストの概要

1: Preference Display 1 package sample. pref ; 2 3 import android. app. Activity ; 4 import android. content. Intent ; 5 import android. content. Shar

¥Í¥Ã¥È¥ï¡¼¥¯¥×¥í¥°¥é¥ß¥ó¥°ÆÃÏÀ

VB.NETコーディング標準

Condition DAQ condition condition 2 3 XML key value

WebOS aplat WebOS WebOS 3 XML Yahoo!Pipes Popfry UNIX grep awk XML GUI WebOS GUI GUI 4 CUI

前ページからの続き // テキストボックス02 id 属性で取得 // id 属性で取得する場合は一意に決まるので 何番目かの指定は不要 var textbox02elem = document.getelementbyid("text_box02_id"); if ("001" == statee

(1) <html>,,,,, <> ( ) (/ ) (2) <!DOCTYPE html> HTML5 (3) <html> HTML (4) <html lang= ja > html (ja) (5) JavaScript CSS (6) <meta charset= shift jis >

Web 1 p.2 1 Servlet Servlet Web Web Web Apache Web Servlet JSP Web Apache Tomcat Jetty Apache Tomcat, Jetty Java JDK, Eclipse

--- サーバ側処理 Java servlet の例 // 通常の Java servlet での POST で受信と同じ protected void dopost(httpservletrequest request, HttpServletResponse response) throws S

Microsoft Word - D JP.docx

Applet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet

II 1 p.1 1 Servlet 1.1 Web Web WWW HTML CGI Common Gateway Interface Web HTML Web Web CGI CGI CGI Perl, PHP C JavaScript Web CGI HTML 1.2 Servlet Java


10 (1) s 10.2 rails c Rails 7 > item = PlanItem.new => #<PlanItem id nil, name nil,...> > item.name = "" => "" > item.valid? => true valid? true false

Java演習(4) -- 変数と型 --

第2回_416.ppt

r02.dvi

55 7 Java C Java TCP/IP TCP/IP TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] a

T2でつなごう! -つなぐつながるWebフレームワーク「T2」の紹介

スライド 1

: : : TSTank 2

Web SOAP Internet Web REST SOAP REST 3 REST SOAP 4

untitled

Oracle Forms Services R6i

AJAXを使用した高い対話性を誇るポートレットの構築

ii II Web Web HTML CSS PHP MySQL Web Web CSS JavaScript Web SQL Web

ALG ppt

REALV5_A4…p_Ł\1_4A_OCF

untitled

「都市から地方への人材誘致・移住促進に関する調査」

<91498EE88CA D815B2E786C73>

〔 大 会 役 員 〕

橡本体資料+参考条文.PDF

Lecture on

Copyright 2006 Mitsui Bussan Secure Directions, Inc. All Rights Reserved. 3 Copyright 2006 Mitsui Bussan Secure Directions, Inc. All Rights Reserved.

listings-ext

Transcription:

JSP Tomcat /export/local/tomcat4.1/webapps/myapp % ls -Rd jsp/ servlet/ WEB-INF/ WEB-INF/classes/ WEB-INF/lib/ JSP <%-- --%> <%! %> / <% %> Java ex01.jsp <%@ page %> <%! String message = Hello, JSP ; %> <html> <body> <p> <% out.println(message); %> </p> </body> </html>

myapp/jsp/ex01.jsp http://localhost:8080/myapp/jsp/ex01.jsp $CATALINA_HOME/work/Standalone/localhost/myapp/jsp (; ) 1 1. ex01.jsp 2 ; 2. () 3. <%! %> <% %>

JSP (1) ( ) request : HTTP response : HTTP page : session : application: out : response, JSP pagecontext: confi : (1) ( ) import <%@ page import = java.util.* %> <%! Date d = new Date(); %> <html> <body> <p> Today is <%out.println(d); %>. </p> </body> </html> ex02.jsp

2 ex02.jsp import ex02.jsp 2 ( ) Date is Mon Feb 02 2004. Time is 12:34:56. ( : java.text.dateformat ) (2) String request.getrequesturi() : URI String request.getservername() : String request.getservletport() : String request.getcontexttype() : MIME <%= %> <% out.print( ) %> ex03.jsp( ) <p> URI is <%= request.getrequesturi() %><br> ServerName is <%= request.getservername() %><br> </p>

3 ex03.jsp (getremoteaddr) (getremoteuser) (getlocale, getcharacterencoding) localhost (3) response.flushbuffer() : (out.flush() ) response.setcontexttype(string) : MIME response.setlocale(locale) : ( ) response.setcharaterencoding(string) : ( ) ex04.jsp( ) <% response.setlocale(new Locale( ja )); response.setcontenttype( text/html; charset=euc ); %>

(4) String session.getid() : ID boolean session.isnew() : false Object session.getattribute(string) : Enumuration session.getattributenames(): void session.setattribute(string, Object): void session.removeattribute(string): 30 WEB-INF/web.xml (0!) <session-config> <session-timeout>10</session-timeout> </session-config> 4 ex05.jsp setattribute/removeattribute session.invalidate()

form URL (?name=val&...) getparameter session ex06.jsp( ) <% String name = request.getparameter( name ); String pass = request.getparameter( pass ); session.setattribute( name, name); session.setattribute( pass, encode(pass,key)); %> if/else, while, for Java jsp:forward jsp:include jsp:param

5 (ex06)/ (ex07) ex08.jsp ex08.jsp( ) <form action= ex08.jsp > Username:<input name= nm type= text ><br> Password:<input name= pw type= password ><br> <input type= submit value= login > </form> <jsp:??? page= ex06.jsp > <jsp:??? /> <jsp:??? /> Bean Bean JSP Bean set JSP get jsp:usebean jsp:setproperty jsp:getproperty Bean, : Bean

6 ex09.jsp loginbean.java login getproperty? <%@ page errorpage= errorpage.jsp %> exception errorpage.jsp ( ) <%@ page iserrorpage= true %> <html> <body> <h2>error Page</h2> <%= exception.tostring() %> occurred.<br>

7 ex09.jsp/loginbean.java Bean session session =cookie / Cookie[] request.getcookies() : Cookie void response.addcookie(cookie) : Cookie String cookie.getname() : Cookie String cookie.getvalue() : Cookie void cookie.setmaxage(int) : Cookie ( ) 0

( ) Cookie ex10.jsp( ) <% page import= java.util.* %> <%! String getdefault(cookie[] ck, String key) { if (ck == null) return ; for (int i=0;i<ck.length;i++) { if (ck[i].getname().equals(key)) return ck[i].getvalue(); } return ; %>... <%= getdefault(request.getcookies(), cookiename) %> ( ) Cookie <%! Cookie c; %> <% if (request.getparameter( nm )!= null) { c = new Cookie(cookieName, request.getparameter( nm )); c.setmaxage(3600); } else { c = new Cookie(cookieName, ); c.setmaxage(0); } response.addcookie(c); %> ex10.jsp( )

8 ex10.jsp (ex09.jsp ) save save ex10.jsp HTML Java core: fmt: xml: XML sql: DB session.jsp( ) <% page taglib= http://java.sun.com/jstl/core prefix= c %>... <c:set var= username scope= session value= Suzuki />

Core: <c:set var= scope= value= /> : page( ), request, session, application <c:out value= /> ${. } : pagescope( ), requestscope... param, paramvalues param. request.getparameter( ) paramvalues.[ ] request.getparametervalues( ) Core: Java <c:if test= > </c:if> : if (else ) <c:choose> : switch <c:when test= 1 > 1</c:when> <c:otherwise> n</c:otherwise> </c:choose> <c:foreach var= : for begin= end= step= > </c:foreach> <c:redirect url= /> : ( ) <c:redirect url= > <c:param name= value= > </c:redirect>

9 ex11.jsp ex06.jsp session.jsp page request fmt: <fmt:setlocale value= scope= /> : ( : ja_jp) <fmt:setbundle basename= var= /> _.properties <fmt:message key= bundle= /> username= password= UTF-8

fmt: ( ) Resources_ja.txt username= password= EUC* % native2ascii Resources_ja.txt > Resources_ja.properties Resources_ja.properties username= uxxxx uxxxx... password= uxxxx uxxxx... UTF-8 /myapp/web-inf/classes (*Windows Shift-JIS[MS932]) fmt: ( ) ex12.jsp( ) <%@ page contenttype= text/html; charset=euc-jp %> <fmt:setlocale value= ja /> <fmt:setbundle basename= Resources var= context /> <table><tr><td> <fmt:message key= username bundle= ${context} /> </td><td>... </td></tr><tr><td> <fmt:message key= password bundle= ${context} /> </td><td>... </td></tr> </table>

10 ex12.jsp ex12.jsp title.top= title.error= label.username= label.password= button.login= label.error= fmt: ( ) <fmt:formatdate value= type= /> : java.util.date : time, date, both <fmt:formatnumber value= type= /> : number, currency, percent pattern= ###0.0# yy/mm/dd HH:mm:ss : ( ) : ( ) <fmt:formatnumber type=... > </fmt:formatnumber>

fmt: ( ) Resources_ja.txt filenotfound= {0} Resources_en.txt filenotfound={0} : No such file. Resources_fr.txt filenotfound=aucun fichier {0}. ex13.jsp( ) <fmt:setlocale value= ja /> <fmt:setbundle var= context basename=... />... <fmt:message key= filenotfound > <fmt:param value= error.jsp /> </fmt:message> 11 ex13.jsp Locale ja en, fr Locale de? ( Keine Acte gefunden werden)