Title: Java Server Pages (JSP)
1Java Server Pages (JSP)
2Symbol Names
Name Name
Tilde ' Single quotation mark, Apostrophe
Grave " Double quotation mark
! Exclamation mark / Slash, Virgule
_at_ At sign, Commercial at \ Back slash
Number sign, Crosshatch, Pound sign Vertical bar
Dollar sign , Comma
Percent sign . Dot, Period, Full stop
Hat sign, Circumflex ? Question mark
Ampersand ( ) (Left / Right) parenthesis
Asterisk, Star sign (Left / Right) braces, curved parenthesis
Dash, Hyphen, Minus sign (Left / Right) bracket, squared parenthesis
_ Underscore, Underline lt gt (Left / Right) angle bracket, pointed brackets
Plus sign ? ? (Left / Right) unidirectional arrows
Equal sign ? Bidirectional arrow
Colon
Semicolon
3JSP Motivation
4World Wide Web
- The World Wide Web is a system of interlinked
hypertext documents accessed via the Internet. - With a web browser, one can view Web pages that
may contain text, images, videos, and other
multimedia and navigate between them using
hyperlinks.
5Architecture of WWW
HTML file
content
request with arguments
user input
File Input
Web Browser
Web Server
GUI
HTTP
input
response
user output
Interface
Server-side program
output
6DigressionHTML
7HTML
- HTML, an initialism of HyperText Markup Language,
is the predominant markup language for web pages. - A markup language is a set of annotations to text
that describe how it is to be structured, laid
out, or formatted. - Hypertext refers to text on a computer that will
lead the user to other, related information on
demand. - Rather than remaining static like traditional
text, hypertext makes possible a dynamic
organization of information through links and
connections (called hyperlinks).
8HTML
- HTML provides a means to describe the structure
of text-based information in a document by
denoting certain text as links, headings,
paragraphs, lists, and so on and to supplement
that text with interactive forms, embedded
images, and other objects. - HTML is written in the form of tags, surrounded
by angle brackets.
9Simple Example
Tags
- ltHTMLgt
- ltHEADgt
- ltTITLEgtSimple HTMLlt/TITLEgt
- lt/HEADgt
- ltBODYgt
- ltH1gtHeadlt/H1gt
- First paragraphltPgt
- Second paragraphltPgt
- lt/BODYgt
- lt/HTMLgt
Angle brackets
Heading
Paragraphs
10HTML Markup Tag
- Formats
- lttag-namegt
- e.g. ltbrgt
- lttag-namegt text lt/tag-namegt
- e.g. ltbgtBoldlt/bgt, ltTITLEgt lt/TITLEgt, ltBODYgt
lt/BODYgt - lttag-name attributeargumentgt
- e.g. ltimg src"a.jpg"gt
- lttag-name attributeargumentgt text lt/tag-namegt
- e.g. lta href"http//www.muohio.edu"gtMiami
Universitylt/agt - Note
- Tag-names are case-insensitive.
- ltHTMLgt, lthtmlgt, ltHtmlgt, lthTmLgt
- Multiple consecutive whitespaces (space, tab,
EOLN) are regarded as one space.
11HTML Text
- paragraph ltPgt ... lt/Pgt
- line break ltBRgt
- centering ltCENTERgt ... lt/CENTERgt
- bold ltBgt ... lt/Bgt
- italic ltIgt ... lt/Igt
- headline ltHngt ... lt/Hngt
- Many tags are deprecated now. (no more standard)
12HTML Special Characters
- Format
- character-name
- Special characters
- lt ? LT
- gt ? GT
- " ? QUOTE
- ? AMP
13HTML Hyperlink
- Anchor Tag
- ltA HREF "address"gt ... lt/Agt
- e.g.
- ltA HREF"http//www.apple.com"gtApplelt/Agt
- Relative Path vs. Absolute Path
- HREF "abc.html"
- HREF "../ddd/abc.html"
- HREF "http//www.joongang.co.kr"
14HTML List
- Unnumbered Lists
- ltULgt ltLIgt ... ltLIgt ... lt/ULgt
- Numbered Lists
- ltOLgt ltLIgt ... ltLIgt ... lt/OLgt
- Definition Lists
- ltDLgt ltDTgt ... ltDDgt ... ltDTgt ... ltDDgt ... lt/DLgt
15HTML Image
- ltIMG SRC "address/... .gif" ALIGN
TOP/MIDDLE/BOTTOM/LEFT/RIGHTgt - ltIMG SRC "address/... .jpg"gt
- e.g.
- ltIMG SRC "picture.gif"gt
16HTML Table
- ltTABLE BORDER ngt
- ltCAPTIONgt ... lt/CAPTIONgt
- ltTRgt
- ltTHgt ... lt/THgt
- ltTDgt ... lt/TDgt
- lt/TRgt
- ltTRgt
- ltTDgt ... lt/TDgt
- ltTDgt ... lt/TDgt
- lt/TRgt
- lt/TABLEgt
- e.g.
- ltTABLE BORDERgt
- ltTRgt
- ltTDgt A11 lt/TDgt
- ltTDgt A12 lt/TDgt
- lt/TRgt
- ltTRgt
- ltTHgt B11 lt/THgt
- ltTDgt B12 lt/TDgt
- lt/TRgt
- lt/TABLEgt
17HTML Form
18Exercise 1 Text and Hyperlinklta href""gtlt/agt
19Exercise 2 Numbered Listltolgtltligtltligtlt/olgt
20Exercise 3 Numbered List and Hyperlink
ltolgtltligtlta href""gtlt/agtltligtlt/olgt
21Exercise 4 Table lttablegtlttrgtlttdgtlt/tdgt...lt/trgtlt/
tablegt
22Exercise 5 Table and Hyperlinklttablegtlttrgtlttdgtlta
href""gtlt/agtlt/tdgt...lt/trgtlt/tablegt
23Exercise 6 Table and Heightlttd height"50"gt
24Exercise 7 Table and Widthlttd width"200"gt
25Exercise 8 Table and Sizelttd height"50"
width"200"gt
26Exercise 9 Image ltimg src"a.jpg"gt
27Exercise 10 Image and Hyperlink lta
href""gtltimg src""gtlt/agt
28Exercise 11 Table, Image and Hyperlink
lttablegtlttrgtlttdgtlt/tdgtlttdgtlta href""gtltimg
src""gtlt/agtlt/tdgtlt/trgtlt/tablegt
29Architecture of WWW
HTML file
content
request with arguments
user input
File Input
Web Browser
Web Server
GUI
HTTP
input
response
user output
Interface
Server-side program
output
30Architecture of WWW
- What happens if Web servers support only HTML
files?
31Architecture of WWW (?)
HTML file
content
request with arguments
user input
File Input
Web Browser
Web Server
GUI
HTTP
input
response
Server-side program
user output
Interface
output
32Architecture of WWW
- What happens if Web servers support only HTML
files? - Static Web Pages vs. Dynamic Web Pages
- The dynamic Web pages are used for
- Login
- Registration
- Shopping cart
- Payment
- Enrollment
33Dynamic Web Pages
- What if Web servers themselves process the
dynamics? - Fast
- Developing Web servers requires expertise, so it
would be complicated and even risky for
application developers to modify a Web server. - Alternative approach?
- An independent program executed by a Web server
34Architecture of WWW
HTML file
content
request with arguments
user input
File Input
Web Browser
Web Server
GUI
HTTP
input
response
Server-side program
user output
Interface
output
35Dynamic Web Pages
- Requirements for Dynamic Web Pages
- User input
- ? Webform by HTML FORM Tag
- Processing based on the user input
- ? JSP
36DigressionWebform
37Webform
- A webform on a web page allows a user to enter
data that is sent to a server for processing. - Webforms resemble paper forms because internet
users fill out the forms using checkboxes, radio
buttons, or text fields. - For example, webforms can be used to enter
shipping or credit card data to order a product
or can be used to retrieve data (e.g., searching
on a search engine).
38Webform FORM Tag
- Syntax
- ltFORM
- METHOD"POST"/"GET"
- ACTION"server-side-program"
- ENCTYPE"application/x-www-form-urlencoded"gt
- ...
- lt/FORMgt
- The FORM tag is just an envelop for a Webform.
Additional tags like INPUT, TEXTAREA, SELECT are
required for a Webform.
39Webform INPUT Tag
- Syntax
- ltINPUT NAME"name"
- VALUE"value"
- SIZE"n"
- MAXLENGTH"n"
- TYPE TEXT/PASSWORD
- /CHECKBOX/RADIO
- /SUBMIT/RESETgt
- Used to input a line of characters
40Webform INPUT Tag
- e.g.
- ltHTMLgt
- ltBODYgt
- ltFORM METHOD"POST" ACTION"login.jsp"gt
- Username ltINPUT TYPE"TEXT" NAME"UN"gt ltBRgt
- Password ltINPUT TYPE"PASSWORD" NAME"PW"gt
- ltBRgt
- ltINPUT TYPE"SUBMIT" VALUE"Login"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
41Webform TEXTAREA Tag
- Syntax
- ltTEXTAREA NAME"name" ROWS"n" COLS"n"gt
- Line 1
- Line 2
-
- Line n
- lt/TEXTAREAgt
- Used to input multiple lines of text
42Webform TEXTAREA Tag
- e.g.
- ltHTMLgt
- ltBODYgt
- ltFORM METHOD"POST" ACTION"hello.jsp"gt
- ltDLgt
- ltDTgt
- ltBgt Commentlt/Bgt
- ltDDgt
- ltTEXTAREA NAME"Comment" ROWS"8" COLS"55"gt
- Hello!
- How is it going?
- Fine, thank you.
- lt/TEXTAREAgt
- lt/DLgt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
43Webform SELECT Tag
- Syntax
- ltSELECT NAME"name" SIZE"n" MULTIPLEgt
- ltOPTIONgt option 1
- ltOPTIONgt option 2
-
- ltOPTIONgt option n
- lt/SELECTgt
- Used to support a list box or a combo box
44Webform SELECT Tag
- e.g.
- ltHTMLgt
- ltBODYgt
- ltFORM METHOD"POST" ACTION"select.jsp"gt
- ltSELECT NAME"group" SIZE"3" MULTIPLEgt
- ltOPTIONgt Title
- ltOPTIONgt Description
- ltOPTIONgt URL
- lt/SELECTgt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
45Exercise 1 Edit Box ltINPUT TYPE"TEXT" gt
46Exercise 2 Edit Box with Initial Value ltINPUT
TYPE"TEXT" VALUE"Song" gt
47Exercise 3 Edit Box and ButtonltINPUT
TYPE"SUBMIT" gt
48Exercise 4 Edit Box and Button ltBRgt
49Exercise 5 Login
50Exercise 6 Check BoxltINPUT TYPE"CHECKBOX" gt
51Exercise 7 Radio ButtonltINPUT TYPE"RADIO"
NAME"" VALUE""gt
52Exercise 8 Form with Table
53Exercise 9 Colspan ltTD COLSPAN"2"gtlt/TDgt
54Exercise 10 Colspan and AlignltTD COLSPAN"2"
ALIGN"CENTER"gtlt/TDgt
55Exercise 11 Table without Border
56Exercise 12 General Form
57JSP Getting Started
58What is JSP?
- Java Server Pages
- Based on Java programming language
- State-of-the-art technology to build Web pages
having dynamic contents - Contrasts to Web pages having static contents by
using HTML only - JSP-based Web pages delivers "different" Web
contents to different persons, while HTML-based
Web pages delivers "same" Web contents to
different persons.
59Dynamic Content Technologies
- Common Gateway Interface (CGI)
- ColdFusion
- Active Server Pages
- Server-side JavaScript
- PHP (Personal Home Page, Professional Hypertext
Preprocessor) - Java Servlets
- Java Server Pages
60What We Need?
- JDK (Java Development Kit)
- Core module for Java programming
- Web Server
- Sun Java System Application Server
- IDE (Integrated Development Environment)
- Supports Editing, Compile, Debugging, etc.
- NetBeans (http//www.netbeans.org/)
61Where are the Tools?
- http//java.sun.com/
- Java SE JDK
- jdk-6u4-windows-i586-p.exe or later
- Java EE Tools
- java-tools-bundle-update4-windows or later
62Using NetBeans IDE
- Build a New Project
- Edit the Source Code
- Compile
- Execute (Run)
- Debug
63Hello, World! - I
- ltHTMLgt
- ltBODYgt
- Hello, World!
- lt/BODYgt
- lt/HTMLgt
64Hello, World! - II
- ltHTMLgt
- ltBODYgt
- lt
- String visitor request.getParameter("name")
- if (visitor null) visitor "World"
- gt
- Hello, lt visitor gt!
- lt/BODYgt
- lt/HTMLgt
Scriptlet
Expression
65Visiting the Page
- http//localhost8080/hello.jsp
- http//localhost8080/hello.jsp?nameSong
66JSP Scripting elements
67JSP Tag Styles
- Scripting-oriented tags
- lt gt
- e.g.
- lt_at_ page import"java.io." gt
- lt r 7.5 gt
- lt r 2 gt
- XML-based tags
- ltjsptag attribute1value1 /gt
- ltjsptag attribute1value1 gt lt/jsptaggt
- e.g.
- ltjspdirective.page import"java.io." /gt
68JSP Tags
- JSP Directives
- lt_at_ page gt
- e.g. lt_at_ page import"java.io." gt
- lt_at_ include gt
- lt_at_ taglib gt
- Scripting Elements
- lt! declarations gt
- lt expression gt
- e.g. lt r 2 gt
- lt scriptlet gt
- e.g. lt r 7.5 gt
69Scripting Element - Expression
- lt expression gt
- e.g.
- lt a b 3 - f / d gt
- lt fact(7) gt
70Scripting Element - Expression
- ltHTMLgt
- ltBODYgt
- sin(3.14)
- lt Math.sin(3.14) gt
- lt/BODYgt
- lt/HTMLgt
71Scripting Element - Scriptlet
- lt statements gt
- e.g.
- lt int i, f, s 0
- for (i 1, f 0 i lt f i)
- s i gt
72Scripting Element - Scriptlet
- ltHTMLgt
- ltBODYgt
- lt
- int i
- for (i 0 i lt 100 i)
-
- out.println(i "ltBRgt")
-
- gt
- lt/BODYgt
- lt/HTMLgt
73Hello, World! - II
- ltHTMLgt
- ltBODYgt
- lt
- String visitor request.getParameter("name")
- if (visitor null) visitor "World"
- gt
- Hello, lt visitor gt!
- lt/BODYgt
- lt/HTMLgt
74Comments
- Content Comments
- lt! comment --gt
- Comments for HTML
- Web browser processes the comments.
- JSP Comments
- lt-- comment --gt
- Comments for JSP
- JSP processes the comments.
- Scripting Language Comments
- // comment
- / comment /
- Comments for Java
- Expression or Scriptlet process the comments.
75JSP Request object
76Implicit Objects
- Servlet-related object
- page
- config
- Input/Output object
- request
- response
- out
- Contextual object
- session
- application
- pageContext
- Error-processing object
- exception
77page Object
- getServletInfo()
- e.g.
- lt ((javax.servlet.jsp.HttpJspPage)page).getServl
etInfo() gt
78config Object
- getInitParameterNames()
- getInitParameter(String name)
- e.g.
- lt String un config.getInitParameter("username")
gt
79request Object
- Request Contents
- getParameterNames()
- getParameter(String name)
- getParameterValues(String name)
- Request Header
- getHeaderNames()
- getHeader(String name)
- getHeaders(String name)
- getIntHeader(String name)
- getDateHeader(String name)
- getCookies()
- Others
- getMethod()
- getRequestURL()
- getQueryString()
- getSession(flag)
- getRequestDispatcher(path)
- getRemoteHost()
- getRemoteAddr()
- getRemoteUser()
- getSession(flag)
80Parameter
- ltHTMLgt
- ltBODYgt
- ltFORM METHODPOST ACTION"login.jsp"gt
- Username ltINPUT TYPETEXT NAME"UN"gt ltBRgt
- Password ltINPUT TYPEPASSWORD NAME"PW"gt ltBRgt
- ltINPUT TYPESUBMIT VALUE"Login"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
- ltHTMLgt
- ltBODYgt
- lt
- String username request.getParameter("UN")
- String password request.getParameter("PW")
- out.println(username "/" password)
- gt
- lt/BODYgt
- lt/HTMLgt
81Types of Inputs
- ltINPUTgt
- Text
- Password
- Checkbox
- Radio
- Submit
82Example
- (e.g.)
- ltHTMLgt
- ltBODYgt
- ltFORM methodpost action"set.jsp"gt
- ltINPUT typetext nameInput value"OK" size"10"
maxlength"15"gt - ltINPUT typesubmit namebutton value"Prev"gt
- ltINPUT typesubmit namebutton value"Index"gt
- ltINPUT typesubmit namebutton value"Next"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
- lt
-
- String a request.getParameter("Input")
- String b request.getParameter("button")
-
- gt
83Exercise 1 Edit Box
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- ltinput typetext name"username" value"Song"gt
ltBRgt - ltinput typesubmit name"submit" value" OK "gt
- lt/formgt
- lt/bodygt
- lt/htmlgt
84Exercise 2 Login
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- Username ltinput typetext name"un"gt ltBRgt
- Password ltinput typepassword name"pw"gt ltBRgt
- ltinput typesubmit name"submit" value" OK "gt
- lt/formgt
- lt/bodygt
- lt/htmlgt
85Exercise 3 Check Box
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- Username ltinput typetext name"un"gt ltBRgt
- Password ltinput typepassword name"pw"gt ltBRgt
- ltinput typecheckbox name"bs"gt Secure mail ltBRgt
- ltinput typesubmit name"submit" value" OK "gt
- lt/formgt
- lt/bodygt
- lt/htmlgt
86Exercise 4 Radio Button
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- Username ltinput typetext name"un"gt ltBRgt
- Password ltinput typepassword name"pw"gt ltBRgt
- ltinput typecheckbox name"bs"gt Secure mail ltBRgt
- ltinput typeradio name"sx"gt Female ltinput
typeradio name"sx"gt MaleltBRgt - ltinput typesubmit name"submit" value" OK "gt
- lt/formgt
- lt/bodygt
- lt/htmlgt
87Exercise 5 Colspan and Align
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- lttablegt
- lttrgt
- lttdgtUsernamelt/tdgt lttdgtltinput typetext
name"un"gt lt/tdgt - lt/trgt
- lttrgt
- lttdgtPasswordlt/tdgt lttdgtltinput typepassword
name"pw"gt lt/tdgt - lt/trgt
- lttrgt
- lttd colspan2 align"center"gtltinput typesubmit
name"submit" value" OK "gtlt/tdgt - lt/trgt
- lt/formgt
- lt/bodygt
88Exercise 6 General Form
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- lttablegt
- lttrgt lttdgtUsernamelt/tdgt lttdgtltinput typetext
name"un"gt lt/tdgt lt/trgt - lttrgt lttdgtPasswordlt/tdgt lttdgtltinput typepassword
name"pw"gt lt/tdgt lt/trgt - lttrgt lttdgtGenderlt/tdgt lttdgtltinput typeradio
name"sx"gtF ltinput typeradio name"sx"gtMlt/tdgt
lt/trgt - lttrgt
- lttdgtHobbylt/tdgt lttdgtltinput typecheckbox
name"h1"gtMusic ltinput typecheckbox
name"h2"gtStamp ltinput typecheckbox
name"h3"gtHiking ltinput typecheckbox
name"h4"gtSoccerlt/tdgt - lt/trgt
- lttrgt lttd colspan2 align"center"gtltinput
typesubmit name"submit" value" OK "gtlt/tdgt
lt/trgt - lt/formgt
- lt/bodygt
- lt/htmlgt
89JSP Response object
90response Object
- Content Setting
- setContentType()
- getCharacterEncoding()
- addCookie(cookie)
- containsHeader(name)
- setHeader(String name, String value)
- setIntHeader(String name, int value)
- setDateHeader(String name, Date value)
- addHeader(String name, String value)
- addIntHeader(String name, int value)
- addDateHeader(String name, Date value)
- Response Setting
- setStatus(code)
- sendError(status, msg)
- sendRedirect(url)
- URL Encoding
- encodeRedirectURL(url)
- encodeURL(name)
91Redirect
- ltHTMLgt
- ltBODYgt
- ltFORM METHODPOST ACTION"login.jsp"gt
- Username ltINPUT TYPETEXT NAME"UN"gt ltBRgt
- Password ltINPUT TYPEPASSWORD NAME"PW"gt ltBRgt
- ltINPUT TYPESUBMIT VALUE"Login"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
- ltHTMLgt
- ltBODYgt
- lt
- String username request.getParameter("UN")
- String password request.getParameter("PW")
- if (username.equals("a") password.equals("b"))
- out.println("Login success!ltBRgt")
- else
- response.sendRedirect("login.html")
- gt
- lt/BODYgt
- lt/HTMLgt
92Digressionif statement
93if statement
- A control statement for division
- Syntax
- if (expression)
- statement(s)1
- else
- statement(s)2
-
- Control and execution
- If evaluation result of the "expression" is true,
then "statement(s)1" is executed. - Otherwise, "statement(s)2" is executed.
- e.g.
- if (n gt 0)
- a 1
- else
- a 0
-
- Controls in programming
- Sequence
- Division
- Repetition
94if statement Java1
- Example
- String response "I love you."
- if (response.contains("love"))
- System.out.println(response)
- System.out.println("Comment You are
lucky.") - else
- System.out.println(response)
-
- In an object-oriented programming language like
Java, we can apply a command like "contains" to a
String variable like "response". - Almost commands in Java return some values
"contains" returns "true" or "false".
95if statement
- Exercise
- Make a Java program such that
- Set a string variable response as "I am fine.".
- Print out the value of the response
- If the response contains a string "fine", then
add a comment "Comment Good!". - Project name
- Java1X1
96Exercise 1 Teenager
- Write a JSP program
- Assume an age.
- If the age is between 13 and 19, display
"Teenager". - Otherwise, display "Not teenager".
97Exercise 2 Gender
- Write a JSP program
- Assume a gender.
- If the gender is "M", display "Male".
- Otherwise, display "Female".
98Extension of "if" Statements
- Extended Syntax
- if (expression)
- statement
- else if (expression)
- statement
-
- else
- statement
- (e.g.)
- if (x lt 0)
-
- i -1
-
- else if (x lt 100)
-
- i 0
-
- else
-
- i 1
99Exercise 3 Teenager
- Write a JSP program
- Assume an age.
- If the age is less than 13, display "Child".
- If the age is between 13 and 19, display
"Teenager". - Otherwise, display "Not teenager".
100Exercise 4 Gender
- Write a JSP program
- Assume a gender.
- If the gender is "M", display "Male".
- If the gender is "F", display "Female".
- Otherwise, display "Transgender".
101End of Digression
102Exercise 1 Check Box
103Exercise 1 Check Box
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- Username ltinput typetext name"un"gt ltBRgt
- Password ltinput typepassword name"pw"gt ltBRgt
- ltinput typecheckbox name"bs"gt Secure mail ltBRgt
- ltinput typesubmit name"submit" value" OK "gt
- lt/formgt
- lt/bodygt
- lt/htmlgt
104Exercise 2 Radio Button
105Exercise 2 Radio Button
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- Username ltinput typetext name"un"gt ltBRgt
- Password ltinput typepassword name"pw"gt ltBRgt
- ltinput typecheckbox name"bs"gt Secure mail ltBRgt
- ltinput typeradio name"sx"gt Female ltinput
typeradio name"sx"gt MaleltBRgt - ltinput typesubmit name"submit" value" OK "gt
- lt/formgt
- lt/bodygt
- lt/htmlgt
106Exercise 3 General Form
107Exercise 3 General Form
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- lttablegt
- lttrgt lttdgtUsernamelt/tdgt lttdgtltinput typetext
name"un"gt lt/tdgt lt/trgt - lttrgt lttdgtPasswordlt/tdgt lttdgtltinput typepassword
name"pw"gt lt/tdgt lt/trgt - lttrgt lttdgtGenderlt/tdgt lttdgtltinput typeradio
name"sx"gtF ltinput typeradio name"sx"gtMlt/tdgt
lt/trgt - lttrgt
- lttdgtHobbylt/tdgt lttdgtltinput typecheckbox
name"h1"gtMusic ltinput typecheckbox
name"h2"gtStamp ltinput typecheckbox
name"h3"gtHiking ltinput typecheckbox
name"h4"gtSoccerlt/tdgt - lt/trgt
- lttrgt lttd colspan2 align"center"gtltinput
typesubmit name"submit" value" OK "gtlt/tdgt
lt/trgt - lt/formgt
- lt/bodygt
- lt/htmlgt
108Exercise 4 Edit Box for Number
109Exercise 4 Edit Box for Number
- lthtmlgt
- ltbodygt
- lth1gtWeb Programminglt/h1gt
- ltform methodpost action"a.jsp"gt
- Age ltinput typetext name"age"gt ltBRgt
- ltinput typesubmit name"submit" value" OK "gt
- lt/formgt
- lt/bodygt
- lt/htmlgt
110Exercise 4 Edit Box for Number
- ltHTMLgt
- ltBODYgt
- lt
- String stringAge request.getParameter("age")
- int age ______________?________________
- if (age lt 13)
- out.println("Child")
- else if (age lt 20)
- out.println("Teenager")
- else
- out.println("Not Teenager")
- gt
- lt/BODYgt
- lt/HTMLgt
111JSP Out object
112out Object
- print()
- println()
- isAutoFlush()
- getBufferSize()
- getRemaining()
- clearBuffer()
- clear()
- newLine()
- flush()
- close()
113Login
- ltHTMLgt
- ltBODYgt
- ltFORM METHODPOST ACTION"login.jsp"gt
- Username ltINPUT TYPETEXT NAME"UN"gt ltBRgt
- Password ltINPUT TYPEPASSWORD NAME"PW"gt ltBRgt
- ltINPUT TYPESUBMIT VALUE"Login"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
- ltHTMLgt
- ltBODYgt
- lt
- String username request.getParameter("UN")
- String password request.getParameter("PW")
- out.println(username)
- out.println(password)
- gt
- lt/BODYgt
- lt/HTMLgt
114Login
- ltHTMLgt
- ltBODYgt
- ltFORM METHODPOST ACTION"login.jsp"gt
- Username ltINPUT TYPETEXT NAME"UN"gt ltBRgt
- Password ltINPUT TYPEPASSWORD NAME"PW"gt ltBRgt
- ltINPUT TYPESUBMIT VALUE"Login"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
- ltHTMLgt
- ltBODYgt
- lt
- String username request.getParameter("UN")
- String password request.getParameter("PW")
- gt
- lt username gt
- lt/ password gt
- lt/BODYgt
- lt/HTMLgt
115Teenager
- ltHTMLgt
- ltBODYgt
- lt
- int age 20
- if (a lt 13)
- out.println("Child")
- else if (a lt 20)
- out.println("Teenager")
- else
- out.println("Not Teenager")
- gt
- lt/BODYgt
- lt/HTMLgt
- ltHTMLgt
- ltBODYgt
- lt
- int age 20
- if (a lt 13)gt
- lt "Child"gt
- ltelse if (a lt 20) gt
- lt "Teenager"gt
- ltelsegt
- lt "Not Teenager"gt
- lt/BODYgt
- lt/HTMLgt
116Digressionfor statement
117for statement
- A control statement for repetition
- Syntax
- for (expression1 expression2 expression3)
- statement(s)
-
- Control and execution
- The "expression1" is evaluated.
- If evaluation result of the "expression2" is
true, then "statement(s)" is executed. - After the execution, the "expression3" is
evaluated. - Go to the evaluation of the "expression2".
- Otherwise, the whole "for" statement is finished.
- e.g.
- for (i 0 i lt 100 i)
-
- System.out.println(i)
-
- Controls in programming
- Sequence
- Division
- Repetition
118for statement Java3
- Example
- import java.io.
- try
- BufferedReader reader new
BufferedReader(new InputStreamReader(System.in)) - int i
- String response ""
- for (i 0 response.contains("Quit")
false i) - System.out.print("Inputgt ")
- response reader.readLine()
- System.out.println(i " " response)
-
- catch (Exception e)
- System.err.println(e)
-
- Note "contains" returns "true" or "false".
119for statement
- Exercise
- Make a Java program such that
- Input a string from user and print it out as in
Java3. - If the string contains "Quit", then stop.
- If the string contains a string "fine", then add
a comment "Comment Good!". - Project name
- Java3X1
120Exercise 1 Display
- Write a JSP program
- Assume a max number n.
- Display all numbers between 1 and n.
121Exercise 2 Summation
- Write a JSP program
- Assume a max number n.
- Calculate summation of all numbers between 1 and
n.
122End of Digression
123JSP Session object
124Session
- A session is a semi-permanent interactive
information exchange, also known as a dialogue, a
conversation or a meeting, between two or more
communicating devices, or between a computer and
user. - A session is set up or established at a certain
point in time, and torn down at a later point in
time. - A session is typically, but not always, stateful,
meaning that at least one of the communicating
parts need to save information about the session
history in order to be able to communicate. - A session in Web is established between a Web
browser and a Web server, and the server needs to
save information about the session history. - (e.g.) Login session
125Session HTTP
- Is HTTP stateful?
- Does HTTP support a session?
- Does HTTP have a mechanism to save information
about the session history. - Basically, no!
- HTTP is not stateful but stateless.
- However, HTTP provides headers for "Cookies" such
as Set-Cookie and Cookie which can be used to
support a session. - The implicit object "session" in JSP provides a
set of commands for a JSP program to save
information about the session history. - This session object is based on the Set-Cookie
and the Cookie headers of HTTP.
126session Object
- getAttribute(name)
- getId()
- getCreationTime()
- getLastAccessTime()
- getMaxInactiveInterval()
- setAttribute(name, object)
- setMaxInactiveInterval(second)
- isNew()
- invalidate()
127Exercise 1 My Name
- Write a HTML program (a.html)
- Input users name
- Write a JSP program (a.jsp)
- Memorize the users name
- Write another JSP program (b.jsp)
- Retrieve and output the users name
128Exercise 1 My Name
- ltHTMLgt
- ltBODYgt
- ltFORM methodpost action"a.jsp"gt
- Nameltinput typetext name"n"gtltbrgt
- ltinput typesubmit value"OK"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
129Exercise 1 My Name
- ltHTMLgt
- ltBODYgt
- lt
- String name request.getParameter("n")
- session.setAttribute("name", name)
- out.println("You can enter ltA HREF'b.jsp'gtour
sitelt/AgtltBRgt") - gt
- lt/BODYgt
- lt/HTMLgt
- ltHTMLgt
- ltBODYgt
- lt
- String n (String)session.getAttribute("name")
- out.println("Your name is ")
- out.println(n)
- out.println(". Right?")
- gt
- lt/BODYgt
- lt/HTMLgt
130Exercise 2 My Hobby
- Write a HTML program (a.html)
- Input users hobbies by using check boxes
- Write a JSP program (a.jsp)
- Memorize the users hobbies
- Write another JSP program (b.jsp)
- Retrieve and output the users hobbies
131Exercise 2 My Hobby
132Exercise SSN
- Write a HTML program (a.html)
- Input users social security number
- Write a JSP program (a.jsp)
- Memorize the users SSN
- Write another JSP program (b.jsp)
- Retrieve and output the users SSN
133Exercise 3 Login
- ltHTMLgt
- ltBODYgt
- lt
- String username request.getParameter("UN")
- String password request.getParameter("PW")
- if (username.equals("a") password.equals("b"))
-
- session.setAttribute("Username", username)
- out.println("Login success!ltBRgt")
- out.println("You can enter ltA HREF'main.jsp'gtour
sitelt/AgtltBRgt") -
- else
-
- out.println("Login failed!ltBRgt")
- out.println("You can NOT enter ltA
HREF'main.jsp'gtour sitelt/AgtltBRgt") -
- gt
- lt/BODYgt
- lt/HTMLgt
- ltHTMLgt
- ltBODYgt
- lt
- String username (String)session.getAttribute("Us
ername") - if (username ! null)
-
- out.println("Welcome!ltBRgt")
- out.println("You can see everything in our
site.ltBRgt") -
- else
-
- out.println("You are not allowed here.ltBRgt")
-
- gt
- lt/BODYgt
- lt/HTMLgt
134Session
- ltHTMLgt
- ltBODYgt
- lt
- session.invalidate()
- out.println("ltA HREF'main.jsp'gtMainlt/Agt")
- gt
- lt/BODYgt
- lt/HTMLgt
135Exercise 3 Logout
- Write a JSP program (logout.jsp)
- Invalidate users session
- Redirect to "login.html"
136HW
- Build a login-based Web site, which has
- Login
- At least 3 Web pages which are allowed only for
authorized user - Logout
137DigressionJava Database Connectivity (JDBC)
138Java Database Connectivity
- Definitions
- JDBC is a standard Java interface for connecting
from Java to relational databases. - JDBC is an API for the Java programming language
that defines how a client may access a relational
database. - It provides methods for querying and updating
data in a database. - The JDBC standard was defined by Sun
Microsystems, allowing individual providers to
implement and extend the standard with their own
JDBC drivers.
139Steps in JDBC Programming
- Create a database
- Create a table
- Set up connection between JSP (or Java) and the
database - e.g. ODBC
- JDBC Programming in JSP
140JDBC Create a database (MS Access)
141JDBC Create a database (MS Access)
142JDBC Create a database (MS Access)
143Exercise 1 Create a database
- Create a database file named "mydb.mdb"
144Exercise 2 Create a database
- Create a database file named "shop.mdb"
145JDBC Create a table (MS Access)
146JDBC Create a table (MS Access)
147JDBC Create a table (MS Access)
148JDBC Create a table (MS Access)
149Exercise 1 Create a table
- Create a table named "customer" in database
"mydb.mdb", of which schema are
Field Type Size
cname Text 20
username Text 10
password Text 20
address Text 50
150Exercise 2 Create a table
- Create a table named "product" in database
"shop.mdb", of which schema are
Field Type Size
PID Text 10
pname Text 20
color Integer
price Integer
size Double
151JDBC Set up ODBC connection (MS Access)
152JDBC Set up ODBC connection (MS Access)
153JDBC Set up ODBC connection (MS Access)
154JDBC Set up ODBC connection (MS Access)
155JDBC Set up ODBC connection (MS Access)
156JDBC Set up ODBC connection (MS Access)
157JDBC Set up ODBC connection (MS Access)
158JDBC Set up ODBC connection (MS Access)
159Exercise 1 Set up a connection
- Set up an ODBC connection between a MS-Access
file "mydb.mdb" and a DSN "mydsn".
160Exercise 2 Set up a connection
- Set up an ODBC connection between a MS-Access
file "shop.mdb" and a DSN "shopdsn".
161JDBC JDBC Programming in JSP (ODBC)
- Syntax
- lt_at_ page import"java.sql." gt
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- Connection conn DriverManager.getConnection
("jdbcodbcdsn", "user", "password") - Statement stmt conn.createStatement()
- stmt.execute("") // SQL statement here
- ResultSet rs stmt.getResultSet()
-
- rs.next()
- s rs.getString()
-
- rs.close()
- stmt.close()
- conn.close()
Black words reserved words Violet words
what you must change Red words what you may
change
162JDBC Example (1) (ODBC) JDBC1
- lt_at_ page import"java.sql." gt
- ltHTMLgt
- ltBODYgt
- lt
- String DB_URL "jdbcodbcydsn"
- String DB_USER ""
- String DB_PASSWORD ""
- Connection conn
- Statement stmt
- ResultSet rs
- String query "SELECT FROM customer"
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- conn DriverManager.getConnection(DB_URL,
DB_USER, DB_PASSWORD) - stmt conn.createStatement()
163JDBC Example (2) (ODBC) JDBC1
- stmt.execute(query)
- rs stmt.getResultSet()
- while (rs.next())
-
- out.println(rs.getString("f_name") " / ")
- out.println(rs.getString("f_username") " /
") - out.println(rs.getString("f_password") " /
") - out.println(rs.getString("f_address") " /
") - out.println("ltBRgt")
-
- rs.close()
- stmt.close()
- conn.close()
- gt
- lt/BODYgt
- lt/HTMLgt
164JDBC Example (1) (Oracle) JDBC1
- lt_at_ page import"java.sql." gt
- lt_at_ page import"oracle.jdbc." gt
- lt_at_ page import"oracle.sql." gt
- ltHTMLgt
- ltBODYgt
- lt
- String DB_URL "jdbcoraclethin_at_134.53.
40.61521SBA" - String DB_USER "songyu"
- String DB_PASSWORD "songyu"
- Connection conn
- Statement stmt
- ResultSet rs
- String query "SELECT FROM customer"
- DriverManager.registerDriver(new
oracle.jdbc.OracleDriver()) - conn DriverManager.getConnection(DB_URL,
DB_USER, DB_PASSWORD) - stmt conn.createStatement()
165JDBC Example (2) (Oracle) JDBC1
- stmt.execute(query)
- rs stmt.getResultSet()
- for ( rs.next())
- out.println(rs.getString("f_name")
" / ") - out.println(rs.getString("f_username")
" / ") - out.println(rs.getString("f_password")
" / ") - out.println(rs.getString("f_address")
" / ") - out.println("ltBRgt")
-
- rs.close()
- stmt.close()
- conn.close()
- gt
- lt/BODYgt
- lt/HTMLgt
166Exercise 1 JDBC Programming JDBCX1
- Write a JSP program which displays all data in
"customer" table of "mydb.mdb" database.
167Exercise 2 JDBC Programming and Table JDBCX2
- Write a JSP program which displays all data in
"customer" table of "mydb.mdb" database by using
TABLE tag of HTML.
168Exercise 3 JDBC Programming JDBCX3
- Write a JSP program which displays all data in
"product" table of "shop.mdb" database.
169Exercise 4 JDBC Programming and Table JDBCX4
- Write a JSP program which displays all data in
"product" table of "shop.mdb" database by using
TABLE tag of HTML.
170DigressionStructured Query Language (SQL)
171INSERT
172SQL INSERT
- INSERT INTO customer
- (f_username, f_password, f_name, f_address)
- VALUES
- ('yusong', '1234', 'Yong Uk Song', '234, Maji,
Wonju') - INSERT INTO emp
- (empno, ename, job, sal, comm, deptno)
- VALUES
- (7890, 'JINKS', 'CLERK', 1.2E3, NULL, 40)
173SQL INSERT Simple Sample (1) SQL1S
- lt_at_ page import"java.sql." gt
- ltHTMLgt
- ltBODYgt
- lt
- String DB_URL "jdbcodbcydsn"
- String DB_USER ""
- String DB_PASSWORD ""
- Connection conn
- Statement stmt
- String query "INSERT INTO customer (f_name,
f_username, f_password, f_address) VALUES ('Yong
Uk Song', 'yusong', '1234', '234, Maji, Wonju')"
174SQL INSERT Simple Sample (2) SQL1S
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- conn DriverManager.getConnection(DB_URL,
DB_USER, DB_PASSWORD) - stmt conn.createStatement()
- stmt.execute(query)
- stmt.close()
- conn.close()
- gt
- lt/BODYgt
- lt/HTMLgt
175SQL INSERT Advanced Sample (1) SQL1A
- ltHTMLgt
- ltBODYgt
- ltFORM method"post" action"insert.jsp"gt
- Nameltinput typetext namenamegtltbrgt
- Userameltinput typetext nameusernamegtltbrgt
- Passwordltinput typetext namepasswordgtltbrgt
- Addressltinput typetext nameaddressgtltbrgt
- ltinput typesubmit value"Add"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
176SQL INSERT Advanced Sample (2) SQL1A
- lt_at_ page import"java.sql." gt
- ltHTMLgt
- ltBODYgt
- lt
- String name request.getParameter("name")
- String username request.getParameter("username"
) - String password request.getParameter("password"
) - String address request.getParameter("address")
- String query "INSERT INTO customer (f_name,
f_username, f_password, f_address) VALUES ('"
name "', '" username "', '" password
"', '" address "')"
177SQL INSERT Advanced Sample (3) SQL1A
- String DB_URL "jdbcodbcydsn"
- String DB_USER ""
- String DB_PASSWORD ""
- Connection conn
- Statement stmt
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- conn DriverManager.getConnection(DB_URL,
DB_USER, DB_PASSWORD) - stmt conn.createStatement()
- stmt.execute(query)
- stmt.close()
- conn.close()
- gt
- lt/BODYgt
- lt/HTMLgt
178SQL INSERT Simple vs. Advanced
- "INSERT INTO customer (f_name, f_username,
f_password, f_address) VALUES ('Yong Uk Song',
'yusong', '1234', '234, Maji, Wonju')" - "INSERT INTO customer (f_name, f_username,
f_password, f_address) VALUES (' " name " ',
' " username " ', ' " password " ', ' "
address " ')"
179Exercise 1 INSERT SQL1X1
- Write a JSP program which adds a data into the
"product" table of "shop.mdb" database.
180Exercise 2 INSERT SQL1X2
- Write an HTML file and a JSP program which inputs
a data from a user and adds the data into the
"product" table of "shop.mdb" database.
181UPDATE
182SQL UPDATE
- UPDATE customer
- SET f_name 'Hong', f_address 'Oxford'
- WHERE f_username 'yusong'
- UPDATE emp
- SET comm NULL
- WHERE job 'TRAINEE'
183SQL UPDATE Simple Sample (1) SQL2S
- lt_at_ page import"java.sql." gt
- ltHTMLgt
- ltBODYgt
- lt
- String DB_URL "jdbcodbcydsn"
- String DB_USER ""
- String DB_PASSWORD ""
- Connection conn
- Statement stmt
- String query "UPDATE customer SET
address'Wonju' WHERE username'yusong' "
184SQL UPDATE Simple Sample (2) SQL2S
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- conn DriverManager.getConnection(DB_URL,
DB_USER, DB_PASSWORD) - stmt conn.createStatement()
- stmt.execute(query)
- stmt.close()
- conn.close()
- gt
- lt/BODYgt
- lt/HTMLgt
185SQL UPDATE Advanced Sample (1) SQL2A
- ltHTMLgt
- ltBODYgt
- ltFORM method"post" action"update.jsp"gt
- Nameltinput typetext namenamegtltbrgt
- Userameltinput typetext nameusernamegtltbrgt
- Passwordltinput typetext namepasswordgtltbrgt
- Addressltinput typetext nameaddressgtltbrgt
- ltinput typesubmit value"Update"gt
- lt/FORMgt
- lt/BODYgt
- lt/HTMLgt
186SQL UPDATE Advanced Sample (2) SQL2A
- lt_at_ page import"java.sql." gt
- ltHTMLgt
- ltBODYgt
- lt
- String name request.getParameter("name")
- String username request.getParameter("username"
) - String password request.getParameter("password"
) - String address request.getParameter("address")
- String query "UPDATE customer SET f_address'"
address "' WHERE f_username'" username
"'"
187SQL UPDATE Advanced Sample (3) SQL2A
- String DB_URL "jdbcodbcydsn"
- String DB_USER ""
- String DB_PASSWORD ""
- Connection conn
- Statement stmt
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- conn DriverManager.getConnection(DB_URL,
DB_USER, DB_PASSWORD) - stmt conn.createStatement()
- stmt.execute(query)
- stmt.close()
- conn.close()
- gt
- lt/BODYgt
- lt/HTMLgt
188SQL UPDATE Simple vs. Advanced
- "UPDATE customer SET f_address'Wonju' WHERE
f_username'yusong' " - "UPDATE customer SET f_address' " address "
' WHERE f_username' " username " ' "
189Exercise 1 UPDATE SQL2X1
- Write a JSP program which updates a data in the
"product" table of "shop. mdb" database.
190Exercise 2 UPDATE SQL2X2
- Write an HTML file and a JSP program which inputs
a data from a user and updates the data in the
"product" table of "shop.mdb" database.
191DELETE
192SQL DELETE
- DELETE FROM customer
- WHERE f_username 'yusong'
- DELETE FROM emp
- WHERE job 'SALESMAN'
- AND comm lt 100
193SELECT
194SQL SELECT (1)
- SELECT f_name, f_address
- FROM customer
- WHERE f_username 'yusong'
-
- SELECT
- FROM tblasp
- ORDER BY name
- WHERE age lt 30
195SQL SELECT (2)
- SELECT
- FROM emp
- WHERE deptno 40
- SELECT ename, job, sal, deptno
- FROM emp
- WHERE NOT (job 'SALESMAN' AND deptno 30)
- ORDER BY deptno ASC, sal DESC
196SQL SELECT Simple Sample (1) SQL4S
- lt_at_ page import"java.sql." gt
- ltHTMLgt
- ltBODYgt
- lt
- String DB_URL "jdbcodbcydsn"
- String DB_USER ""
- String DB_PASSWORD ""
- Connection conn
- Statement stmt
- ResultSet rs
- String query "SELECT password FROM customer
WHERE username'yusong'" - Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- conn DriverManager.getConnection(DB_URL,
DB_USER, DB_PASSWORD) - stmt conn.createStatement()
197SQL SELECT Simple Sample (2) SQL4S
- stmt.execute(query)
- rs stmt.getResultSet()
- if (!rs.next())
-
- out.println("Unknown user")
-
- else if (rs.getString("f_password").equals("1234"
)) -
- out.println("Login success")
-
- else
-
- out.println("Login failure")
-
- stmt.close()
- conn.close()
- gt
- lt/BODYgt
- lt/HTMLgt
198SQL Result Set (1)
yusong 1234 Yong Song Wonju, Korea
wkim abcd Woo Kim Seoul, Korea
spark qwer Sang Park Suwon, Korea
slee asdf Soo Lee Ohio, U.S.A
jhong zxcv June Hong Seoul, Kora
rs.getString("f_username") ? Error rs.getString("f
_password") ? Error rs.getString("f_name") ?
Error rs.getString("f_address") ? Error
Firstly,
199SQL Result Set (2)
yusong 1234 Yong Song Wonju, Korea
wkim abcd Woo Kim Seoul, Korea
spark qwer Sang Park Suwon, Korea
slee asdf Soo Lee Ohio, U.S.A
jhong zxcv June Hong Seoul, Kora
rs.getString("f_username") ? "yusong" rs.getString
("f_password") ? "1234" rs.getString("f_name") ?
"Yong Song" rs.getString("f_address") ? "Wonju,
Korea"
rs.next( ) ? true
200SQL Result Set (3)
yusong 1234 Yong Song Wonju, Korea
wkim abcd Woo Kim Seoul, Korea
spark qwer Sang Park Suwon, Korea
slee asdf Soo Lee Ohio, U.S.A
jhong zxcv June Hong Seoul, Kora
rs.getString("f_username") ? "wkim" rs.getString("
f_password") ? "abcd" rs.getString("f_name") ?
"Woo Kim" rs.getString("f_address") ? "Seoul,
Korea"
rs.next( ) ? true
201SQL Result Set (4)
yusong 1234 Yong Song Wonju, Korea
wkim abcd Woo Kim Seoul, Korea
spark qwer Sang Park Suwon, Korea
slee asdf Soo Lee Ohio, U.S.A
jhong zxcv June Hong Seoul, Kora
rs.getString("f_username") ? "spark" rs.getString(
"f_password") ? "qwer" rs.getString("f_name") ?
"Sang Park" rs.getString("f_address") ? "Suwon,
Korea"
rs.next( ) ? true
202SQL Result Set (5)
yusong 1234 Yong Song Wonju, Korea
wkim abcd Woo Kim Seoul, Korea
spark qwer Sang Park Suwon, Korea
slee asdf Soo Lee Ohio, U.S.A
jhong zxcv June Hong Seoul, Kora
rs.getString("f_username") ? "slee" rs.getString("
f_password") ? "as