tag:blogger.com,1999:blog-85533083603671663302024-03-13T03:43:50.176-07:00All free tutorialsSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-8553308360367166330.post-75391073035847766632009-01-02T02:58:00.000-08:002009-01-02T02:59:11.462-08:00Business Application Programming Interface <meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><title>Tutorial on BAPI</title><!--[if gte mso 9]><xml> <o:documentproperties> <o:subject>BAPIs</o:Subject> <o:author>Sudhanshu Singh</o:Author> <o:version>12.00</o:Version> </o:DocumentProperties> </xml><![endif]--><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" semihidden="false" unhidewhenused="false" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-alt:Wingdings; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-fareast-language:ZH-CN;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif"; color: black;">
<br /></span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif"; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif"; color: black;">Definition </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif"; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">A Business Application Programming Interface (BAPI) is a precisely defined interface providing access to processes and data in business application systems such as R/3. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">BAPIs are defined as API methods of SAP Objects. These objects and their BAPIs are described and stored in the Business Object Repository (BOR). <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif"; color: black;">Use </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif"; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">BAPIs can be called within the R/3 System from external application systems and other programs. A BAPI call can either be made as an object oriented method call or as a remote function call (RFC). <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">BAPIs are a global communication standard for business applications. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Examples of what BAPIs can be used for include: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">R/3 satellite systems <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Distributed R/3 scenarios using Application Link Enabling (ALE) <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Connecting R/3 Systems to the Internet using Internet application components (IACs) <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Visual Basic programs as front ends to R/3 Systems <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Work flow applications that extend beyond system boundaries <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Customers' and partners' own developments <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Connections to non-SAP software <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings; color: black;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Connections to legacy systems <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Business Object Repository (BOR) </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Definition </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The Business Object Repository (BOR) is the object oriented repository in the R/3 System. It contains, among other objects, SAP Business Objects and their methods. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In the BOR a Business Application Programming Interface (BAPI) is defined as an API method of an SAP Business Object. Thus defined, the BAPIs become standard with full stability guarantees as regards their content and interface. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Use </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">With regard to SAP Business Objects and their BAPIs, the BOR has the following functions: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• provides an object oriented view of R/3 System data and processes. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">R/3 application functions are accessed using methods (BAPIs) of SAP Business Objects. Implementation information is encapsulated; only the interface functionality of the method is visible to the user. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• arranges the various interfaces in accordance with the component hierarchy, enabling functions to be searched and retrieved quickly and simply. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Manages BAPIs in release updates. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">BAPI interface enhancements made by adding parameters are recorded in the BOR. Previous interface versions can thus be reconstructed at any time. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">When a BAPI is created the release version of the new BAPI is recorded in the BOR. The same applies when any interface parameter is created. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The version control of the function module that a BAPI is based on is managed in the Function Builder<i>. </i><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Ensures interface stability. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Any interface changes that are carried out in the BOR, are automatically checked for syntax compatibility against the associated development objects in the ABAP Dictionary. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Integration </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You should only define a BAPI as a SAP Business Object method in the BOR if the function module that the BAPI is based on has been fully implemented. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Full access to the BOR is restricted to the persons responsible for the objects involved and for quality control. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif";">BOR-BAPI Wizard </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BOR-BAPI Wizard assists with creating new BAPI methods in the BOR. It takes you through the creation process step by step. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 4 A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Transaction Model for Developing BAPIs </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The transaction model in which BAPIs are used determines how you have to program BAPIs. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The transaction model described here has been used to develop BAPIs for R/3 Releases 3.1 and 4.0A. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Logical Unit of Work (LUW) and Statelessness </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Within the context of this transaction model a transaction represents one processing step or one logical unit of work (LUW). When a transaction is called, database operations are either fully executed or not at all. The whole transaction must be programmed to be stateless. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">This transaction model requires that: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• no data is imported that may indirectly affect the result. If a transaction is called more than once, each call must have the same result. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For BAPIs this means, for example, that Set or Get parameters cannot be used. However, you can keep Customizing data in a global memory as this data remains unchanged even if transaction calls are repeated. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• there must be no functional dependencies between two transactions. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• either <b>all </b>relevant data has to be changed in the database or <b>none </b>at all. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The following sections describe how the transaction model effects BAPI development: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Using the Transaction Model in Release 3.1 <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Using the Transaction Model in Release 4.0A <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 14pt; font-family: "Arial","sans-serif";">Using the Transaction Model in Release 3.1 </span></b><span style="font-size: 14pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The example below of an external program calling a BAPI to change data in an R/3 System, illustrates how the transaction model affects BAPI development in Release 3.1. Assume the transaction was written in, for instance, Visual Basic and that data is to be changed in the R/3 System only. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The RFC connection is live the whole time the external program is logged on to the R/3 System to avoid having to connect and disconnect repeatedly. When the RFC connection is already established, an RFC call does not essentially take up any more CPU time than a direct call to the function module from within the R/3 System. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">There is one BAPI call for each transaction in the transaction model supported in 3.1. BAPIs can only be called synchronously. A BAPI call is essentially the call of the underlying RFC capable function module. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Process Flow </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The process flow of the program consists of the steps below (see graphic): <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Log on <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 5A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">..... (Visual Basic source code) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Call BAPI to read and/or change data <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">..... (Visual Basic source code) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Call BAPI to read and/or change data <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">..... (Visual Basic source code) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Log off <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Prerequisites </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">What do the terms "LUW" and "statelessness" mean to BAPIs that are implemented in the framework of this transaction model? <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">If a transaction represents one Logical Unit of Work and in addition is supposed to be stateless, BAPIs are affected as follows: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>Initial state each time a BAPI is called </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A repeated call of one BAPI must produce the same result. Only data that is not affected by the execution of the BAPI, for example, customizing data, can be buffered. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>No functional dependency between two BAPIs </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A BAPI call must not be negatively affected by an earlier call of another BAPI. A follow up call must not presuppose an earlier call. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>All or nothing principle </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A database change, for example, creating a new sales order, must be carried out completely or not at all (LUW). <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">This is why BAPIs to be implemented in 3.1 are created with integrated commit control. The "Commit Work" command is always invoked at the end of the function module of a BAPI that modifies data. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 6 A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 14pt; font-family: "Arial","sans-serif";">Using the Transaction Model in Release 4.0A </span></b><span style="font-size: 14pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In Release 4.0A the Commit control must be taken out of write BAPIs, that is, those BAPIs that cause database changes. However, the existing transaction model used in Release 3.1 should not be changed. This is achieved by using the RFC capable function module BAPI_TRANSACTION_COMMIT which executes the command "Commit Work". <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">This procedure is required because BAPIs are used for continued development of the R/3 System, for example, for separating individual R/3 components. If this is the case, BAPIs must support the transaction model used in the R/3 System. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Features </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A program based on this transaction model could consist of the following steps (see graphic): <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Log on <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">..... (Visual Basic source code) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Call BAPI to read and/or change data <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Call BAPI_TRANSACTION_COMMIT <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">..... (Visual Basic source code) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Call BAPI to read and/or change data <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Call BAPI_TRANSACTION_COMMIT <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">..... (Visual Basic source code) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Log off <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 7A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Defining and Implementing the BAPI </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A BAPI is an API method of a business object and is defined as such in the Business Object Repository (BOR). However, a BAPI is implemented as an RFC capable function module which is maintained in the Function Builder. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For function modules that implement BAPIs certain standards and rules must be adhered to over and above the standard programming rules for function modules. This section describes how to define a BAPI and which particular guidelines to comply with. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">When implementing BAPIs follow the requirements below to ensure you achieve consistent behavior and representation of BAPIs as object oriented methods of SAP Business Objects. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">There is a range of BAPIs that provide basic functions and these can be implemented for most of the SAP Business Objects. For information on these BAPIs see the section Frequently Used BAPIs. Check if the BAPI you want to implement is in one of these general categories. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Process Flow </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The process of defining and implementing a BAPI consists of the following steps: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Describing the Scenario in which the BAPI is used <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Reviewing the BAPI Concept and BAPI Scenario <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Defining a BAPI and Its Interface <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Creating Individual Programming Objects <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Testing the BAPI <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Releasing and Freezing the BAPI <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 8 A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Frequently Used BAPIs </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Definition </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Some BAPIs and methods provide basic functions and can be used for most SAP Business Objects. These BAPIs are: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif";">BAPIs for Reading Data </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The following BAPIs provide you with read-only access to data in the associated Business Object: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>GetList </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">With this BAPI you can select a range of object key values, for example, company codes and material numbers. To specify appropriate selection requirements the calling program must pass the relevant parameters to the interface. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The key values selected by the BAPI <i>GetList </i>are returned to the calling program in a table, together with other useful information, for example, short texts. The key values can then be passed on to another BAPI for further processing, for example, the BAPI <i>GetDetail, </i>as listed below. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For further information on programming GetList BAPIs see Programming Value Ranges. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>GetDetail </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>GetDetail </i>uses a key to retrieve details about a specific instance of an object and returns this data to the calling program. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>GetStatus </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>GetStatus </i>is used to query the status of an SAP Business Object, for example, to determine the processing status of a sales order. This BAPI is used only for displaying the status of an object and does not retrieve full details like the BAPI <i>GetDetail</i>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>ExistenceCheck </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>ExistenceCheck </i>checks whether an entry exists for an SAP Business Object, for example, whether the customer master has been created. You should implement this method as a workflow method and not as a BAPI (RFC capable function module). <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The method <i>CompanyCode.ExistenceCheck </i>of the business object <i>CompanyCode </i>(BUS0002) is an example of this. This workflow method is indirectly invoked when the calling program instantiates an object, for example, by using GetSAPObject("CompanyCode") from within Visual Basic. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif";">BAPIs for Creating or Changing Data </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The following BAPIs can create, change or delete instances of a business object: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>Create or CreateFromData </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>Create </i>or <i>CreateFromData </i>creates an instance of an object, for example, a sales order. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>Change </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>Change </i>changes an existing instance of a SAP Business Object, for example, a sales order. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For more information about the BAPI <i>Change </i>see Programming Replicate/Clone BAPIs. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>Delete </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>Delete </i>deletes an instance of a SAP Business Object, for example, a sales order. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 9A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif";">BAPIs for Replicating Business Object Instances </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPIs below can be implemented as methods of business objects that can be replicated. For further information about these BAPIs see Programming Replicate/Clone BAPIs: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>Replicate </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>Replicate </i>is used by a client system to request clones of business objects in a server system. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">This method must be implemented for each business object to be cloned. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">At least one of the following BAPIs must be implemented for each business object to be cloned: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>Clone </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>Clone </i>is used by a system to replicate one business object on another system or to modify one business object that has already been cloned. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• <b>CloneMultiple </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI <i>CloneMultiple </i>is used by a system to replicate several business objects on another system or to modify several business objects that have already been cloned. Unlike the BAPI <i>Clone</i>, the BAPI <i>CloneMultiple </i>can replicate or modify several business object instances at the same time. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 10 A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Defining a BAPI Scenario </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Before you program a BAPI you should clearly define the processes and situations the BAPI will be used for. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Process Flow </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">To define the scenario the BAPI is to be used for, consider the following issues: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Which scenario is to be implemented? <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Every BAPI should be based on a model of a scenario in which it can be usefully employed. You can describe the scenario in the form of a <b>process model. </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Which SAP Business Objects are involved? <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">From the scenario definition and with the help of the process model you can get information about the SAP Business Objects relevant to the BAPI scenario. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 9pt; font-family: "Arial","sans-serif";">Example </span></b><span style="font-size: 9pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In the scenario to be implemented, a BAPI is required to read data about a creditor. First of all, a list of creditors is to be displayed from which a specific creditor can be selected. Then, using another BAPI, specific details about this creditor are to be displayed. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The relevant SAP Business Object for this scenario is <i>Creditor. </i><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• What functionality should the BAPI provide and how does it affect related BAPIs, especially the other BAPIs of the SAP Business Object in question? <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In line with the scenario concept BAPIs must complement each other to create a complete scenario. Their relationships with each other must be clearly defined. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 9pt; font-family: "Arial","sans-serif";">Example </span></b><span style="font-size: 9pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">To read a creditor's details as described in the above scenario, two BAPIs are required: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";">- </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Display list of creditors <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";">- </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Display details of a specific creditor <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The interdependency between these two BAPIs is evident because first the creditor list is displayed to obtain the ID of the specific creditor sought. From this ID, details of this creditor can then be displayed. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">However, the two BAPIs remain functionally independent of each other, because if the creditor ID is known, the BAPI "Display details of a specific creditor" can be used without first calling the BAPI "Display list of creditors". <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• To what extent can the BAPI's functionality be implemented within the scope of the business object? <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A BAPI should be developed so that it provides functionality exclusively within the context of its associated SAP Business Object. If the data of a different SAP Business Object is to be read or updated then the appropriate interface for this object must be used. The functions or methods of these other objects are used implicitly (delegation principle). <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 9pt; font-family: "Arial","sans-serif";">Example </span></b><span style="font-size: 9pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 11A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal; page-break-before: always;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPIs required to read creditor details in the above scenario are only able to access data in the SAP Business Object <i>Creditor. </i>Other object types are not involved. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Is the BAPI assigned to the SAP Business Object in a meaningful and semantically correct way? <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Result </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Once you have considered these issues you will be able to clearly conceptualize the functionality of the planned BAPI(s). You will also have identified the SAP Business Objects relevant to the BAPI scenario. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 14pt; font-family: "Arial","sans-serif";">Review </span></b><span style="font-size: 14pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In the previous step you created a concept for a scenario a BAPI could be applied to. You also defined relevant SAP Business Objects. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Before you implement the scenario and begin defining and developing the BAPI, you should carry out a review of the scenario concept. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Process Flow </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You should carry out the review of the BAPI scenario in cooperation with all persons involved in the BAPI development and those responsible for quality control in your development group. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Result </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Start developing the BAPI only after you have successfully completed the review. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 12 A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Defining a BAPI and Its Interface </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">After you have carried out the review of the BAPI concept and it has been accepted, you can start defining the BAPI itself. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In this step, you will decide on the names, parameters, and characteristics of the BAPI and determine the structures the BAPI will be based on. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Only after you have planned and defined these required details can you start to implement the BAPI, as described in Creating Individual Programming Objects and Programming BAPIs. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Process Flow </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">To define the scope and required components of the BAPI to be implemented, the following steps must be completed: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Determining the SAP Business Object and Its Key Fields <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Defining the Interface Structure of the BAPI <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Identifying the name of the function group, or if a function group does not exist already, planning a name for one. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">All BAPIs belonging to one SAP Business Object should be stored as function modules in one function group. Ascertain whether a function group has already been created for the BAPIs of the SAP Business Object in question. If a function group does not already exist, then plan a name for the one to be created. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You can use the default technical name (object type) of the SAP Business Object as the basis of the function group name. The technical name of a SAP Business Object usually takes the form of <i>BUSnnnn</i>, where <i>n </i>is a number. Use the suffix "<i>nnnn</i>" as the name of the function group. For example, if the technical name of the object is <i>BUS1008 </i>then the associated BAPI function group is called <i>1008. </i><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">To ascertain the technical name of the Business Object, open the Business Object in the Business Object Repository (BOR), as described in Determining the SAP Business Object and Its Key Fields. To display further details, for example, the object type, double click the name of the Business Object. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Assigning a name to the function module <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Choose a name that gives an indication of what the BAPI is used for. The naming convention is: BAPI_<<i>Business Object name</i>>_<<i>method name</i>>. For information about naming a method refer to Naming the Method in the BOR. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For example, in the case of a BAPI which reads details for the object type <i>Creditor</i>, the name of the associated function module is <i>BAPI_CREDITOR_GETDETAIL</i><b>. </b><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Naming Parameters in the Function Module <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Defining the format for passing the values in the function module interface. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Parameters must not be converted before they are passed to and from the BAPI interface. This is because BAPIs are programming interfaces and not end user interfaces. Exceptions are currency codes, ISO codes and fields with an internal key. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Specifying the Required Objects in ABAP Dictionary <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Naming the Method in the BOR <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Naming Parameters in the BOR <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 1 _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 10.5pt; font-family: "Arial","sans-serif";">123 </span></b><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Determining the SAP Business Object and Its Key Fields </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You have to identify the relevant SAP Business Object in the Business Object Repository (BOR) and determine whether the key fields of the Business Object are relevant for your BAPI. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A key is defined in the BOR for most SAP Business Objects. This key can consist of several key fields. The contents of these key fields uniquely identify one individual instance of an SAP Business Object. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You can differentiate between instance-dependent and instance-independent BAPI methods. Unlike instance-independent methods, instance-dependent methods relate to one instance (one specific occurrence) of an SAP Business Object type, for example to one specific sales order. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In the case of instance-dependent BAPIs, the key fields of the corresponding SAP Business Object must be used as parameters in the function module the BAPI is based on so that the associated object instance can be identified. The names of the key fields in the SAP Business Object and the corresponding parameters in the BAPI function module must be the same, because the name links the key fields to the parameters. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">All the key fields defined in the BOR for the SAP Business Object in question must be used as the parameters in the function module. For further information see Defining the Interface Structure of the BAPI. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 9pt; font-family: "Arial","sans-serif";">Example </span></b><span style="font-size: 9pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">SAP Business Object <i>Creditor </i>has a key field named <i>CreditorId</i>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">This key field must be defined as a parameter with the name <i>CREDITORID </i>in the function modules of the instant-dependent BAPIs for this Business Object. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">To display the Business Object and its key fields follow the steps below: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">1. Select <i>Tools </i>→ <i>ABAP Workbench </i>→ <i>Overview </i>→ <i>Business Object Browser </i>. The business objects are displayed in the order of the R/3 application hierarchy. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">2. Select the required SAP Business Object in the application hierarchy and double click it to open it. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">3. To display the Business Object's key fields, expand the node <i>Key fields. </i><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 14 A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Defining the Interface Structure of the BAPI </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In this step you are going to define the BAPI interface, that is, the individual import, export and table parameters required for calling the BAPI. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 8.5pt; font-family: "Arial","sans-serif";">Caution </span></b><span style="font-size: 8.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You cannot use Changing and Exception parameters in a function module which implements a BAPI. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Process Flow </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">To define the interface parameters, proceed as follows: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">1. Check whether the key fields of the SAP Business Object are required in the interface. The key fields of the SAP Business Object are some of the most important BAPI parameters. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";">- </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">If a key value is to be passed to the BAPI by the calling program, the key field must be set as an import parameter in the function module of the BAPI. That way a specific instance of the Business Object is identified. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For example, this could be a customer number (CustomerNo) in the BAPIs <i>Customer.GetDetail </i>and <i>Customer.CheckPassword, </i>or the number of a sales document in the BAPI <i>SalesOrder.GetStatus</i>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";">- </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For BAPIs that generate instances, for example, the BAPIs <i>Create </i>or <i>CreateFromData, </i>the key field of the Business Object should be set as an export parameter in the BAPI function module. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">These BAPIs return one key value, for example, an order number in the BAPI <i>SalesOrder.CreateFromData</i>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";">- </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">For BAPIs that are class methods a key field is <b>neither </b>set as an import <b>nor </b>as an export parameter in the BAPI function module. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Class methods are instance-independent and are called without the use of key values. Usually they return a table with a selection of key values. Exceptions are write BAPIs, as described in the list item above. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">2. Specify what other data is relevant as import, export or table parameters for the BAPI. Every BAPI must have an Export parameter return that reports messages back to the calling program. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 9pt; font-family: "Arial","sans-serif";">Example </span></b><span style="font-size: 9pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The BAPI to be developed is to read data from the SAP Business Object <i>Creditor. </i>To read creditor details, the calling program has to pass the ID of the creditor and the company code. The creditor data returned is to include general details, specific details and bank details. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">To map these requirements onto the BAPI interface, the following parameters must be set in the function module which the BAPI is based on: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">The key field <i>CreditorID </i>of the SAP Business Object as an import parameter <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">An import parameter for the company code <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A Return parameter that reports messages back to the calling program <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A parameter for general details of the creditor <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A parameter for specific details of the creditor <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Wingdings;">�� </span><span style="font-size: 10pt; font-family: "Arial","sans-serif";">A parameter for bank details of the creditor <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">_________ __________________________________________________________________ 15A _____________________________ <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><b><span style="font-size: 16pt; font-family: "Arial","sans-serif";">Naming Parameters in the Function Module </span></b><span style="font-size: 16pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Purpose </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In the previous step you identified the contents of the interface parameters. Now you can specify the names of these parameters in the function module. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";">Prerequisites </span></b><span style="font-size: 11.5pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You can only define export, import and table parameters in the function module interface of the BAPI. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Give meaningful names to the parameters in the function module interface to give the BAPI an easy-to-use interface. This is because the names you choose for the function module parameters are used in the Business Object Repository (BOR) as the names of the corresponding method parameters. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">When assigning parameter names follow the guidelines below: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• The names must be in English <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• The names of parameters in the function module can generally be a maximum of 30 alphanumeric characters. The names of parameters in a function module that implements a BAPI can only have a maxiumum of 20 alphanumeric characters, because the names of parameters in the function module must be identical to the parameter names in the BOR, and the latter are restricted to a maxiumum of 20 characters. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• The names of parameters in the function module must be written in capitals. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• Choose meaningful names and do not use abbreviations. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 9pt; font-family: "Arial","sans-serif";">Example </span></b><span style="font-size: 9pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">In the above example based on the creditor scenario, the following parameters were identified: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• An import parameter for the key field <i>CreditorId </i>of the SAP Business Object <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• An import parameter for the company code <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• A Return parameter <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• A parameter for general details of creditor <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• A parameter for specific details of creditor <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">• A parameter for bank details of creditor <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif";">You could use the following names for these parameters in the function module: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif";">Parameters and their Names in the Function Module </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="border: medium none ; margin-left: 9pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style="height: 13.85pt;"> <td style="border: 1pt solid black; padding: 0in 5.4pt; width: 149.8pt; height: 13.85pt;" valign="top" width="200"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Contents </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p></o:p></span></p> </td> <td style="border-style: solid solid solid none; border-color: black black black -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 117.4pt; height: 13.85pt;" valign="top" width="157"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Name in Function Module </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p></o:p></span></p> </td> <td style="border-style: solid solid solid none; border-color: black black black -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 117.4pt; height: 13.85pt;" valign="top" width="157"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Parameter Type </span></b><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style="height: 99.55pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 149.8pt; height: 99.55pt;" valign="top" width="200"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Creditor number <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">Company code General creditor details Specific creditor details Return parameter Bank details <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 117.4pt; height: 99.55pt;" valign="top" width="157"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">CREDITORID <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">COMPANYCODE CREDITORGENERALDATA CREDITORCOMPANYDATA RETURN CREDITORBANKDATA <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 117.4pt; height: 99.55pt;" valign="top" width="157"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">IMPORTING <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Arial","sans-serif"; color: black;">IMPORTING EXPORTING EXPORTING EXPORTING TABLES <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-30592073494116087282009-01-02T02:55:00.000-08:002009-01-02T02:56:26.437-08:00SAP Script Tutorial <meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><title>Microsoft Word - SAPScript</title><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>Sudhanshu Singh</o:Author> <o:version>12.00</o:Version> </o:DocumentProperties> </xml><![endif]--><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" unhidewhenused="false" name="Normal (Web)"> <w:lsdexception locked="false" unhidewhenused="false" name="HTML Preformatted"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"French Script MT"; panose-1:3 2 4 2 4 6 7 4 6 5; mso-font-alt:"French Script MT"; mso-font-charset:0; mso-generic-font-family:script; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-alt:Verdana; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} @font-face {font-family:"Arial Rounded MT Bold"; panose-1:2 15 7 4 3 5 4 3 2 4; mso-font-alt:"Arial Rounded MT Bold"; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-fareast-language:ZH-CN;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; text-indent: 0.05pt; line-height: normal;" align="center"><span style="font-size: 26pt; font-family: "French Script MT"; color: black;">Introduction <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Often there are instances where an output from a SAP program is required on a physical paper in a pre-designed format. Using normal ABAP code this is not possible. Instead SAP provides an object called <b>SAPSCRIPT </b>to generate such kind of documents which can contain logos, tables and other objects and which can look like pre-printed documents. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">This tutorial focuses on the design and use of Layout sets in ABAP programs to generate beautified output in SAP. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">A layout set is a template designed in SAP to place the stream of data coming from a SAP program on different parts of a physical page. The designer needs to <b><i>lay out </i></b>the various elements that need to be printed on the page and store it as an object in the SAP system. An ABAP program will subsequently call this object to generate an instance of the template – thus generating an output document from the program. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">In this tutorial we will cover subjects such as: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">• </span><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Main elements of SAPScript <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">• </span><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Commands that can be used in a layout set <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">• </span><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">How to include a graphical image <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">• </span><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Commands that can be used in SAPScript <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">• </span><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Step-by-step walkthrough of example <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">• </span><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Example layout set <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">• </span><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Example SAPScript code <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 26pt; font-family: "French Script MT";">Main Elements <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Language </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Language in which the data coming on to the layout set will be printed. Generally, this will be the language that has been set up as default in the SAP system <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Header </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Section to define the various attributes of the layout set on a global level. Changing these attributes will affect all the components of the layout set. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">The various components of the header are explained below: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">• </span><b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Administration Information </span></b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">This shows the information about the layout set – details of the designer, details of changes occurring to the design, development class of the layout set and the language details for the layout set. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">• </span><b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Standard Attributes </span></b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">1. Description - Brief description or title of the layout set <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">2. Default paragraph - The base paragraph that is globally applicable to the document. This can be overridden at lower level of the layout set by using other paragraphs <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">3. Tab Stop - The base tab-stop that is globally applicable to the document. These can be overridden at lower level of the layout set by using other tab stops <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">4. First Page - The start page of the layout set <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">5. Page Format <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">6. Orientation - The direction of printing the data on a page – P for portrait (vertical) and L for landscape (horizontal) <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">7. Lines per inch <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">8. Characters/inch <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.75in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">• </span><b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Font Attributes </span></b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Here the various attributes and the base font applicable to the document can be defined. This font setting can be overridden at a lower level using the character strings. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Paragraphs </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Used to define the start and end positions for the different texts and objects that need to be printed on the output document. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Character Strings </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Used to define the fonts, and the formatting and printing styles for each and every character that needs to be printed on the output document. The start of the character string is indicated by <string>, while the end of the character string is indicated by </>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Pages </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">The designer needs to organize the template as a series of pages. When an actual output document is printed, it will refer to each page for putting the data coming from the ABAP program. The order of pages is also taken from the template i.e. the layout set defined. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Windows </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Various parts of the output document can be conveniently organized on the pages using windows. Thus the data stream coming from the ABAP program can be logically grouped into various parts and can be placed on different locations on a page. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">There are 2 main types of windows that can be used in a layout set: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Arial Rounded MT Bold","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><span style="font-size: 9pt; font-family: "Arial Rounded MT Bold","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Arial Rounded MT Bold","sans-serif";">• </span><b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">MAIN </span></b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">- A layout set can have only one MAIN window which is created by default. This window can flow over multiple pages. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">• <b>CONSTANT </b>- A layout set can have any number of constant windows. A CONSTANT window can be used once per page. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Text Elements </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Any text that needs to be written on the output document should be placed within a text element. This includes constant text as well as variable data like internal table data coming from the ABAP program. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">It is advisable to group logically related data within one text element. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">The fields of various tables defined in the ABAP program will be included under these text elements. These fields are carriers of data. Every field should be included in a pair of ‘&’ characters. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";">Page Windows </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">All the windows that form a page of the layout set. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">Choose the window and click the <b>Text Elements </b>button to go to the Layout Set Editor. This consists of 2 parts. The small space on the left is for specifying the type of command, while the window adjacent to it is for writing the command or the text that needs to go under a text element. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 26pt; font-family: "French Script MT";">Layout Set Commands <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";">The various types of commands that can be used within a layout set are tabulated below: </span></b><span style="font-size: 9pt; font-family: "Verdana","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="border: medium none ; margin-left: 6.7pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style="height: 12.1pt;"> <td style="border: 1pt solid black; padding: 0in 5.4pt; background: rgb(204, 255, 204) none repeat scroll 0% 0%; width: 207.8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; height: 12.1pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">Command </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;"><o:p></o:p></span></p> </td> <td style="border-style: solid solid solid none; border-color: black black black -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; background: rgb(204, 255, 204) none repeat scroll 0% 0%; width: 207.8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; height: 12.1pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;">Purpose </span></b><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">* <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Default paragraph <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Blank <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Continuous text <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">= <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Extended Line <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">( <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Raw Line <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">/ <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Line Feed <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">/= <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Line Feed and extended line <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">/( <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Line Feed and Raw Line <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">/: <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Command Line <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">/* <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Comment Line <o:p></o:p></span></p> </td> </tr> <tr style="height: 10.85pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">/E <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 10.85pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">Text Element <o:p></o:p></span></p> </td> </tr> <tr style="height: 21.8pt;"> <td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 207.8pt; height: 21.8pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;"><pn> <o:p></o:p></span></p> </td> <td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 207.8pt; height: 21.8pt;" valign="top" width="277"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9pt; font-family: "Verdana","sans-serif"; color: black;">This is either the name of the paragraph that should be applicable from that line of the layout set. <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-31837911717403371572009-01-02T02:42:00.000-08:002009-01-02T02:45:13.890-08:00HTML Tutorial<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="0" name="footer"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="0" name="FollowedHyperlink"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="HTML Top of Form"> <w:lsdexception locked="false" priority="0" name="HTML Bottom of Form"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="HTML Typewriter"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Garamond; panose-1:2 2 4 4 3 3 1 1 8 3; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h2 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 2 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:2; font-size:18.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} h3 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 3 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:3; font-size:13.0pt; font-family:"Arial","sans-serif"; mso-fareast-language:EN-US; font-weight:bold;} p.MsoHeader, li.MsoHeader, div.MsoHeader {mso-style-unhide:no; mso-style-link:"Header Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} p.MsoFooter, li.MsoFooter, div.MsoFooter {mso-style-unhide:no; mso-style-link:"Footer Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} tt {mso-style-unhide:no; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} span.Heading2Char {mso-style-name:"Heading 2 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 2"; mso-ansi-font-size:18.0pt; mso-bidi-font-size:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.Heading3Char {mso-style-name:"Heading 3 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 3"; mso-ansi-font-size:13.0pt; mso-bidi-font-size:13.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-fareast-language:EN-US; font-weight:bold;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} p.intro, li.intro, div.intro {mso-style-name:intro; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.ieonly {mso-style-name:ieonly; mso-style-unhide:no;} span.z-TopofFormChar {mso-style-name:"z-Top of Form Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"z-Top of Form"; mso-ansi-font-size:8.0pt; mso-bidi-font-size:8.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; display:none; mso-hide:all; mso-fareast-language:EN-US;} span.z-BottomofFormChar {mso-style-name:"z-Bottom of Form Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"z-Bottom of Form"; mso-ansi-font-size:8.0pt; mso-bidi-font-size:8.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; display:none; mso-hide:all; mso-fareast-language:EN-US;} span.HeaderChar {mso-style-name:"Header Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Header; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; mso-fareast-language:EN-US;} span.FooterChar {mso-style-name:"Footer Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Footer; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:45.0pt 1.25in 45.0pt 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:220599352; mso-list-template-ids:175643050;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:360517441; mso-list-template-ids:-547978648;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:422805422; mso-list-template-ids:430180594;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l3 {mso-list-id:468985575; mso-list-template-ids:809385816;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l4 {mso-list-id:897518819; mso-list-template-ids:1072706306;} @list l4:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l5 {mso-list-id:912393563; mso-list-template-ids:944822970;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l6 {mso-list-id:1006588734; mso-list-template-ids:1938333658;} @list l6:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l7 {mso-list-id:1450011058; mso-list-template-ids:450297006;} @list l7:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l8 {mso-list-id:1463695539; mso-list-template-ids:-395512530;} @list l8:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l9 {mso-list-id:1638334759; mso-list-template-ids:-725287930;} @list l9:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l10 {mso-list-id:1726489686; mso-list-template-ids:998541424;} @list l10:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l11 {mso-list-id:2035770154; mso-list-template-ids:-124988370;} @list l11:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">What is an HTML File?<o:p></o:p></span></h2> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">HTML stands for <b>H</b>yper <b>T</b>ext <b>M</b>arkup <b>L</b>anguage <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">An HTML file is a text file containing small <b>markup tags</b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The markup tags tell the Web browser <b>how to display</b> the page <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">An HTML file must have an <b>htm</b> or <b>html</b> file extension <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">An HTML file can be created using a <b>simple text editor</b> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Do You Want to Try It?<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">If you are running Windows, start Notepad.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">If you are on a Mac start SimpleText.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">In OSX start TextEdit and change the following preferences: Select (in the preferences window) "Plain text" instead of "Rich text" and then select "Ignore rich text commands in HTML files". This is very important because if you don't do this HTML codes probably won't work.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Type in the following text:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><html><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><title>Title of page</title><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">This is my first homepage. <b>This text is bold</b><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></html><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">Save the file as "mypage.htm". <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Start your Internet browser. Select "Open" (or "Open Page") in the File menu of your browser. A dialog box will appear. Select "Browse" (or "Choose File") and locate the HTML file you just created - "mypage.htm" - select it and click "Open". Now you should see an address in the dialog box, for example "C:\MyDocuments\mypage.htm". Click OK, and the browser will display the page.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Example Explained<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The first tag in your HTML document is <html>. This tag tells your browser that this is the start of an HTML document. The last tag in your document is </html>. This tag tells your browser that this is the end of the HTML document.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The text between the <head> tag and the </head> tag is header information. Header information is not displayed in the browser window.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The text between the <title> tags is the title of your document. The title is displayed in your browser's caption.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The text between the <body> tags is the text that will be displayed in your browser.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The text between the <b> and </b> tags will be displayed in a bold font.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">HTM or HTML Extension?<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">When you save an HTML file, you can use either the .htm or the .html extension. We have used .htm in our examples. It might be a bad habit inhe<st1:personname st="on">rit</st1:personname>ed from the past when some of the commonly used software only allowed three letter extensions.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">With newer software we think it will be perfectly safe to use .html.<o:p></o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">HTML Tags<o:p></o:p></span></h2> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">HTML tags are used to mark-up HTML <b>elements</b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">HTML tags are surrounded by the <b>two characters <></b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The surrounding characters are called <b>angle brackets</b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">HTML tags normally <b>come in pairs</b> like <b> and </b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The first tag in a pair is the <b>start tag,</b> the second tag is the <b>end tag</b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The text between the start and end tags is the <b>element content</b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">HTML tags are <b>not case sensitive,</b> <b> means the same as <b> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">HTML Elements<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Remember the HTML example from the previous page:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><html><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><title>Title of page</title><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">This is my first homepage. <b>This text is bold</b><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></html><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">This is an HTML element:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><b>This text is bold</b><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The HTML element starts with a <b>start tag</b>: <b>
<br />The <b>content</b> of the HTML element is: This text is bold
<br />The HTML element ends with an <b>end tag</b>: </b><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The purpose of the <b> tag is to define an HTML element that should be displayed as bold.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This is also an HTML element:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">This is my first homepage. <b>This text is bold</b><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></body><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">This HTML element starts with the start tag <body>, and ends with the end tag </body>.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The purpose of the <body> tag is to define the HTML element that contains the body of the HTML document.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Why do We Use Lowercase Tags?<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">We have just said that HTML tags are not case sensitive: <b> means the same as <b>. When you surf the Web, you will notice that most tutorials use uppercase HTML tags in their examples. We always use lowercase tags. Why?<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">If you want to prepare yourself for the next generations of HTML, you should start using lowercase tags. The World Wide Web Consortium (W3C) recommends lowercase tags in their HTML 4 recommendation, and XHTML (the next generation HTML) demands lowercase tags.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Tag Attributes<o:p></o:p></span></h2> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Tags can have attributes<i>. </i>Attributes can provide additional information about the HTML elements on your page. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This tag defines the body element of your HTML page: <body>. With an added bgcolor attribute, you can tell the browser that the background color of your page should be red, like this: <body bgcolor="red">.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This tag defines an HTML table: <table>. With an added border attribute, you can tell the browser that the table should have no borders: <table border="0"><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Attributes always come in name/value pairs like this: name="value".<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Attributes are always added to the start tag of an HTML element.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Quote Styles, "red" or 'red'?<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Attribute values should always be enclosed in quotes. Double style quotes are the most common, but single style quotes are also allowed.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">In some rare situations, like when the attribute value itself contains quotes, it is necessary to use single quotes:<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">name='John "ShotGun" Nelson'<o:p></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">The most important tags in HTML are tags that define headings, paragraphs and line breaks.<o:p></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">The best way to learn HTML is to work with examples. We have created a very nice HTML editor for you. With this editor, you can edit the HTML source code if you like, and click on a test button to view the result.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Headings<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6> defines the smallest heading.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><h1>This is a heading</h1><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><h2>This is a heading</h2><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><h3>This is a heading</h3><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><h4>This is a heading</h4><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><h5>This is a heading</h5><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><h6>This is a heading</h6><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">HTML automatically adds an extra blank line before and after a heading.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Paragraphs<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Paragraphs are defined with the <p> tag.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p>This is a paragraph</p><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p>This is another paragraph</p><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">HTML automatically adds an extra blank line before and after a paragraph.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Line Breaks<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The <br /> tag is used when you want to end a line, but don't want to start a new paragraph. The <br /> tag forces a line break wherever you place it.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p>This <br /> is a para<br />graph with line breaks</p><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The <br /> tag is an empty tag. It has no closing tag.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Comments in HTML<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The comment tag is used to insert a comment in the HTML source code. A comment will be ignored by the browser. You can use comments to explain your code, which can help you when you edit the source code at a later date.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><!-- This is a comment --><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">Note that you need an exclamation point after the opening bracket, but not before the closing bracket.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Basic Notes - Useful Tips<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">When you w<st1:personname st="on">rit</st1:personname>e HTML text, you can never be sure how the text is displayed in another browser. Some people have large computer displays, some have small. The text will be reformatted every time the user resizes his window. Never try to format the text in your editor by adding empty lines and spaces to the text.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">HTML will truncate the spaces in your text. Any number of spaces count as one. Some extra information: In HTML a new line counts as one space. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Using empty paragraphs <p> to insert blank lines is a bad habit. Use the <br /> tag instead. (But don't use the <br /> tag to create lists. Wait until you have learned about HTML lists.)<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">You might have noticed that paragraphs can be w<st1:personname st="on">rit</st1:personname>ten without the closing tag </p>. Don't rely on it. The next version of HTML will not allow you to skip ANY closing tags.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">HTML automatically adds an extra blank line before and after some elements, like before and after a paragraph, and before and after a heading.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">We use a horizontal rule (the <hr /> tag), to separate the sections in our tutorials.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Basic HTML Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_html.asp"><html></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an HTML document<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_body.asp"><body></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the document's body<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_hn.asp"><h1> to <h6></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines header 1 to header 6<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_p.asp"><p></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a paragraph<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_br.asp"><br /></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Inserts a single line break<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_hr.asp"><hr /></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a horizontal rule<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_comment.asp"><!--></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a comment<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="intro"><span style="font-family: "Garamond","serif";">HTML defines a lot of elements for formatting output, like bold or italic text.<o:p></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">Below are a lot of examples that you can try out yourself:<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">How to View HTML Source<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Have you ever seen a Web page and wondered "How do they do that?"<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">To find out, simply click on the VIEW option in your browsers toolbar and select SOURCE or PAGE SOURCE. This will open a window that shows you the actual HTML of the page.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Text Formatting Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" width="20%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 80%;" width="80%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_font_style.asp"><b></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines bold text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_font_style.asp"><big></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines big text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><em></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines emphasized text <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_font_style.asp"><i></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines italic text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_font_style.asp"><small></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines small text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><strong></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines strong text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_sup.asp"><sub></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines subscripted text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_sup.asp"><sup></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines superscripted text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_ins.asp"><ins></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines inserted text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_del.asp"><del></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines deleted text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_strike.asp"><s></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <<st1:state st="on"><st1:place st="on">del</st1:place></st1:state>> instead<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_strike.asp"><strike></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <<st1:state st="on"><st1:place st="on">del</st1:place></st1:state>> instead<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_u.asp"><u></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use styles instead<o:p></o:p></span></p> </td> </tr> </tbody></table> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">"Computer Output" Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" width="20%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 80%;" width="80%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><code></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines computer code text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><kbd></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines keyboard text <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><samp></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines sample computer code<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_font_style.asp"><tt></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines teletype text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><var></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a variable<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_pre.asp"><pre></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines preformatted text<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><listing><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <pre> instead <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><plaintext><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <pre> instead<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><xmp><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <pre> instead<o:p></o:p></span></p> </td> </tr> </tbody></table> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Citations, Quotations, and Definition Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" width="20%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 80%;" width="80%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_abbr.asp"><abbr></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an abbreviation<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_acronym.asp"><acronym></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an acronym<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_address.asp"><address></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an address element<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_bdo.asp"><bdo></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the text direction<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_blockquote.asp"><blockquote></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a long quotation<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_q.asp"><q></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a short quotation<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><cite></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a citation<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_phrase_elements.asp"><dfn></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a definition term<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="intro"><span style="font-family: "Garamond","serif";">Some characters like the <></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">To display a less than sign (<) in HTML, we have to use a character entity.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Character Entities<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Some characters have a special meaning in HTML, like the less than sign (<) that defines the start of an HTML tag. If we want the browser to actually display these characters we must insert character entities in the HTML source.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">A character entity has three parts: an ampersand (&), an entity name or a # and an entity number, and finally a semicolon (;). <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">To display a less than sign in an HTML document we must w<st1:personname st="on">rit</st1:personname>e: <b><</b> or <b><</b> <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The advantage of using a name instead of a number is that a name is easier to remember. The disadvantage is that not all browsers support the newest entity names, while the support for entity numbers is very good in almost all browsers.<o:p></o:p></span></p> <p><b><span style="font-family: "Garamond","serif";">Note</span></b><span style="font-family: "Garamond","serif";"> that the entities are case sensitive. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This example lets you experiment with character entities: <a href="http://www.w3schools.com/html/tryit.asp?filename=tryhtml_entities" target="_blank">Character Entities</a><span class="ieonly"> IE only</span><o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Non-breaking Space<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The most common character entity in HTML is the non-breaking space.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Normally HTML will truncate spaces in your text. If you w<st1:personname st="on">rit</st1:personname>e 10 spaces in your text HTML will remove 9 of them. To add spaces to your text, use the character entity.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Most Common Character Entities:<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Result<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Entity Name<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Entity Number<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">non-breaking space<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><<o:p> </o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">less than<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">><o:p> </o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">greater than<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">&<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">ampersand<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">&<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">&<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">quotation mark<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">"<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">'<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">apostrophe <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">' (does not work in IE)<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">'<o:p></o:p></span></p> </td> </tr> </tbody></table> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Some Other Commonly Used Character Entities:<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Result<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Entity Name<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Entity Number<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">¢<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">cent<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">¢<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">¢<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">£<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">pound<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">£<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">£<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">¥<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">yen<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">¥<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">¥<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">§<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">section<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">§<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">§<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">©<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">copyright<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">©<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">©<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">®<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">registered trademark<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">®<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">®<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">×<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">multiplication<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">×<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">×<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">÷<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">division<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">÷<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">÷<o:p></o:p></span></p> </td> </tr> </tbody></table> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Anchor Tag and the Href Attribute<o:p></o:p></span></h2> <p><b><span style="font-family: "Garamond","serif";">HTML uses the <a> (anchor) tag to create a link to another document.</span></b><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The syntax of creating an anchor: <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><a href="url">Text to be displayed</a><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The <a> tag is used to create an anchor to link from, the href attribute is used to address the document to link to, and the words between the open and close of the anchor tag will be displayed as a hyperlink.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This anchor defines a link to W3Schools:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><a href="http://www.w3schools.com/">Visit W3Schools!</a><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The line above will look like this in a browser:<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Target Attribute<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">With the target attribute, you can define <b>where</b> the linked document will be opened.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The line below will open the document in a new browser window:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><a href="http://www.w3schools.com/"></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">target="_blank">Visit W3Schools!</a><o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Anchor Tag and the Name Attribute<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The name attribute is used to create a named anchor. When using named anchors we can create links that can jump directly into a specific section on a page, instead of letting the user scroll around to find what he/she is looking for.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Below is the syntax of a named anchor:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><a name="label">Text to be displayed</a><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The name attribute is used to create a named anchor. The name of the anchor can be any text you care to use.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The line below defines a named anchor:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><a name="tips">Useful Tips Section</a><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">You should notice that a named anchor is not displayed in a special way.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">To link directly to the "tips" section, add a # sign and the name of the anchor to the end of a URL, like this:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><a href="http://www.w3schools.com/html_links.asp#tips"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">Jump to the Useful Tips Section</a><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">A hyperlink to the Useful Tips Section from WITHIN the file "html_links.asp" will look like this: <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><a href="#tips">Jump to the Useful Tips Section</a><o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Basic Notes - Useful Tips<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Always add a trailing slash to subfolder references. If you link like this: href="http://www.w3schools.com/html", you will generate two HTTP requests to the server, because the server will add a slash to the address and create a new request like this: href="http://www.w3schools.com/html/" <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">If a browser cannot find a named anchor that has been specified, it goes to the top of the document. No error occurs. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Link Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_a.asp"><a></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an anchor<o:p></o:p></span></p> </td> </tr> </tbody></table> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Examples<o:p></o:p></span></h2> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Frames<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and each frame is independent of the others.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The disadvantages of using frames are:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The web developer must keep track of more HTML documents <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">It is difficult to print the entire page <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Frameset Tag<o:p></o:p></span></h2> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The <frameset> tag defines how to divide the window into frames <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Each frameset defines a set of rows <b>or</b> columns <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The values of the rows/columns indicate the amount of screen area each row/column will occupy <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Frame Tag<o:p></o:p></span></h2> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">The <frame> tag defines what HTML document to put into each frame <o:p></o:p></span></li></ul> <p><span style="font-family: "Garamond","serif";">In the example below we have a frameset with two columns. The first column is set to 25% of the width of the browser window. The second column is set to 75% of the width of the browser window. The HTML document "frame_a.htm" is put into the first column, and the HTML document "frame_b.htm" is put into the second column:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><frameset cols="25%,75%"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"> <frame src="frame_a.htm"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"> <frame src="frame_b.htm"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></frameset><o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Basic Notes - Useful Tips<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">If a frame has visible borders, the user can resize it by dragging the border. To prevent a user from doing this, you can add noresize="noresize" to the <frame> tag.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Add the <noframes> tag for browsers that do not support frames.<o:p></o:p></span></p> <p><b><span style="font-family: "Garamond","serif";">Important:</span></b><span style="font-family: "Garamond","serif";"> You cannot use the <body></body> tags together with the <frameset></frameset> tags! However, if you add a <noframes> tag containing some text for browsers that do not support frames, you will have to enclose the text in <body></body> tags! See how it is done in the first example below.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Frame Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_frameset.asp"><frameset></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a set of frames<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_frame.asp"><frame></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a sub window (a frame)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_noframes.asp"><noframes></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a noframe section for browsers that do not handle frames<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_iframe.asp"><iframe></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an inline sub window (frame)<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Tables<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). The letters td stands for "table data," which is the content of a data cell. A data cell can contain text, images, lists, paragraphs, forms, horizontal rules, tables, etc.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><table border="1"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 2</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 2, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 2, cell 2</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></table><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 2<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 2, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 2, cell 2<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Tables and the Border Attribute<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">If you do not specify a border attribute the table will be displayed without any borders. Sometimes this can be useful, but most of the time, you want the borders to show. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">To display a table with borders, you will have to use the border attribute:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><table border="1"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>Row 1, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>Row 1, cell 2</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></table><o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Headings in a Table<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Headings in a table are defined with the <th> tag.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><table border="1"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><th>Heading</th><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><th>Another Heading</th><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 2</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 2, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 2, cell 2</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></table><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-family: "Garamond","serif";">Heading<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-family: "Garamond","serif";">Another Heading<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 2<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 2, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 2, cell 2<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Empty Cells in a Table<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Table cells with no content are not displayed very well in most browsers.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><table border="1"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 2</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 2, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td></td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></table><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 2<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 2, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">Note that the borders around the empty table cell are missing (NB! Mozilla Firefox displays the border).<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">To avoid this, add a non-breaking space ( ) to empty data cells, to make the borders visible: <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><table border="1"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 1, cell 2</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td>row 2, cell 1</td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><td> </td><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></tr><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></table><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 1, cell 2<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">row 2, cell 1<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Basic Notes - Useful Tips<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The <thead>,<tbody> and <tfoot> elements are seldom used, because of bad browser support. Expect this to change in future versions of XHTML. If you have Internet Explorer 5.0 or newer, you can view a <a href="http://www.w3schools.com/xml/tryit.asp?filename=cd_catalog_island_thead" target="_blank">working example</a> in our XML tutorial.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Table Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_table.asp"><table></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_th.asp"><th></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table header<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_tr.asp"><tr></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table row<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_td.asp"><td></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table cell<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_caption.asp"><caption></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table caption<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_colgroup.asp"><colgroup></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines groups of table columns<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_col.asp"><col></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the attribute values for one or more columns in a table<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_thead.asp"><thead></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table head<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_tbody.asp"><tbody></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table body <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_tfoot.asp"><tfoot></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a table footer <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="intro"><span style="font-family: "Garamond","serif";">HTML supports ordered, unordered and definition lists.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Unordered Lists<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">An unordered list is a list of items. The list items are marked with bullets (typically small black circles).<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><ul><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><li>Coffee</li><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><li>Milk</li><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></ul><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">Here is how it looks in a browser:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Coffee <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Milk <o:p></o:p></span></li></ul> <p><span style="font-family: "Garamond","serif";">Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Ordered Lists<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">An ordered list is also a list of items. The list items are marked with numbers.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><ol><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><li>Coffee</li><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><li>Milk</li><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></ol><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">Here is how it looks in a browser:<o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Coffee <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Milk <o:p></o:p></span></li></ol> <p><span style="font-family: "Garamond","serif";">Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Definition Lists<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">A definition list is <b>not</b> a list of items. This is a list of terms and explanation of the terms.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">A definition list starts with the <dl> tag. Each definition-list term starts with the <dt> tag. Each definition-list definition starts with the <dd> tag.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><dl><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><dt>Coffee</dt><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><dd>Black hot drink</dd><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><dt>Milk</dt><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><dd>White cold drink</dd><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></dl><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">Here is how it looks in a browser:<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Coffee <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: "Garamond","serif";">Black hot drink <o:p></o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Milk <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: "Garamond","serif";">White cold drink <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Inside a definition-list definition (the <dd> tag) you can put paragraphs, line breaks, images, links, other lists, etc.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">List Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_ol.asp"><ol></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an ordered list<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_ul.asp"><ul></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an unordered list<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_li.asp"><li></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a list item<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_dl.asp"><dl></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a definition list<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_dt.asp"><dt></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a definition term<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_dd.asp"><dd></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a definition description<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_dir.asp"><dir></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <ul> instead<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_menu.asp"><menu></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <ul> instead<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Forms<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">A form is an area that can contain form elements.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Form elements are elements that allow the user to enter information (like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.) in a form.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">A form is defined with the <form> tag.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span><input><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span><input><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Input<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The most used form tag is the <input> tag. The type of input is specified with the type attribute. The most commonly used input types are explained below.<o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Text Fields<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">Text fields are used when you want the user to type letters, numbers, etc. in a form.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">First name: <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="text" name="firstname"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><br /><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">Last name: <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="text" name="lastname"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <form> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">First name: <input name="firstname" type="text">
<br />Last name: <input name="lastname" type="text"><o:p></o:p></span></p> </form> <p><span style="font-family: "Garamond","serif";">Note that the form itself is not visible. Also note that in most browsers, the width of the text field is 20 characters by default. <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Radio Buttons<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">Radio Buttons are used when you want the user to select one of a limited number of choices.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="radio" name="sex" value="male"> Male<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><br /><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="radio" name="sex" value="female"> Female<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <form> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><input name="sex" value="male" type="radio">Male
<br /><input name="sex" value="female" type="radio">Female <o:p></o:p></span></p> </form> <p><span style="font-family: "Garamond","serif";">Note that only one option can be chosen. <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Checkboxes <o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">Checkboxes are used when you want the user to select one or more options of a limited number of choices.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="checkbox" name="bike"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">I have a bike<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><br /><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="checkbox" name="car"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">I have a car<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <form> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><input name="bike" value="ON" type="checkbox">I have a bike
<br /><input name="car" value="ON" type="checkbox">I have a car <o:p></o:p></span></p> </form> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Form's Action Attribute and the Submit Button<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">When the user clicks on the "Submit" button, the content of the form is sent to another file. The form's action attribute defines the name of the file to send the content to. The file defined in the action attribute usually does something with the received input.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form name="input" action="html_form_action.asp"></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">method="get"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">Username: <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="text" name="user"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="submit" value="Submit"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">How it looks in a browser:<o:p></o:p></span></p> <form> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Username: <input name="user" type="text"><input action="html_form_action.asp" method="get" type="submit"><o:p></o:p></span></p> </form> <p><span style="font-family: "Garamond","serif";">If you type some characters in the text field above, and click the "Submit" button, you will send your input to a page called "html_form_action.asp". That page will show you the received input. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Form Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_form.asp"><form></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a form for user input<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_input.asp"><input></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an input field<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_textarea.asp"><textarea></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a text-area (a multi-line text input control)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_label.asp"><label></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a label to a control<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_fieldset.asp"><fieldset></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a fieldset<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_legend.asp"><legend></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a caption for a fieldset<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_select.asp"><select></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a selectable list (a drop-down box)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_optgroup.asp"><optgroup></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an option group<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_option.asp"><option></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an option in the drop-down box<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_button.asp"><button></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a push button<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><isindex><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <input> instead<o:p></o:p></span></p> </td> </tr> </tbody></table> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Image Tag and the Src Attribute <o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">In HTML, images are defined with the <img> tag. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <img> tag is empty, which means that it contains attributes only and it has no closing tag. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display on your page. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The syntax of defining an image:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><img src="url" /><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The URL points to the location where the image is stored. An image named "boat.gif" located in the directory "images" on "www.w3schools.com" has the URL: http://www.w3schools.com/images/boat.gif. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The browser puts the image where the image tag occurs in the document. If you put an image tag between two paragraphs, the browser shows the first paragraph, then the image, and then the second paragraph. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Alt Attribute <o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The alt attribute is used to define an "alternate text" for an image. The value of the alt attribute is an author-defined text: <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><img src="boat.gif" alt="Big Boat" /><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. The browser will then display the alternate text instead of the image. It is a good practice to include the "alt" attribute for each image on a page, to improve the display and usefulness of your document for people who have text-only browsers. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Basic Notes - Useful Tips<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">If an HTML file contains ten images - eleven files are required to display the page right. Loading images take time, so my best advice is: Use images carefully. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Image Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_img.asp"><img></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an image<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_map.asp"><map></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an image map<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_area.asp"><area></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a clickable area inside an image map<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="intro"><span style="font-family: "Garamond","serif";">A good background can make a Web site look really great.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Backgrounds<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The <body> tag has two attributes where you can specify backgrounds. The background can be a color or an image.<o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Bgcolor<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">The bgcolor attribute specifies a background-color for an HTML page. The value of this attribute can be a hexadecimal number, an RGB value, or a color name:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body bgcolor="#000000"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body bgcolor="rgb(0,0,0)"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body bgcolor="black"><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The lines above all set the background-color to black. <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Background<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">The background attribute specifies a background-image for an HTML page. The value of this attribute is the URL of the image you want to use. If the image is smaller than the browser window, the image will repeat itself until it fills the entire browser window.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body background="clouds.gif"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body background="http://www.w3schools.com/clouds.gif"><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The URL can be relative (as in the first line above) or absolute (as in the second line above).<o:p></o:p></span></p> <p><b><span style="font-family: "Garamond","serif";">Note: </span></b><span style="font-family: "Garamond","serif";">If you want to use a background image, you should keep in mind:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Will the background image increase the loading time too much? <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Will the background image look good with other images on the page? <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Will the background image look good with the text colors on the page? <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Will the background image look good when it is repeated on the page? <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Will the background image take away the focus from the text? <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Basic Notes - Useful Tips<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The bgcolor, background, and the text attributes in the <body> tag are deprecated in the latest versions of HTML (HTML 4 and XHTML). The World Wide Web Consortium (W3C) has removed these attributes from its recommendations.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Style sheets (CSS) should be used instead (to define the layout and display properties of HTML elements).<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Color Values<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Colors are defined using a hexadecimal notation for the combination of Red, Green, and Blue color values (RGB). The lowest value that can be given to one light source is 0 (hex #00). The highest value is 255 (hex #FF).<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This table shows the result of combining Red, Green, and Blue light sources:.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-family: "Garamond","serif";">Color<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-family: "Garamond","serif";">Color HEX<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-family: "Garamond","serif";">Color RGB<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: black none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#000000<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(0,0,0)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: red none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#FF0000<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(255,0,0)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: lime none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#00FF00<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(0,255,0)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: blue none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#0000FF<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(0,0,255)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#FFFF00<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(255,255,0)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: aqua none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#00FFFF<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(0,255,255)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: fuchsia none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#FF00FF<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(255,0,255)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#C0C0C0<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(192,192,192)<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#FFFFFF<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">rgb(255,255,255)<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Color Names<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">A collection of color names is supported by most browsers.<o:p></o:p></span></p> <p><b><span style="font-family: "Garamond","serif";">Note:</span></b><span style="font-family: "Garamond","serif";"> Only 16 <b>color names</b> are supported by the W3C HTML 4.0 standard (aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow). For all other colors you should use the <b>Color HEX</b> value.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Color<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Color HEX<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Color Name<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: aliceblue none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#F0F8FF<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">AliceBlue<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: antiquewhite none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#FAEBD7<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">AntiqueWhite<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: aquamarine none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#7FFFD4<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Aquamarine<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: black none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#000000<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Black<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: blue none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#0000FF<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Blue<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: blueviolet none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#8A2BE2<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">BlueViolet<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; background: brown none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">#A52A2A<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Brown<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Web Safe Colors<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">A few years ago, when most computers supported only 256 different colors, a list of 216 Web Safe Colors was suggested as a Web standard. The reason for this was that the Microsoft and Mac operating system used 40 different "reserved" fixed system colors (about 20 each). <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">We are not sure how important this is now, since more and more computers are equipped with the ability to display millions of different colors, but the choice is left to you. <o:p></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">Colors are displayed combining RED, GREEN, and BLUE light sources. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Color Values <o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">HTML colors are defined using a hexadecimal notation for the combination of Red, Green, and Blue color values (RGB). The lowest value that can be given to one of the light sources is 0 (hex #00). The highest value is 255 (hex #FF). <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">HTML Basic Document<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";"><html>
<br /><head>
<br /><title>Document name goes here</title>
<br /></head><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><body>
<br />Visible text goes here
<br /></body> <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"></html><o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Heading Elements<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><h1>Largest Heading</h1> <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><h2> . . . </h2>
<br /><h3> . . . </h3>
<br /><h4> . . . </h4>
<br /><h5> . . . </h5><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><h6>Smallest Heading</h6><o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Text Elements<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><p>This is a paragraph</p>
<br /><br /> (line break)
<br /><hr /> (horizontal rule)
<br /><pre>This text is preformatted</pre> <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Logical Styles<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><em>This text is emphasized</em>
<br /><strong>This text is strong</strong>
<br /><code>This is some computer code</code> <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Physical Styles<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><b>This text is bold</b>
<br /><i>This text is italic</i> <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Links, Anchors, and Image Elements<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.example.com/">This is a Link</a>
<br /><a href="http://www.example.com/"><img src="URL" alt="Alternate Text" /></a>
<br /><a href="mailto:webmaster@example.com">Send e-mail</a> <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">A named anchor:
<br /><a name="tips">Useful Tips Section</a>
<br /><a href="#tips">Jump to the Useful Tips Section</a><o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Unordered list<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><ul>
<br /><li>First item</li>
<br /><li>Next item</li>
<br /></ul> <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Ordered list<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><ol>
<br /><li>First item</li>
<br /><li>Next item</li>
<br /></ol> <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Definition list<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><dl>
<br /><dt>First term</dt>
<br /><dd>Definition</dd>
<br /><dt>Next term</dt>
<br /><dd>Definition</dd>
<br /></dl> <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Tables<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";"><table border="1">
<br /><tr>
<br /><th>someheader</th>
<br /><th>someheader</th>
<br /></tr>
<br /><tr>
<br /><td>sometext</td>
<br /><td>sometext</td>
<br /></tr>
<br /></table><o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Frames<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";"><frameset cols="25%,75%">
<br /> <frame src="page1.htm">
<br /> <frame src="page2.htm">
<br /></frameset><o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Forms<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><form action="http://www.example.com/test.asp" method="post/get"> <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><input type="text" name="lastname" value="Nixon" size="30" maxlength="50">
<br /><input type="password">
<br /><input type="checkbox" checked="checked">
<br /><input type="radio" checked="checked">
<br /><input type="submit">
<br /><input type="reset">
<br /><input type="hidden">
<br />
<br /><select>
<br /><option>Apples
<br /><option>Bananas
<br /><option>Cherries
<br /></select><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><textarea name="Comment" rows="60" cols="20"></textarea>
<br />
<br /></form><o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Entities<o:p></o:p></span></h3> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">< is the same as <
<br />> is the same as >
<br />© is the same as © <o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Other Elements<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";"><!-- This is a comment --><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><blockquote>
<br />Text quoted from some source.
<br /></blockquote><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><address>
<br />Address 1<br />
<br />Address 2<br />
<br />City<br />
<br /></address><o:p></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">Everywhere on the Web you will find pages that are formatted like newspaper pages using HTML columns.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">HTML Layout - Using Tables<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="0" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 5.25pt; width: 50%;" valign="top" width="50%"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">One very common practice with HTML, is to use HTML tables to format the layout of an HTML page. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">A part of this page is formatted with two columns, like a newspaper page.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">As you can see on this page, there is a left column and a right column.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This text is displayed in the left column.<o:p></o:p></span></p> </td> <td style="padding: 5.25pt; width: 50%;" valign="top" width="50%"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">An HTML <table> is used to divide a part of this Web page into two columns. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The trick is to use a table without borders, and maybe a little extra cell-padding.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">No matter how much text you add to this page, it will stay inside its column borders.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Same Layout - Color Added<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="0" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 5.25pt; width: 50%;" valign="top" width="50%"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">One very common practice with HTML, is to use HTML tables to format the layout of an HTML page. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">A part of this page is formatted with two columns, like a newspaper page.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">As you can see at this page, there is a left column and a right column.<o:p></o:p></span></p> </td> <td style="padding: 5.25pt; background: aqua none repeat scroll 0% 0%; width: 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" valign="top" width="50%"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">An HTML <table> is used to divide a part of this Web page into two columns. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">This text is displayed in the right column.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The trick is to use a table without borders, and maybe a little extra cell-padding.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">No matter how much text you add to this page, it will stay inside its column borders.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The HTML <span> Tag<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">With HTML code like this, you can specify both the size and the type of the browser output :<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style="font-family:Verdana;font-size:85%;"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">This is a paragraph.<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></span><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></p><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style="font-family:Times;font-size:100%;"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">This is another paragraph.<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></span><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></p><o:p></o:p></span></pre></td> </tr> </tbody></table> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Font Attributes<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Example<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Purpose<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">size="number"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">size="2"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the font size<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">size="+number"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">size="+1"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Increases the font size<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">size="-number"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">size="-1"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Decreases the font size<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">face="face-name"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">face="Times"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the font-name<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">color="color-value"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">color="#eeff00"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the font color<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">color="color-name"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">color="red"<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the font color<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <span> Tag Should NOT be Used<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The <span> tag is deprecated in the latest versions of HTML (HTML 4 and XHTML).<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The World Wide Web Consortium (W3C) has removed the <span> tag from its recommendations. In future versions of HTML, style sheets (CSS) will be used to define the layout and display properties of HTML elements. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">How to Use Styles<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">When a browser reads a style sheet, it will format the document according to it. There are three ways of inserting a style sheet:<o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">External Style Sheet<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><link rel="stylesheet" type="text/css"></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">href="mystyle.css"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre></td> </tr> </tbody></table> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Internal Style Sheet<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section with the <style> tag.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><style type="text/css"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">body {background-color: red}<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">p {margin-left: 20px}<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></style><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre></td> </tr> </tbody></table> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Inline Styles<o:p></o:p></span></h3> <p><span style="font-family: "Garamond","serif";">An inline style should be used when a unique style is to be applied to a single occurrence of an element.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p style="color: red; margin-left: 20px"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">This is a paragraph<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></p><o:p></o:p></span></pre></td> </tr> </tbody></table> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Style Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_style.asp"><style></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a style definition<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_link.asp"><link></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a resource reference<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_div.asp"><div></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a section in a document<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_span.asp"><span></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a section in a document<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_font.asp"><span></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use styles instead<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_basefont.asp"><basefont></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use styles instead <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_center.asp"><center></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use styles instead<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The Head Element <o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The head element contains general information, also called meta-information, about a document. <st1:place st="on">Meta</st1:place> means "information about". <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">You can say that meta-data means information about data, or meta-information means information about information. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Information Inside the Head Element <o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The elements inside the head element should not be displayed by a browser. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">According to the HTML standard, only a few tags are legal inside the head section. These are: <base>, <link>, <meta>, <title>, <style>, and <script>. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Look at the following illegal construct: <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span><p>This is some text</p><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">In this case the browser has two options:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Display the text because it is inside a paragraph element <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Hide the text because it is inside a head element <o:p></o:p></span></li></ul> <p><span style="font-family: "Garamond","serif";">If you put an HTML element like <h1> or <p> inside a head element like this, most browsers will display it, even if it is illegal.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Should browsers forgive you for errors like this? We don't think so. Others do.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Head Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 80%;" valign="top" width="80%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_head.asp"><head></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines information about the document<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_title.asp"><title></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the document title<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_base.asp"><base></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a base URL for all the links on a page<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_link.asp"><link></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a resource reference<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_meta.asp"><meta></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines meta information<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_doctype.asp"><!DOCTYPE></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines the document type. This tag goes before the <html> start tag.<o:p></o:p></span></p> </td> </tr> </tbody></table> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <st1:place st="on">Meta</st1:place> Element <o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">As we explained in the previous chapter, the head element contains general information (meta-information) about a document. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">HTML also includes a meta element that goes inside the head element. The purpose of the meta element is to provide meta-information about the document. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Most often the meta element is used to provide information that is relevant to browsers or.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Keywords for Search Engines<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Some search engines on the WWW will use the name and content attributes of the meta tag to index your pages.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">This meta element defines a description of your page: </span></b><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><meta name="description" content="Free Web tutorials on HTML, CSS, XML, and XHTML"><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">This meta element defines keywords for your page:</span></b><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><meta name="keywords" content="HTML, DHTML, CSS, XML, XHTML, JavaScript, VBScript"><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The intention of the name and content attributes is to describe the content of a page. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">However, since too many webmasters have used meta tags for spamming, like repeating keywords to give pages a higher ranking, some search engines have stopped using them entirely. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Unknown <st1:place st="on">Meta</st1:place> Attributes<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Sometimes you will see meta attributes that are unknown to you like this:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><meta name="secu<st1:personname w:st=">rit</st1:personname>y" content="low"> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">Then you just have to accept that this is something unique to the site or to the author of the site, and that it has probably no relevance to you. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">You can see a complete list of the meta element attributes in our
<br /><span style=""> </span><o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">HTML Links<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">When you click on a link in an HTML document like this: <a href="http://www.w3schools.com/html/lastpage.htm" target="_blank">Last Page</a>, an underlying <a> tag points to a place (an address) on the Web with an href attribute value like this: <a href="lastpage.htm">Last Page</a>.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The Last Page link in the example is a link that is relative to the Web site that you are browsing, and your browser will construct a full Web address like <a href="http://www.w3schools.com/html/lastpage.htm" target="_blank">http://www.w3schools.com/html/lastpage.htm</a> to access the page.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Uniform Resource Locators<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Something called a Uniform Resource Locator (URL) is used to address a document (or other data) on the World Wide Web. A full Web address like this: <a href="http://www.w3schools.com/html/lastpage.htm" target="_blank">http://www.w3schools.com/html/lastpage.htm</a> follows these syntax rules:<o:p></o:p></span></p> <p><b><span style="font-family: "Garamond","serif";">scheme</span></b><tt><b><span style="font-size: 10pt; font-family: "Garamond","serif";">://</span></b></tt><b><span style="font-family: "Garamond","serif";">host.domain</span></b><tt><b><span style="font-size: 10pt; font-family: "Garamond","serif";">:</span></b></tt><b><span style="font-family: "Garamond","serif";">port</span></b><tt><b><span style="font-size: 10pt; font-family: "Garamond","serif";">/</span></b></tt><b><span style="font-family: "Garamond","serif";">path</span></b><tt><b><span style="font-size: 10pt; font-family: "Garamond","serif";">/</span></b></tt><b><span style="font-family: "Garamond","serif";">filename</span></b><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">The <b>scheme</b> is defining the <b>type</b> of Internet service. The most common type is <b>http</b>. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <b>domain</b> is defining the Internet <b>domain name</b> like w3schools.com.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <b>host</b> is defining the domain host. If omitted, the default host for http is <b>www</b>.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <b>:port</b> is defining the <b>port number </b>at the host. The port number is normally omitted. The default port number for http is <b>80</b>. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <b>path</b> is defining a <b>path</b> (a sub directory) at the server. If the path is omitted, the resource (the document) must be located at the root directory of the Web site.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <b>filename</b> is defining the name of a document. The default filename might be default.asp, or index.html or something else depending on the settings of the Web server.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">URL Schemes<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Some examples of the most common schemes can be found below:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Schemes<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Access<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">file<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">a file on your local PC<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">ftp<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">a file on an FTP server<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">http<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">a file on a World Wide Web Server<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">gopher<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">a file on a Gopher server<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">news<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">a Usenet newsgroup<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">telnet<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">a Telnet connection<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">WAIS<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">a file on a WAIS server<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Accessing a Newsgroup<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The following HTML code:<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><a href="news:alt.html">HTML Newsgroup</a><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">creates a link to a newsgroup like this <a href="news:alt.html">HTML Newsgroup</a>.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Downloading with FTP<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The following HTML code:<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><a href="ftp://www.w3schools.com/ftp/winzip.exe">Download WinZip</a><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">creates a link to download a file like this: <a href="ftp://www.w3schools.com/ftp/winzip.exe" target="_blank">Download WinZip</a>.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">(The link doesn't work. Don't try it. It is just an example. W3Schools doesn't really have an ftp directory.)<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Link to your Mail system<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The following HTML code:<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><a href="mailto:someone@w3schools.com">someone@w3schools.com</a><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">creates a link to your own mail system like this:<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><a href="mailto:someone@w3schools.com">someone@w3schools.com</a><o:p></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">Add scripts to HTML pages to make them more dynamic and interactive.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Insert a Script into HTML Page<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">A script in HTML is defined with the <script> tag. Note that you will have to use the type attribute to specify the scripting language.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><html><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><script type="text/javascript"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">document.w<st1:personname st="on">rit</st1:personname>e("Hello World!")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></script><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></html><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The script above will produce this output:<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Hello World!<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">How to Handle Older Browsers<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">A browser that does not recognize the <script> tag at all, will display the <script> tag's content as text on the page. To prevent the browser from doing this, you should hide the script in comment tags. An old browser (that does not recognize the <script> tag) will ignore the comment and it will not w<st1:personname st="on">rit</st1:personname>e the tag's content on the page, while a new browser will understand that the script should be executed, even if it is surrounded by comment tags.<o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Example<o:p></o:p></span></h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">JavaScript:</span></b><span style="font-family: "Garamond","serif";">
<br /> <script type="text/javascript">
<br /> <!--
<br /> document.w<st1:personname st="on">rit</st1:personname>e("Hello World!")
<br /> //-->
<br /> </script> <o:p></o:p></span></p> <p><b><span style="font-family: "Garamond","serif";">VBScript:
<br /> </span></b><span style="font-family: "Garamond","serif";"><script type="text/vbscript">
<br /> <!--
<br /> document.w<st1:personname st="on">rit</st1:personname>e("Hello World!")
<br /> '-->
<br /> </script><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <noscript> Tag<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">In addition to hiding the script inside a comment, you can also add a <noscript> tag.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <noscript> tag is used to define an alternate text if a script is NOT executed. This tag is used for browsers that recognize the <script> tag, but do not support the script inside, so these browsers will display the text inside the <noscript> tag instead. However, if a browser supports the script inside the <script> tag it will ignore the <noscript> tag.<o:p></o:p></span></p> <h3><span style="font-size: 12pt; font-family: "Garamond","serif";">Example<o:p></o:p></span></h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">JavaScript:</span></b><span style="font-family: "Garamond","serif";">
<br /> <script type="text/javascript">
<br /> <!--
<br /> document.w<st1:personname st="on">rit</st1:personname>e("Hello World!")
<br /> //-->
<br /> </script>
<br /> <noscript>Your browser does not support JavaScript!</noscript> <o:p></o:p></span></p> <p><b><span style="font-family: "Garamond","serif";">VBScript:
<br /> </span></b><span style="font-family: "Garamond","serif";"><script type="text/vbscript">
<br /> <!--
<br /> document.w<st1:personname st="on">rit</st1:personname>e("Hello World!")
<br /> '-->
<br /> </script>
<br /> <noscript>Your browser does not support VBScript!</noscript><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Script Tags<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Tag<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_script.asp"><script></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines a script<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_noscript.asp"><noscript></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an alternate text if the script is not executed<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_object.asp"><object></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines an embedded object<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_param.asp"><param></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Defines run-time settings (parameters) for an object<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><a href="http://www.w3schools.com/tags/tag_applet.asp"><applet></a><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Deprecated. Use <object> instead<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p><span style="font-family: "Garamond","serif";">HTML tags can have attributes. The special attributes for each tag are listed under each tag description. The attributes listed here are the core and language attributes that are standard for all tags (with a few exceptions):<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Core Attributes<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Not valid in base, head, html, meta, param, script, style, and title elements.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Value<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 45%;" valign="top" width="45%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">class<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">class_rule </span></i><span style="font-family: "Garamond","serif";">or<i> style_rule</i><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">The class of the element<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">id<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">id_name</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">A unique id for the element<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">style<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">style_definition</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">An inline style definition <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">title<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">tooltip_text </span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">A text to display in a tool tip <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Language Attributes<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Not valid in base, br, frame, frameset, hr, iframe, param, and script elements.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Value<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 45%;" valign="top" width="45%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">dir<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">ltr | rtl<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Sets the text direction<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">lang<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">language_code</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Sets the language code<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Keyboard Attributes<o:p></o:p></span></h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Value<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 45%;" valign="top" width="45%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">accesskey<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">character</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Sets a keyboard shortcut to access an element <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">tabindex<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">number</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Sets the tab order of an element <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p><span style="font-family: "Garamond","serif";">New to HTML 4.0 is the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of attributes that can be inserted into HTML tags to define event actions.<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Window Events<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Only valid in body and frameset elements.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Value<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onload<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when a document loads <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onunload<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when a document unloads <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Form Element Events<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Only valid in form elements.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Value<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onchange<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when the element changes <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onsubmit<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when the form is submitted <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onreset<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when the form is reset <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onselect<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script </span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when the element is selected <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onblur<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script </span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when the element loses focus <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onfocus<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script </span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Script to be run when the element gets focus<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Keyboard Events<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Value<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onkeydown<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when key is pressed<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onkeypress<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when key is pressed and released<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onkeyup<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when key is released<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Mouse Events<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title elements.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Attribute<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Value<o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onclick<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do on a mouse click <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">ondblclick<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do on a mouse double-click <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onmousedown<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when mouse button is pressed <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onmousemove<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when mouse pointer moves <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onmouseout<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when mouse pointer moves out of an element <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onmouseover<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when mouse pointer moves over an element <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">onmouseup<o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i><span style="font-family: "Garamond","serif";">script</span></i><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">What to do when mouse button is released <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="intro"><span style="font-family: "Garamond","serif";">Below is a reference of ASCII characters in URL-encoding form (hexadecimal format).<o:p></o:p></span></p> <p class="intro"><span style="font-family: "Garamond","serif";">Hexadecimal values can be used to display non-standard letters and characters in browsers and plug-ins.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Try It<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Type some text or an ASCII value in the input field below, and click on the "URL Encode" button to see the URL-encoding.<o:p></o:p></span></p> <form> <p><span style="font-family: "Garamond","serif";"><textarea rows="7" cols="50" name="txt">This is a text </textarea><o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><input action="html_urlresult.asp" value="URL Encode" method="post" name="submit" type="submit"><o:p></o:p></span></p> </form> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Your First Step: A Personal Web Server<o:p></o:p></span></h2> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">If you want other people to view your pages, you must publish them. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">To publish your work, you have to copy your files to a web server. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Your own PC can act as a web server if it is connected to a network. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">If you are running Windows 98, you can use the PWS (Personal Web Server). <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">PWS is hiding in the PWS folder in your Windows CD. <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Personal Web Server (PWS)<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">PWS turns any Windows computer into a Web server. PWS is easy to install and ideal for developing and testing Web applications. PWS has been optimized for workstation use, but has all the requirements of a full Web server. It also runs Active Server Pages (ASP) just like its larger brother IIS. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">How to Install a Personal Web Server (PWS):<o:p></o:p></span></h2> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Browse your Windows installation to see if you have installed PWS. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">If not, install PWS from the PWS directory on your Windows CD. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Follow the instructions and get your Personal Web Server up and running. <o:p></o:p></span></li></ul> <p><b><span style="font-family: "Garamond","serif";">Note:</span></b><span style="font-family: "Garamond","serif";"> Microsoft Windows XP Home Edition does not come with the option to turn your computer into a PWS!<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Internet Information Server (IIS)<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Windows 2000's built-in Web server IIS, makes it easy to build large applications for the Web. Both PWS and IIS include ASP, a server-side scripting standard that can be used to create dynamic and interactive Web applications. IIS is also available for Windows NT. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Your Next Step: A Professional Web Server <o:p></o:p></span></h2> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">If you do not want to use PWS or IIS, you must upload your files to a public server. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Most Internet Service Providers (ISP's) will offer to host your web pages. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">If your employer has an Internet Server, you can ask him to host your Web site. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">If you are really serious about this, you should install your own Internet Server. <o:p></o:p></span></li></ul> <p><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">HTML Summary<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">This tutorial has taught you how to use HTML to create your own web site.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">HTML is the universal markup language for the Web. HTML lets you format text, add graphics, create links, input forms, frames and tables, etc., and save it all in a text file that any browser can read and display.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The key to HTML is the tags, which indicates what content is coming up.<o:p></o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-53845588706819071092009-01-02T02:40:00.000-08:002009-01-02T02:41:58.117-08:00Ajax Tutorial<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="HTML Top of Form"> <w:lsdexception locked="false" priority="0" name="HTML Bottom of Form"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Garamond; panose-1:2 2 4 4 3 3 1 1 8 3; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h2 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 2 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:2; font-size:18.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading2Char {mso-style-name:"Heading 2 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 2"; mso-ansi-font-size:18.0pt; mso-bidi-font-size:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} p.intro, li.intro, div.intro {mso-style-name:intro; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.z-TopofFormChar {mso-style-name:"z-Top of Form Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"z-Top of Form"; mso-ansi-font-size:8.0pt; mso-bidi-font-size:8.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; display:none; mso-hide:all; mso-fareast-language:EN-US;} span.z-BottomofFormChar {mso-style-name:"z-Bottom of Form Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"z-Bottom of Form"; mso-ansi-font-size:8.0pt; mso-bidi-font-size:8.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; display:none; mso-hide:all; mso-fareast-language:EN-US;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:.5in 1.0in 27.0pt 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:204292755; mso-list-template-ids:-622681592;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:832716339; mso-list-template-ids:-1213409636;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:1408922404; mso-list-template-ids:231760706;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <div class="MsoNormal" style="text-align: center;" align="center"><p><st1:city st="on"><st1:place st="on"><b><span style="font-family: "Garamond","serif";">AJAX</span></b></st1:place></st1:city><b><span style="font-family: "Garamond","serif";"> Keywords:<o:p></o:p></span></b></p> <ul type="disc"><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">JavaScript and XML <o:p></o:p></span></b></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">Web browser technology <o:p></o:p></span></b></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">Open web standards <o:p></o:p></span></b></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">Browser and platform independent <o:p></o:p></span></b></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">Better and faster Internet applications <o:p></o:p></span></b></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">XML and HTTP Requests </span></b></li></ul><span style="font-family: "Garamond","serif";"><hr align="center" size="2" width="100%"> </span></div>
<br /><h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> = Asynchronous JavaScript And XML<o:p></o:p></span></h2> <p><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> is an acronym for <b>A</b>synchronous <b>J</b>avaScript <b>A</b>nd <b>X</b>ML. <o:p></o:p></span></p> <p><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> is not a programming language, but simply a development technique for creating interactive web applications.<o:p></o:p></span></p> <p><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> uses JavaScript to send and receive data between a web browser and a web server.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> technique makes web pages more responsive by exchanging data with a server behind the scenes, instead of reloading an entire web page each time a user makes a change.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">With <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city>, web applications can be faster, more interactive, and more user friendly.<o:p></o:p></span></p> <p><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> uses an XMLHTTPRequest object to send data to a web server, and XML is commonly used as the format for receiving server data, although any format, including plain text, can be used.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Is A Browser Technology<o:p></o:p></span></h2> <p><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> is a technology that runs in your browser. It uses asynchronous data transfer between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The technology makes Internet applications smaller, faster and more user friendly.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1035" type="#_x0000_t75" alt="lamp" style="'width:11.25pt;height:11.25pt'/"><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.gif" alt="lamp" shapes="_x0000_i1035" width="15" height="15" /><!--[endif]--> <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> is a web browser technology independent of web server software. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Is Based On Open Standards<o:p></o:p></span></h2> <p><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> is based on the following open standards:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">JavaScript</span></b><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">XML</span></b><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">HTML</span></b><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-family: "Garamond","serif";">CSS</span></b><span style="font-family: "Garamond","serif";"> <o:p></o:p></span></li></ul> <p><span style="font-family: "Garamond","serif";">The open standards used in <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> are well defined, and supported by all major browsers. <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> applications are browser and platform independent. (Cross-Platform, Cross-Browser technology)<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Is About Better Internet Applications<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">Web applications have many benefits over desktop applications, they can reach a larger audience, they are easier to install and support, and easier to develop.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">However, Internet applications are not always as "rich" and user-friendly as traditional desktop applications. <o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">With <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city>, Internet applications can be made richer (smaller, faster, and easier to use).<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">You Can Start Using <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> Today<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">There is nothing new to learn.<o:p></o:p></span></p> <p><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> is based on open standards. These standards have been used by most developers for several years.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Most existing web applications can be rewritten to use <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> technology instead of traditional HTML forms.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Uses XML And HTTP Requests<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">A traditional web application will submit input (using an HTML form) to a web server. After the web server has processed the data, it will return a completely new web page to the user.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">Because the server returns a new web page each time the user submits input, traditional web applications often run slowly and tend to be less user friendly.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">With <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city>, web applications can send and retrieve data without reloading the whole web page. This is done by sending HTTP Requests to the server, and by modifying only parts of the web page using JavaScript.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The preferred way to communicate with the server is by sending data as XML (but other methods can be used).<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">You will learn more about how this is done in the next chapters of this tutorial.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="intro"><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> can be used to create more interactive applications. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Example<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">In the <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> example below we will demonstrate how a web page can communicate with a web server online as a user enters data into a web form. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Type a Name in the Box Below<o:p></o:p></span></h2> <form> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">First Name: <input type="text"><o:p></o:p></span></p> </form> <p><span style="font-family: "Garamond","serif";">Suggestions: <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Example Explained - The HTML Form<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The form above has the following HTML code:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form> <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">First Name:<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="text" id="txt1"></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">onkeyup="showHint(this.value)"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p>Suggestions: <span id="txtHint"></span></p> <o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">As you can see it is just a simple HTML form with an input field called "txt1".<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The paragraph below the form contains a span called "txtHint". The span is used as a placeholder for hints retrieved from the web server.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">When the user inputs data, a function called "showHint()" is executed. The execution of the function is triggered by the "onkeyup" event. In other words: Each time the user moves his finger away from a keyboard key inside the txt1 field, the function showHint is called.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Example Explained - The showHint() Function<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The showHint() function is a very simple JavaScript function placed in the <head> section of the HTML page.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The function contains the following code:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function showHint(str)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (str.length > 0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var url="gethint.asp?sid="+Math.random()+"&q="+str<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp=GetXmlHttpObject(stateChanged) <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp.open("GET", url , true) <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp.send(null) <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">else<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">document.getElementById("txtHint").innerHTML="" <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">}<o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The function executes every time a character is entered in the input field.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">If there is some input in the text field (str.length > 0) the function executes the following:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Creates an XMLHTTP object <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Sends an HTTP request to the file "gethint.asp" on the server <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-family: "Garamond","serif";">Tells the XMLHTTP object to execute the stateChanged() function when the HTTP triggers a change. <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Example Explained - The stateChanged() Function<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The stateChanged() function contains the following code:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function stateChanged() <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">document.getElementById("txtHint").innerHTML=xmlHttp.responseText <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The stateChanged() function executes every time the state of the XMLHTTP object changes.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">When the state changes to 4 (or to "complete"), the content of the txtHint span is filled with the response text. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Example - <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> Source<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The source code below belongs to the <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> example on the previous page.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">You can copy and paste it, and try it yourself.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> HTML Page<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">This is the HTML page. It contains a simple HTML form and a link to a JavaScript.<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><html><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><script src="clienthint.js"></script> <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form> <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">First Name:<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><input type="text" id="txt1"></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">onkeyup="showHint(this.value)"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p>Suggestions: <span id="txtHint"></span></p> <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></html><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">The JavaScript code is listed below.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> JavaScript<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">This is the JavaScript code, stored in the file "clienthint.js":<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var xmlHttp<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function showHint(str)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (str.length > 0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var url="gethint.asp?sid=" + Math.random() + "&q=" + str<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp=GetXmlHttpObject(stateChanged)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp.open("GET", url , true)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp.send(null)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">else<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">document.getElementById("txtHint").innerHTML=""<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function stateChanged() <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">document.getElementById("txtHint").innerHTML=xmlHttp.responseText <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function GetXmlHttpObject(handler)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var objXmlHttp=null<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.userAgent.indexOf("Opera")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">alert("This example doesn't work in Opera") <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">}<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.userAgent.indexOf("MSIE")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var strName="Msxml2.XMLHTTP"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.appVersion.indexOf("MSIE 5.5")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">strName="Microsoft.XMLHTTP"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">try<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp=new ActiveXObject(strName)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp.onreadystatechange=handler <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return objXmlHttp<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">catch(e)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">alert("Error. Scripting for ActiveX might be disabled") <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.userAgent.indexOf("Mozilla")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp=new XMLHttpRequest()<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp.onload=handler<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp.onerror=handler <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return objXmlHttp<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">}<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> Server Page<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The server page called by the JavaScript, is a simple ASP file called "gethint.asp".<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The page is written in VBScript for an Internet Information Server (IIS). It could easily be rewritten in PHP, or some other server language.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">It just checks an array of names and returns the corresponding names to the client:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><%<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">dim a(30)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(1)="Anna"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(2)="<st1:state st="on"><st1:place st="on">Brittany</st1:place></st1:state>"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(3)="Cinderella"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(4)="Diana"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(5)="Eva"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(6)="Fiona"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(7)="Gunda"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(8)="Hege"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(9)="Inga"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(10)="Johanna"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(11)="Kitty"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(12)="Linda"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(13)="Nina"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(14)="Ophelia"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(15)="Petunia"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(16)="Amanda"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(17)="Raquel"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(18)="Cindy"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(19)="<st1:place st="on">Doris</st1:place>"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(20)="Eve"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(21)="Evita"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(22)="Sunniva"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(23)="Tove"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(24)="Unni"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(25)="Violet"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(26)="Liza"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(27)="<st1:city st="on"><st1:place st="on">Elizabeth</st1:place></st1:city>"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(28)="Ellen"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(29)="Wenche"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">a(30)="Vicky"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">q=ucase(request.querystring("q"))<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if len(q)>0 then<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>hint=""<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>for i=1 to 30<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>if q=ucase(mid(a(i),1,len(q))) then<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>if hint="" then<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>hint=a(i)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>else<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>hint=hint & " , " & a(i)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>end if<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>end if<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>next<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">end if <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if hint="" then <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>response.write("no suggestion")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">else<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><span style=""> </span>response.write(hint)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">end if<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">%><o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="intro"><st1:city st="on"><st1:place st="on"><span style="font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-family: "Garamond","serif";"> can be used for interactive communication with a database.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Database Example<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">In the <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> example below we will demonstrate how a web page can fetch information from a database using <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> technology.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">Select a Name in the Box Below<o:p></o:p></span></h2> <form> <p class="MsoNormal"><span style="font-family: "Garamond","serif";">Select a Customer: <select name="customers"> <option selected="selected" value="ALFKI">Alfreds Futterkiste </option><option value="NORTS ">North/South </option><option value="WOLZA">Wolski Zajazd </option></select><o:p></o:p></span></p> </form> <p class="MsoNormal"><b><span style="font-family: "Garamond","serif";">Customer info will be listed here.</span></b><span style="font-family: "Garamond","serif";"><o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><st1:city st="on"><st1:place st="on"><span style="font-size: 12pt; font-family: "Garamond","serif";">AJAX</span></st1:place></st1:city><span style="font-size: 12pt; font-family: "Garamond","serif";"> Example Explained<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The example above contains a simple HTML form and a link to a JavaScript:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><html><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><script src="selectcustomer.js"></script><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></head><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><form> <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">Select a Customer:<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><select name="customers" onchange="showCustomer(this.value)"><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><option value="ALFKI">Alfreds Futterkiste<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><option value="NORTS ">North/South<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><option value="WOLZA">Wolski Zajazd <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></select><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></form><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><p><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><div id="txtHint"><b>Customer info will be listed here.</b></div><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></p><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></body><o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"></html><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-family: "Garamond","serif";">As you can see it is just a simple HTML form with a drop down box called "customers".<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The paragraph below the form contains a div called "txtHint". The div is used as a placeholder for info retrieved from the web server.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">When the user selects data, a function called "showCustomer()" is executed. The execution of the function is triggered by the "onchange" event. In other words: Each time the user change the value in the drop down box, the function showCustomer is called.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The JavaScript code is listed below.<o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> JavaScript<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">This is the JavaScript code stored in the file "selectcustomer.js":<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var xmlHttp<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function showCustomer(str)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var url="getcustomer.asp?sid=" + Math.random() + "&q=" + str<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp=GetXmlHttpObject(stateChanged)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp.open("GET", url , true)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">xmlHttp.send(null)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function stateChanged() <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">document.getElementById("txtHint").innerHTML=xmlHttp.responseText <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">function GetXmlHttpObject(handler)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var objXmlHttp=null<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.userAgent.indexOf("Opera")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">alert("This example doesn't work in Opera") <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">}<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.userAgent.indexOf("MSIE")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">var strName="Msxml2.XMLHTTP"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.appVersion.indexOf("MSIE 5.5")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">strName="Microsoft.XMLHTTP"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">try<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp=new ActiveXObject(strName)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp.onreadystatechange=handler <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return objXmlHttp<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">catch(e)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{ <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">alert("Error. Scripting for ActiveX might be disabled") <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">if (navigator.userAgent.indexOf("Mozilla")>=0)<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">{<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp=new XMLHttpRequest()<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp.onload=handler<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">objXmlHttp.onerror=handler <o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">return objXmlHttp<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">}<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">} <o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 12pt; font-family: "Garamond","serif";">The <st1:city st="on"><st1:place st="on">AJAX</st1:place></st1:city> Server Page<o:p></o:p></span></h2> <p><span style="font-family: "Garamond","serif";">The server paged called by the JavaScript, is a simple ASP file called "getcustomer.asp".<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The page is written in VBScript for an Internet Information Server (IIS). It could easily be rewritten in PHP, or some other server language.<o:p></o:p></span></p> <p><span style="font-family: "Garamond","serif";">The code runs an SQL against a database and returns the result as an HTML table:<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">sql=sql & request.querystring("q")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">set conn=Server.CreateObject("ADODB.Connection")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">conn.Provider="Microsoft.Jet.OLEDB.4.0"<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">conn.Open(Server.Mappath("/db/northwind.mdb"))<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">set rs = Server.CreateObject("ADODB.recordset")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">rs.Open sql, conn<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">response.write("<table>")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">do until rs.EOF<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">for each x in rs.Fields<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">response.write("<tr><td><b>" & x.name & "</b></td>")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">response.write("<td>" & x.value & "</td></tr>")<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">next<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">rs.MoveNext<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">loop<o:p></o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";"><o:p> </o:p></span></pre><pre><span style="font-size: 12pt; font-family: "Garamond","serif";">response.write("</table>")<o:p></o:p></span></pre></td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-family: "Garamond","serif";"> <hr align="center" size="2" width="100%"> </span></div> <p class="MsoNormal"><span style="font-family: "Garamond","serif";"><o:p> </o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-25050094211651170252009-01-02T02:37:00.000-08:002009-01-02T02:40:04.673-08:00ASP Tutorial<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="Street"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="country-region"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="time"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="address"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="date"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h1 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 1 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:1; font-size:16.0pt; font-family:"Arial","sans-serif"; mso-font-kerning:16.0pt; mso-fareast-language:EN-US; font-weight:bold;} h2 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 2 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:2; font-size:18.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} h3 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 3 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:3; font-size:13.0pt; font-family:"Arial","sans-serif"; mso-fareast-language:EN-US; font-weight:bold;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 1"; mso-ansi-font-size:16.0pt; mso-bidi-font-size:16.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-font-kerning:16.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.Heading2Char {mso-style-name:"Heading 2 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 2"; mso-ansi-font-size:18.0pt; mso-bidi-font-size:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.Heading3Char {mso-style-name:"Heading 3 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 3"; mso-ansi-font-size:13.0pt; mso-bidi-font-size:13.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-fareast-language:EN-US; font-weight:bold;} p.intro, li.intro, div.intro {mso-style-name:intro; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} span.red {mso-style-name:red; mso-style-unhide:no;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:75370038; mso-list-template-ids:-1103483978;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:147208553; mso-list-template-ids:-2138927024;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:156462685; mso-list-template-ids:-2120432068;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l3 {mso-list-id:183176155; mso-list-template-ids:674774620;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l4 {mso-list-id:270403408; mso-list-template-ids:2028766528;} @list l4:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l5 {mso-list-id:465010418; mso-list-template-ids:-1738916518;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l6 {mso-list-id:479003211; mso-list-template-ids:1145083916;} @list l6:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l7 {mso-list-id:582909584; mso-list-template-ids:1248627982;} @list l7:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l8 {mso-list-id:638221730; mso-list-template-ids:-436039426;} @list l8:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l9 {mso-list-id:662319585; mso-list-template-ids:-1585515566;} @list l9:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l10 {mso-list-id:683287135; mso-list-template-ids:-1193137896;} @list l10:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l11 {mso-list-id:804541649; mso-list-template-ids:976269420;} @list l11:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l12 {mso-list-id:1010178062; mso-list-template-ids:321712644;} @list l12:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l13 {mso-list-id:1054354846; mso-list-template-ids:1885606374;} @list l13:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l14 {mso-list-id:1078136761; mso-list-template-ids:-1160064126;} @list l14:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l15 {mso-list-id:1078676392; mso-list-template-ids:1379990680;} @list l15:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l16 {mso-list-id:1087119236; mso-list-template-ids:2093284902;} @list l16:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l17 {mso-list-id:1113091651; mso-list-template-ids:-1947982802;} @list l17:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l18 {mso-list-id:1291059899; mso-list-template-ids:-313087698;} @list l18:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l19 {mso-list-id:1413048057; mso-list-template-ids:1113735158;} @list l19:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l20 {mso-list-id:1509903513; mso-list-template-ids:2112778584;} @list l20:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l21 {mso-list-id:1523006531; mso-list-template-ids:1049662440;} @list l21:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l22 {mso-list-id:1563760192; mso-list-template-ids:-1571931118;} @list l22:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l23 {mso-list-id:1577586745; mso-list-template-ids:827486850;} @list l23:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l24 {mso-list-id:1578636872; mso-list-template-ids:231761530;} @list l24:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l25 {mso-list-id:1578830166; mso-list-template-ids:-1359963504;} @list l25:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l26 {mso-list-id:1790583513; mso-list-template-ids:869433032;} @list l26:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l27 {mso-list-id:1905791334; mso-list-template-ids:1529918642;} @list l27:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l28 {mso-list-id:1962417600; mso-list-template-ids:637701298;} @list l28:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l29 {mso-list-id:1997100841; mso-list-template-ids:353240808;} @list l29:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l30 {mso-list-id:2009212927; mso-list-template-ids:726428178;} @list l30:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--><div class="MsoNormal" style="text-align: center;" align="center"><hr align="center" size="2" width="100%"> </div> <h2>What is ASP?</h2> <ul type="disc"><li class="MsoNormal" style="">ASP stands for <b>A</b>ctive <b>S</b>erver <b>P</b>ages </li><li class="MsoNormal" style="">ASP is a program that runs inside <b>IIS</b> </li><li class="MsoNormal" style="">IIS stands for <b>I</b>nternet <b>I</b>nformation <b>S</b>ervices </li><li class="MsoNormal" style="">IIS comes as a free component with <b>Windows 2000</b> </li><li class="MsoNormal" style="">IIS is also a part of the <b>Windows NT 4.0 Option Pack</b> </li><li class="MsoNormal" style="">The Option Pack can be <b>downloaded</b> from Microsoft </li><li class="MsoNormal" style=""><b>PWS</b> is a smaller - but fully functional - version of IIS </li><li class="MsoNormal" style="">PWS can be found on your <b>Windows 95/98 CD</b> </li></ul> <h2>ASP Compatibility</h2> <ul type="disc"><li class="MsoNormal" style="">ASP is a Microsoft Technology </li><li class="MsoNormal" style="">To run IIS you must have Windows NT 4.0 or later </li><li class="MsoNormal" style="">To run PWS you must have Windows 95 or later </li><li class="MsoNormal" style="">ChiliASP is a technology that runs ASP without Windows OS </li><li class="MsoNormal" style="">InstantASP is another technology that runs ASP without Windows </li></ul> <h2>What is an ASP File?</h2> <ul type="disc"><li class="MsoNormal" style="">An ASP file is just the same as an HTML file </li><li class="MsoNormal" style="">An ASP file can contain text, HTML, XML, and scripts </li><li class="MsoNormal" style="">Scripts in an ASP file are executed on the server </li><li class="MsoNormal" style="">An ASP file has the file extension ".asp" </li></ul> <h2>How Does ASP Differ from HTML?</h2> <ul type="disc"><li class="MsoNormal" style="">When a browser requests an HTML file, the server returns the file </li><li class="MsoNormal" style="">When a browser requests an ASP file, IIS passes the request to the ASP engine. The ASP engine reads the ASP file, line by line, and executes the scripts in the file. Finally, the ASP file is returned to the browser as plain HTML </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>What can ASP do for you?</h2> <ul type="disc"><li class="MsoNormal" style="">Dynamically edit, change or add any content of a Web page </li><li class="MsoNormal" style="">Respond to user queries or data submitted from HTML forms </li><li class="MsoNormal" style="">Access any data or databases and return the results to a browser </li><li class="MsoNormal" style="">Customize a Web page to make it more useful for individual users </li><li class="MsoNormal" style="">The advantages of using ASP instead of CGI and Perl, are those of simplicity and speed </li><li class="MsoNormal" style="">Provides security since your ASP code can not be viewed from the browser </li><li class="MsoNormal" style="">Since ASP files are returned as plain HTML, they can be viewed in any browser </li><li class="MsoNormal" style="">Clever ASP programming can minimize the network traffic </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">You can run ASP on your own PC without an external server. To do that, you must install Microsoft's Personal Web Server (PWS) or Internet Information Services (IIS) on your PC.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to Run ASP on your own PC</h2> <p>You can run ASP on your own PC without an external server. To do that, you must install Microsoft's Personal Web Server (PWS) or Internet Information Services (IIS) on your PC.</p> <p><b>If you are serious about using ASP, you should have at least Windows 98, Second Edition. </b></p> <p><b>If you are really serious about using ASP, you should go for Windows 2000.</b></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to install PWS and run ASP on Windows 95</h2> <p>Personal Web Server (PWS) is not shipped with Windows 95 !!</p> <p>To run ASP on Windows 95, you will have to download "Windows NT 4.0 Option Pack" from Microsoft.</p> <p><a href="http://www.microsoft.com/ntserver/nts/downloads/recommended/NT4OptPk/default.asp" target="_blank">Download the "Windows NT 4.0 Option Pack"</a></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to install PWS and run ASP on Windows NT</h2> <p>Personal Web Server (PWS) is not shipped with Windows NT !!</p> <p>To run ASP on Windows NT, you will have to download "Windows NT 4.0 Option Pack" from Microsoft.</p> <p><a href="http://www.microsoft.com/ntserver/nts/downloads/recommended/NT4OptPk/default.asp" target="_blank">Download the "Windows NT 4.0 Option Pack"</a></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to install PWS and run ASP on Windows 98</h2> <ol start="1" type="1"><li class="MsoNormal" style="">Open the <b>Add-ons</b> folder on your Windows98 CD, find the <b>PWS</b> folder and run the <b>setup.exe</b> file. </li><li class="MsoNormal" style="">An <b>Inetpub folder</b> will be created on your harddrive. Open it and find the <b>wwwroot</b> folder. </li><li class="MsoNormal" style=""><b>Create a new folder</b>, like "MyWeb", under wwwroot. </li><li class="MsoNormal" style=""><b>Use a text editor</b> to write some ASP code, save the file as "test1.asp" in the "MyWeb" folder. </li><li class="MsoNormal" style="">Make sure your Web server is running - The installation program has added a new icon on your task bar (this is the PWS symbol). Click on the icon and press the Start button in the window that appears. </li><li class="MsoNormal" style=""><b>Open your browser</b> and type in "http://localhost/MyWeb/test1.asp", to view your first ASP page. </li></ol> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to install PWS and run ASP on Windows ME</h2> <p>Personal Web Server (PWS) is not included with Windows Me !!</p> <p><a href="http://support.microsoft.com/support/kb/articles/Q266/4/56.ASP" target="_blank">Read article from Microsoft</a></p> <p><a href="http://billsway.com/notes_public/PWS_WinMe.txt" target="_blank">A workaround!</a></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to install IIS and run ASP on Windows 2000</h2> <ol start="1" type="1"><li class="MsoNormal" style="">From your <b>Start Button</b>, go to <b>Settings</b>, and <b>Control Panel</b> </li><li class="MsoNormal" style="">In the Control Panel window select <b>Add/Remove Programs</b> </li><li class="MsoNormal" style="">In the Add/Remove window select <b>Add/Remove Windows Components</b> </li><li class="MsoNormal" style="">In the Wizard window check <b>Internet Information Services</b>, <b>click OK</b> </li><li class="MsoNormal" style="">An <b>Inetpub folder</b> will be created on your harddrive </li><li class="MsoNormal" style="">Open the Inetpub folder, and find a folder named <b>wwwroot</b> </li><li class="MsoNormal" style=""><b>Create a new folder</b>, like "MyWeb", under wwwroot. </li><li class="MsoNormal" style=""><b>Use a text editor</b> to write some ASP code, save the file as "test1.asp" in the "MyWeb" folder </li><li class="MsoNormal" style="">Make sure your Web server is running - The installation program has added a new icon on your task bar (this is the IIS symbol). Click on the icon and press the Start button in the window that appears. </li><li class="MsoNormal" style=""><b>Open your browser</b> and type in "http://localhost/MyWeb/test1.asp", to view your first ASP page </li></ol> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to install IIS and run ASP on Windows XP Professional</h2> <p><b>Note:</b> You cannot run ASP on Windows XP Home Edition.</p> <ol start="1" type="1"><li class="MsoNormal" style="">Insert the Windows XP Professional CD-Rom into your <st1:street st="on"><st1:address st="on">CD-Rom Drive</st1:address></st1:street> </li><li class="MsoNormal" style="">From your <b>Start Button</b>, go to <b>Settings</b>, and <b>Control Panel</b> </li><li class="MsoNormal" style="">In the Control Panel window select <b>Add/Remove Programs</b> </li><li class="MsoNormal" style="">In the Add/Remove window select <b>Add/Remove Windows Components</b> </li><li class="MsoNormal" style="">In the Wizard window check <b>Internet Information Services</b>, <b>click OK</b> </li><li class="MsoNormal" style="">An <b>Inetpub folder</b> will be created on your harddrive </li><li class="MsoNormal" style="">Open the Inetpub folder, and find a folder named <b>wwwroot</b> </li><li class="MsoNormal" style=""><b>Create a new folder</b>, like "MyWeb", under wwwroot. </li><li class="MsoNormal" style=""><b>Use a text editor</b> to write some ASP code, save the file as "test1.asp" in the "MyWeb" folder </li><li class="MsoNormal" style="">Make sure your Web server is running - its status can be checked by going into the <b>Control Panel</b>, then <b>Administrative Tools</b>, and double-click the "<b>IIS Manager</b>" icon </li><li class="MsoNormal" style=""><b>Open your browser</b> and type in "http://localhost/MyWeb/test1.asp", to view your first ASP page </li></ol> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to install IIS and run ASP on Windows Server 2003 (Windows .NET Server)</h2> <ol start="1" type="1"><li class="MsoNormal" style="">When you start the Windows Server 2003, you should see the <b>Manage Your Server wizard</b> </li><li class="MsoNormal" style="">If the wizard is not displayed, go to <b>Administrative Tools, </b>and select <b>Manage Your Server</b> </li><li class="MsoNormal" style="">In the wizard, click <b>Add or Remove a Role</b>, click Next </li><li class="MsoNormal" style="">Select <b>Custom Configuration</b>, click Next </li><li class="MsoNormal" style="">Select <b>Application Server role</b>, click Next </li><li class="MsoNormal" style="">Select <b>Enable ASP.NET</b>, click Next </li><li class="MsoNormal" style="">Now, the wizard may ask for the <b>Server 2003 CD</b>. Insert the CD and let it run until it is finished, then click the Finish button </li><li class="MsoNormal" style="">The wizard should now show the Application Server role installed </li><li class="MsoNormal" style="">Click on <b>Manage This Application Server</b> to bring up the <b>Application Server Management Console (MMC)</b> </li><li class="MsoNormal" style="">Expand the <b>Internet Information Services (IIS) Manager</b>, then expand your server, and then the Web Sites folder </li><li class="MsoNormal" style="">You should see the Default Web Site, and it should not say (Stopped) </li><li class="MsoNormal" style="">IIS is running! </li><li class="MsoNormal" style="">In the <b>Internet Information Services (IIS) Manager </b>click on the <b>Web Service Extensions</b> folder </li><li class="MsoNormal" style="">Here you will see that <b>Active Server Pages are Prohibited</b> (this is the default configuration of IIS 6) </li><li class="MsoNormal" style="">Highlight <b>Active Server Pages</b> and click the <b>Allow</b> button </li><li class="MsoNormal" style="">ASP is now active! </li></ol> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">You cannot view the ASP source code by selecting "View source" in a browser, you will only see the output from the ASP file, which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.</p> <p class="intro">In our ASP tutorial, every example displays the hidden ASP source code. This will make it easier for you to understand how it works.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples </h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_text" target="_blank">Write text with ASP</a>
<br />How to write some text with ASP. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_formatting" target="_blank">Add some HTML to the text</a>
<br />How to format the text with HTML tags. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Basic Syntax Rule </h2> <p>An ASP file normally contains HTML tags, just like an HTML file. However, an ASP file can also contain <b>server scripts</b>, surrounded by the delimiters <b><%</b> and <b>%></b>. Server scripts are <b>executed on the server, </b>and can contain any expressions, statements, procedures, or operators valid for the scripting language you prefer to use. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Write Output to a Browser</h2> <p>The response.write command is used to write output to a browser. The following example sends the text "Hello World" to the browser:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><body></pre><pre><span class="red"><%<o:p></o:p></span></pre><pre><span class="red">response.write("Hello World!")<o:p></o:p></span></pre><pre><span class="red">%></span></pre><pre></body></pre><pre><html></pre></td> </tr> </tbody></table> <p>There is also a shorthand method for the response.write command. The following example also sends the text "Hello World" to the browser:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><body></pre><pre><span class="red"><%="Hello World!"%></span></pre><pre></body></pre><pre><html></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>VBScript</h2> <p>You can use several scripting languages in ASP. However, the default scripting language is VBScript:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><body></pre><pre><span class="red"><%<o:p></o:p></span></pre><pre><span class="red">response.write("Hello World!")<o:p></o:p></span></pre><pre><span class="red">%></span></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p>The example above writes "Hello World!" into the body of the document. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>JavaScript </h2> <p>To set JavaScript as the default scripting language for a particular page you must insert a language specification at the top of the page:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%@ language="javascript"%></pre><pre><html></pre><pre><body></pre><pre><span class="red"><%<o:p></o:p></span></pre><pre><span class="red">Response.Write("Hello World!")<o:p></o:p></span></pre><pre><span class="red">%></span></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p><b>Note:</b> Unlike VBScript - JavaScript is case sensitive. You will have to write your ASP code with uppercase letters and lowercase letters when the language requires it. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Other Scripting Languages </h2> <p>ASP is shipped with VBScript and JScript (Microsoft's implementation of JavaScript). If you want to script in another language, like PERL, REXX, or Python, you will have to install script engines for them.</p> <p><b>Important:</b> Because the scripts are executed on the server, the browser that displays the ASP file does not need to support scripting at all!</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">A variable is used to store information. </p> <p class="intro">If the variable is declared outside a procedure it can be changed by any script in the ASP file. If the variable is declared inside a procedure, it is created and destroyed every time the procedure is executed. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_variable" target="_blank">Declare a variable</a>
<br />Variables are used to store information. This example demonstrates how to declare a variable, assign a value to it, and use the value in a text.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_array" target="_blank">Declare an array</a>
<br />Arrays are used to store a series of related data items. This example demonstrates how to declare an array that stores names.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_fornext2" target="_blank">Loop through the HTML headers</a>
<br />How to loop through the six headers in HTML.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_vbtime" target="_blank">Time-based greeting using VBScript</a>
<br />This example will display a different message to the user depending on the time on the server.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_jstime" target="_blank">Time-based greeting using JavaScript</a>
<br />This example is the same as the one above, but the syntax is different.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Lifetime of Variables </h2> <p>A variable declared outside a procedure can be accessed and changed by any script in the ASP file. </p> <p>A variable declared inside a procedure is created and destroyed every time the procedure is executed. No scripts outside the procedure can access or change the variable. </p> <p>To declare variables accessible to more than one ASP file, declare them as session variables or application variables.</p> <h3>Session Variables</h3> <p>Session variables are used to store information about ONE single user, and are available to all pages in one application. Typically information stored in session variables are name, id, and preferences.</p> <h3>Application Variables </h3> <p>Application variables are also available to all pages in one application. Application variables are used to store information about ALL users in a specific application.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">A variable is used to store information. </p> <p class="intro">If the variable is declared outside a procedure it can be changed by any script in the ASP file. If the variable is declared inside a procedure, it is created and destroyed every time the procedure is executed. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_variable" target="_blank">Declare a variable</a>
<br />Variables are used to store information. This example demonstrates how to declare a variable, assign a value to it, and use the value in a text.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_array" target="_blank">Declare an array</a>
<br />Arrays are used to store a series of related data items. This example demonstrates how to declare an array that stores names.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_fornext2" target="_blank">Loop through the HTML headers</a>
<br />How to loop through the six headers in HTML.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_vbtime" target="_blank">Time-based greeting using VBScript</a>
<br />This example will display a different message to the user depending on the time on the server.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_jstime" target="_blank">Time-based greeting using JavaScript</a>
<br />This example is the same as the one above, but the syntax is different.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Lifetime of Variables </h2> <p>A variable declared outside a procedure can be accessed and changed by any script in the ASP file. </p> <p>A variable declared inside a procedure is created and destroyed every time the procedure is executed. No scripts outside the procedure can access or change the variable. </p> <p>To declare variables accessible to more than one ASP file, declare them as session variables or application variables.</p> <h3>Session Variables</h3> <p>Session variables are used to store information about ONE single user, and are available to all pages in one application. Typically information stored in session variables are name, id, and preferences.</p> <h3>Application Variables </h3> <p>Application variables are also available to all pages in one application. Application variables are used to store information about ALL users in a specific application.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">In ASP you can call a JavaScript procedure from a VBScript and vice versa. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples </h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_vbproc" target="_blank">Call a procedure using VBScript</a>
<br />How to call a VBScript procedure from ASP.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_jsproc" target="_blank">Call a procedure using JavaScript</a>
<br />How to call a JavaScript procedure from ASP.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_vbproc2" target="_blank">Call procedures using VBScript</a>
<br />How to call both a JavaScript procedure and a VBScript procedure in an ASP file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Procedures </h2> <p>The ASP source code can contain procedures and functions: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><head></pre><pre><%</pre><pre>sub vbproc(num1,num2)</pre><pre>response.write(num1*num2)</pre><pre>end sub</pre><pre>%></pre><pre></head></pre><pre><body></pre><pre><p>Result: <%call vbproc(3,4)%></p></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p>Insert the <%@ language="<i>language</i>" %> line above the <html> tag to write procedures or functions in another scripting language than default: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%@ language="javascript" %></pre><pre><html></pre><pre><head></pre><pre><%</pre><pre>function jsproc(num1,num2)</pre><pre>{</pre><pre>Response.Write(num1*num2)</pre><pre>}</pre><pre>%></pre><pre></head></pre><pre><body></pre><pre><p>Result: <%jsproc(3,4)%></p></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Differences Between VBScript and JavaScript</h2> <p>When calling a VBScript or a JavaScript procedure from an ASP file written in VBScript, you can use the "call" keyword followed by the procedure name. If a procedure requires parameters, the parameter list must be enclosed in parentheses when using the "call" keyword. If you omit the "call" keyword, the parameter list must not be enclosed in parentheses. If the procedure has no parameters, the parentheses are optional. </p> <p>When calling a JavaScript or a VBScript procedure from an ASP file written in JavaScript, always use parentheses after the procedure name. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The Request.QueryString and Request.Form commands may be used to retrieve information from forms, like user input.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_reqquery" target="_blank">A form with method="get"</a>
<br />How to interact with the user, with the Request.QueryString command.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_simpleform" target="_blank">A form with method="post"</a>
<br />How to interact with the user, with the Request.Form command.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_radiob" target="_blank">A form with radio buttons</a>
<br />How to interact with the user, through radio buttons, with the Request.Form command.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>User Input </h2> <p>The Request object may be used to retrieve user information from forms.</p> <p><b>Form example:</b></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><form method="get" action="simpleform.asp"></pre><pre>First Name: <input type="text" name="fname"></pre><pre><br /></pre><pre>Last Name: <input type="text" name="lname"></pre><pre><br /><br /></pre><pre><input type="submit" value="Submit"></pre><pre></form></pre></td> </tr> </tbody></table> <p>User input can be retrieved in two ways: With Request.QueryString or Request.Form. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Request.QueryString</h2> <p>The Request.QueryString command is used to collect values in a form with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.</p> <p>If a user typed "Bill" and "Gates" in the form example above, the URL sent to the server would look like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>http://www.w3schools.com/simpleform.asp?fname=Bill&lname=Gates</pre></td> </tr> </tbody></table> <p>Assume that the ASP file "simpleform.asp" contains the following script:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><body></pre><pre>Welcome</pre><pre><%</pre><pre>response.write(request.querystring("fname"))</pre><pre>response.write(" " & request.querystring("lname"))</pre><pre>%></pre><pre></body></pre></td> </tr> </tbody></table> <p>The browser will display the following in the body of the document:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>Welcome Bill Gates</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Request.Form </h2> <p>The Request.Form command is used to collect values in a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.</p> <p>If a user typed "Bill" and "Gates" in the form example above, the URL sent to the server would look like this: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>http://www.w3schools.com/simpleform.asp</pre></td> </tr> </tbody></table> <p>Assume that the ASP file "simpleform.asp" contains the following script:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><body></pre><pre>Welcome</pre><pre><%</pre><pre>response.write(request.form("fname"))</pre><pre>response.write(" " & request.form("lname"))</pre><pre>%></pre><pre></body></pre></td> </tr> </tbody></table> <p>The browser will display the following in the body of the document:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>Welcome Bill Gates</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Form Validation</h2> <p>User input should be validated on the browser whenever possible (by client scripts). Browser validation is faster and you reduce the server load.</p> <p>You should consider using server validation if the user input will be inserted into a database. A good way to validate a form on the server is to post the form to itself, instead of jumping to a different page. The user will then get the error messages on the same page as the form. This makes it easier to discover the error.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">A cookie is often used to identify a user.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples </h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_cookies" target="_blank">Welcome cookie</a>
<br />How to create a Welcome cookie.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>What is a Cookie? </h2> <p>A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to Create a Cookie</h2> <p>The "Response.Cookies" command is used to create cookies.</p> <p><b>Note:</b> The Response.Cookies command must appear BEFORE the <html> tag. </p> <p>In the example below, we will create a cookie named "firstname" and assign the value "Alex" to it:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Response.Cookies("firstname")="Alex"</pre><pre>%></pre></td> </tr> </tbody></table> <p>It is also possible to assign properties to a cookie, like setting a date when the cookie should expire: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Response.Cookies("firstname")="Alex" </pre><pre>Response.Cookies("firstname").Expires=#<st1:date month="5" day="10" year="2002" st="on">May 10,2002</st1:date>#</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to Retrieve a Cookie Value</h2> <p>The "Request.Cookies" command is used to retrieve a cookie value. </p> <p>In the example below, we retrieve the value of the cookie named "firstname" and display it on a page:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>fname=Request.Cookies("firstname")</pre><pre>response.write("Firstname=" & fname)</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal">
<br /><b>Output:</b> </p> <p>Firstname=Alex</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>A Cookie with Keys </h2> <p>If a cookie contains a collection of multiple values, we say that the cookie has Keys. </p> <p>In the example below, we will create a cookie collection named "user". The "user" cookie has Keys that contains information about a user:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Response.Cookies("user")("firstname")="John"</pre><pre>Response.Cookies("user")("lastname")="Smith"</pre><pre>Response.Cookies("user")("country")="<st1:country-region st="on"><st1:place st="on">Norway</st1:place></st1:country-region>"</pre><pre>Response.Cookies("user")("age")="25"</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Read all Cookies</h2> <p>Look at the following code:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Response.Cookies("firstname")="Alex"</pre><pre>Response.Cookies("user")("firstname")="John"</pre><pre>Response.Cookies("user")("lastname")="Smith"</pre><pre>Response.Cookies("user")("country")="<st1:country-region st="on"><st1:place st="on">Norway</st1:place></st1:country-region>"</pre><pre>Response.Cookies("user")("age")="25"</pre><pre>%></pre></td> </tr> </tbody></table> <p>Assume that your server has sent all the cookies above to a user.</p> <p>Now we want to read all the cookies sent to a user. The example below shows how to do it (note that the code below checks if a cookie has Keys with the HasKeys property):</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><body></pre><pre><%</pre><pre>dim x,y</pre><pre>for each x in Request.Cookies</pre><pre><span style=""> </span>response.write("<p>")</pre><pre><span style=""> </span>if Request.Cookies(x).HasKeys then</pre><pre><span style=""> </span>for each y in Request.Cookies(x)</pre><pre><span style=""> </span>response.write(x & ":" & y & "=" & Request.Cookies(x)(y))</pre><pre><span style=""> </span>response.write("<br />")</pre><pre><span style=""> </span>next</pre><pre><span style=""> </span>else</pre><pre><span style=""> </span>Response.Write(x & "=" & Request.Cookies(x) & "<br />")</pre><pre><span style=""> </span>end if</pre><pre><span style=""> </span>response.write "</p>"</pre><pre>next</pre><pre>%></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p><b>Output:</b></p> <p>firstname=Alex</p> <p>user:firstname=John
<br />user:lastname=Smith
<br />user:country=<st1:country-region st="on"><st1:place st="on">Norway</st1:place></st1:country-region>
<br />user:age=25</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>What if a Browser Does NOT Support Cookies?</h2> <p>If your application deals with browsers that do not support cookies, you will have to use other methods to pass information from one page to another in your application. There are two ways of doing this: </p> <h3>1. Add parameters to a URL</h3> <p>You can add parameters to a URL:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><a href="welcome.asp?fname=John&lname=Smith"></pre><pre>Go to Welcome Page</a></pre></td> </tr> </tbody></table> <p>And retrieve the values in the "welcome.asp" file like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>fname=Request.querystring("fname")</pre><pre>lname=Request.querystring("lname")</pre><pre>response.write("<p>Hello " & fname & " " & lname & "!</p>")</pre><pre>response.write("<p>Welcome to my Web site!</p>")</pre><pre>%></pre></td> </tr> </tbody></table> <h3>2. Use a form</h3> <p>You can use a form. The form passes the user input to "welcome.asp" when the user clicks on the Submit button: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><form method="post" action="welcome.asp"></pre><pre>First Name:<span style=""> </span><input type="text" name="fname" value=""></pre><pre>Last Name: <input type="text" name="lname" value=""></pre><pre><input type="submit" value="Submit"></pre><pre></form></pre></td> </tr> </tbody></table> <p>Retrieve the values in the "welcome.asp" file like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>fname=Request.form("fname")</pre><pre>lname=Request.form("lname")</pre><pre>response.write("<p>Hello " & fname & " " & lname & "!</p>")</pre><pre>response.write("<p>Welcome to my Web site!</p>")</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The Session object is used to store information about, or change settings for a user session. Variables stored in the Session object hold information about one single user, and are available to all pages in one application. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Session object </h2> <p>When you are working with an application, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web server does not know who you are and what you do because the HTTP address doesn't maintain state. </p> <p>ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the client and it contains information that identifies the user. This interface is called the Session object. </p> <p>The Session object is used to store information about, or change settings for a user session. Variables stored in the Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>When does a Session Start?</h2> <p>A session starts when: </p> <ul type="disc"><li class="MsoNormal" style="">A new user requests an ASP file, and the Global.asa file includes a Session_OnStart procedure </li><li class="MsoNormal" style="">A value is stored in a Session variable </li><li class="MsoNormal" style="">A user requests an ASP file, and the Global.asa file uses the <object> tag to instantiate an object with session scope </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>When does a Session End?</h2> <p>A session ends if a user has not requested or refreshed a page in the application for a specified period. By default, this is 20 minutes. </p> <p>If you want to set a timeout interval that is shorter or longer than the default, you can set the <b>Timeout</b> property.</p> <p>The example below sets a timeout interval of 5 minutes:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Session.Timeout=5</pre><pre>%></pre></td> </tr> </tbody></table> <p>To end a session immediately, you may use the <b>Abandon</b> method:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Session.Abandon</pre><pre>%></pre></td> </tr> </tbody></table> <p><b>Note:</b> The main problem with sessions is WHEN they should end. We do not know if the user's last request was the final one or not. So we do not know how long we should keep the session "alive". Waiting too long for an idle session uses up resources on the server, but if the session is deleted too soon the user has to start all over again because the server has deleted all the information. Finding the right timeout interval can be difficult!</p> <p><b>Tip:</b> If you are using session variables, store SMALL amounts of data in them. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Store and Retrieve Session Variables </h2> <p>The most important thing about the Session object is that you can store variables in it.</p> <p>The example below will set the Session variable <i>username</i> to "Donald Duck" and the Session variable <i>age</i> to "50":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Session("username")="Donald Duck"</pre><pre>Session("age")=50</pre><pre>%></pre></td> </tr> </tbody></table> <p>When the value is stored in a session variable it can be reached from ANY page in the ASP application:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>Welcome <%Response.Write(Session("username"))%></pre></td> </tr> </tbody></table> <p>The line above returns: "Welcome Donald Duck".</p> <p>You can also store user preferences in the Session object, and then access that preference to choose what page to return to the user. </p> <p>The example below specifies a text-only version of the page if the user has a low screen resolution: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%If Session("screenres")="low" Then%> </pre><pre><span style=""> </span>This is the text version of the page</pre><pre><%Else%> </pre><pre><span style=""> </span>This is the multimedia version of the page</pre><pre><%End If%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Remove Session Variables </h2> <p>The Contents collection contains all session variables.</p> <p>It is possible to remove a session variable with the Remove method.</p> <p>The example below removes the session variable "sale" if the value of the session variable "age" is lower than 18: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>If Session.Contents("age")<18><pre><span style=""> </span>Session.Contents.Remove("sale")</pre><pre>End If </pre><pre>%></pre></td> </tr> </tbody></table> <p>To remove all variables in a session, use the RemoveAll method: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Session.Contents.RemoveAll()</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2><st1:place st="on">Loop</st1:place> Through the Contents Collection</h2> <p>The Contents collection contains all session variables. You can loop through the Contents collection, to see what's stored in it: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Session("username")="Donald Duck"</pre><pre>Session("age")=50</pre><pre>dim i</pre><pre>For Each i in Session.Contents</pre><pre><span style=""> </span>Response.Write(i & "<br />")</pre><pre>Next</pre><pre>%></pre></td> </tr> </tbody></table> <p>Result:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>username</pre><pre>age</pre></td> </tr> </tbody></table> <p>If you do not know the number of items in the Contents collection, you can use the Count property:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>dim i</pre><pre>dim j</pre><pre>j=Session.Contents.Count</pre><pre>Response.Write("Session variables: " & j)</pre><pre>For i=1 to j</pre><pre><span style=""> </span>Response.Write(Session.Contents(i) & "<br />")</pre><pre>Next</pre><pre>%></pre></td> </tr> </tbody></table> <p>Result:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>Session variables: 2</pre><pre>Donald Duck</pre><pre>50</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2><st1:place st="on">Loop</st1:place> Through the StaticObjects Collection</h2> <p>You can loop through the StaticObjects collection, to see the values of all objects stored in the Session object:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>dim i</pre><pre>For Each i in Session.StaticObjects</pre><pre><span style=""> </span>Response.Write(i & "<br />")</pre><pre>Next</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">A group of ASP files that work together to perform some purpose is called an application. The Application object in ASP is used to tie these files together.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Application Object</h2> <p>An application on the Web may be a group of ASP files. The ASP files work together to perform some purpose. The Application object in ASP is used to tie these files together.</p> <p>The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share one Application object, while with Sessions there is one Session object for EACH user.</p> <p>The Application object should hold information that will be used by many pages in the application (like database connection information). This means that you can access the information from any page. It also means that you can change the information in one place and the changes will automatically be reflected on all pages.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Store and Retrieve Application Variables</h2> <p>Application variables can be accessed and changed by any page in the application.</p> <p>You can create Application variables in "Global.asa" like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><script language="vbscript" runat="server"></pre><pre><o:p> </o:p></pre><pre>Sub Application_OnStart</pre><pre>application("vartime")=""</pre><pre>application("users")=1</pre><pre>End Sub</pre><pre><o:p> </o:p></pre><pre></script></pre></td> </tr> </tbody></table> <p>In the example above we have created two Application variables: "vartime" and "users".</p> <p>You can access the value of an Application variable like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>There are </pre><pre><%</pre><pre>Response.Write(Application("users"))</pre><pre>%> </pre><pre>active connections.</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2><st1:place st="on">Loop</st1:place> Through the Contents Collection</h2> <p>The Contents collection contains all application variables. You can loop through the Contents collection, to see what's stored in it:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>dim i</pre><pre>For Each i in Application.Contents</pre><pre><span style=""> </span>Response.Write(i & "<br />")</pre><pre>Next</pre><pre>%></pre></td> </tr> </tbody></table> <p>If you do not know the number of items in the Contents collection, you can use the Count property:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>dim i</pre><pre>dim j</pre><pre>j=Application.Contents.Count</pre><pre>For i=1 to j</pre><pre><span style=""> </span>Response.Write(Application.Contents(i) & "<br />")</pre><pre>Next</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2><st1:place st="on">Loop</st1:place> Through the StaticObjects Collection</h2> <p>You can loop through the StaticObjects collection, to see the values of all objects stored in the Application object:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>dim i</pre><pre>For Each i in Application.StaticObjects</pre><pre><span style=""> </span>Response.Write(i & "<br />")</pre><pre>Next</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Lock and Unlock</h2> <p>You can lock an application with the "Lock" method. When an application is locked, the users cannot change the Application variables (other than the one currently accessing it). You can unlock an application with the "Unlock" method. This method removes the lock from the Application variable:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Application.Lock</pre><pre><span style=""> </span>'do some application object operations</pre><pre>Application.Unlock</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The #include Directive</h2> <p>You can insert the content of one ASP file into another ASP file before the server executes it, with the #include directive. The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to Use the #include Directive</h2> <p>Here is a file called "mypage.asp":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html> </pre><pre><body> </pre><pre><h3>Words of Wisdom:</h3></pre><pre><p><!--#include file="wisdom.inc"--></p> </pre><pre><h3>The time is:</h3></pre><pre><p><!--#include file="time.inc"--></p></pre><pre></body> </pre><pre></html> </pre></td> </tr> </tbody></table> <p>Here is the "wisdom.inc" file:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>"One should never increase, beyond what is necessary,</pre><pre>the number of entities required to explain anything."</pre></td> </tr> </tbody></table> <p>Here is the "time.inc" file:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>Response.Write(Time)</pre><pre>%></pre></td> </tr> </tbody></table> <p>If you look at the source code in a browser, it will look something like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><body></pre><pre><h3>Words of Wisdom:</h3></pre><pre><p>"One should never increase, beyond what is necessary,</pre><pre>the number of entities required to explain anything."</p></pre><pre><h3>The time is:</h3></pre><pre><p><st1:time hour="11" minute="33" st="on">11:33:42 AM</st1:time></p></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Syntax for Including Files</h2> <p>To include a file in an ASP page, place the #include directive inside comment tags:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><!--#include virtual="somefilename"--></pre><pre>or</pre><pre><!--#include file ="somefilename"--></pre></td> </tr> </tbody></table> <h3>The Virtual Keyword</h3> <p>Use the virtual keyword to indicate a path beginning with a virtual directory.</p> <p>If a file named "header.inc" resides in a virtual directory named /html, the following line would insert the contents of "header.inc":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><!-- #include virtual ="/html/header.inc" --></pre></td> </tr> </tbody></table> <h3>The File Keyword</h3> <p>Use the file keyword to indicate a relative path. A relative path begins with the directory that contains the including file.</p> <p>If you have a file in the html directory, and the file "header.inc" resides in html\headers, the following line would insert "header.inc" in your file:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><!-- #include file ="headers\header.inc" --></pre></td> </tr> </tbody></table> <p>Note that the path to the included file (headers\header.inc) is relative to the including file. If the file containing this #include statement is not in the html directory, the statement will not work.</p> <p>You can also use the file keyword with the syntax (..\) to include a file from a higher-level directory.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Tips and Notes</h2> <p>In the sections above we have used the file extension ".inc" for included files. Notice that if a user tries to browse an INC file directly, its content will be displayed. If your included file contains confidential information or information you do not want any users to see, it is better to use an ASP extension. The source code in an ASP file will not be visible after the interpretation. An included file can also include other files, and one ASP file can include the same file more than once. </p> <p><b>Important:</b> Included files are processed and inserted before the scripts are executed.</p> <p>The following script will not work because ASP executes the #include directive before it assigns a value to the variable:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>fname="header.inc"</pre><pre>%></pre><pre><!--#include file="<%=fname%>"--></pre></td> </tr> </tbody></table> <p>You cannot open or close a script delimiter in an INC file. This script will not work:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><%</pre><pre>For i = 1 To n</pre><pre><span style=""> </span><!--#include file="count.inc"--></pre><pre>Next</pre><pre>%></pre></td> </tr> </tbody></table> <p>But this script will work:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><% For i = 1 to n %></pre><pre><!--#include file="count.inc" --></pre><pre><% Next %></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Global.asa file</h2> <p>The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application. All valid browser scripts (JavaScript, VBScript, JScript, PerlScript, etc.) can be used within Global.asa.</p> <p>The Global.asa file can contain only the following:</p> <ul type="disc"><li class="MsoNormal" style="">Application events </li><li class="MsoNormal" style="">Session events </li><li class="MsoNormal" style=""><object> declarations </li><li class="MsoNormal" style="">TypeLibrary declarations </li><li class="MsoNormal" style="">the #include directive </li></ul> <p><b>Note:</b> The Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Events in Global.asa</h2> <p>In Global.asa you can tell the application and session objects what to do when the application/session starts and what to do when the application/session ends. The code for this is placed in event handlers. The Global.asa file can contain four types of events:</p> <p class="MsoNormal"><b>Application_OnStart</b> - This event occurs when the FIRST user calls the first page from an ASP application. This event occurs after the Web server is restarted or after the Global.asa file is edited. The "Session_OnStart" event occurs immediately after this event. </p> <p><b>Session_OnStart</b> - This event occurs EVERY time a NEW user requests his or her first page in the ASP application.</p> <p><b>Session_OnEnd</b> - This event occurs EVERY time a user ends a session. A user ends a session after a page has not been requested by the user for a specified time (by default this is 20 minutes).</p> <p><b>Application_OnEnd</b> - This event occurs after the LAST user has ended the session. Typically, this event occurs when a Web server stops. This procedure is used to clean up settings after the Application stops, like delete records or write information to text files.</p> <p>A Global.asa file could look something like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><script language="vbscript" runat="server"></pre><pre>sub Application_OnStart</pre><pre><span style=""> </span>'some code</pre><pre>end sub</pre><pre>sub Application_OnEnd</pre><pre><span style=""> </span>'some code</pre><pre>end sub</pre><pre>sub Session_OnStart</pre><pre><span style=""> </span>'some code</pre><pre>end sub</pre><pre>sub Session_OnEnd</pre><pre><span style=""> </span>'some code</pre><pre>end sub</pre><pre></script></pre></td> </tr> </tbody></table> <p><b>Note:</b> Because we cannot use the ASP script delimiters (<% and %>) to insert scripts in the Global.asa file, we put subroutines inside an HTML <script> element.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2><object> Declarations </h2> <p>It is possible to create objects with session or application scope in Global.asa by using the <object> tag. </p> <p><b>Note:</b> The <object> tag should be outside the <script> tag!</p> <h3>Syntax </h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><object runat="server" scope="scope" id="id"><pre>{progid="progID"|classid="classID"}></pre><pre>....</pre><pre></object></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Parameter<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 80%;" valign="top" width="80%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">scope </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the scope of the object (either Session or Application) </p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">id </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies a unique id for the object </p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ProgID </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">An id associated with a class id. The format for ProgID is [Vendor.]Component[.Version] </p> <p>Either ProgID or ClassID must be specified.</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ClassID </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies a unique id for a COM class object. </p> <p>Either ProgID or ClassID must be specified.</p> </td> </tr> </tbody></table> <h3>Examples </h3> <p>The first example creates an object of session scope named "MyAd" by using the ProgID parameter:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><object runat="server" scope="session" id="MyAd"><pre>progid="MSWC.AdRotator"></pre><pre></object></pre></td> </tr> </tbody></table> <p>The second example creates an object of application scope named "MyConnection" by using the ClassID parameter:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><object runat="server" scope="application" id="MyConnection"><pre>classid="Clsid:8AD3067A-B3FC-11CF-A560-00A0C9081C21"></pre><pre></object></pre></td> </tr> </tbody></table> <p>The objects declared in the Global.asa file can be used by any script in the application:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p>GLOBAL.ASA:</p> <pre><object runat="server" scope="session" id="MyAd"><pre>progid="MSWC.AdRotator"></pre><pre></object></pre> <p>You could reference the object "MyAd" from any page in the ASP application:</p> <p>SOME .ASP FILE:</p> <pre><%=MyAd.GetAdvertisement("/banners/adrot.txt")%> </pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>TypeLibrary Declarations</h2> <p>A TypeLibrary is a container for the contents of a DLL file corresponding to a COM object. By including a call to the TypeLibrary in the Global.asa file, the constants of the COM object can be accessed, and errors can be better reported by the ASP code. If your Web application relies on COM objects that have declared data types in type libraries, you can declare the type libraries in Global.asa.</p> <h3>Syntax </h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><!--METADATA TYPE="TypeLib"</pre><pre>file="filename"</pre><pre>uuid="typelibraryuuid"</pre><pre>version="versionnumber"</pre><pre>lcid="localeid"</pre><pre>--></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Parameter<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 80%;" valign="top" width="80%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">file</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies an absolute path to a type library. </p> <p>Either the file parameter or the uuid parameter is required</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">uuid</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies a unique identifier for the type library. </p> <p>Either the file parameter or the uuid parameter is required</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">version</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Used for selecting version. If the requested version is not found, then the most recent version is used</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">lcid</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. The locale identifier to be used for the type library</p> </td> </tr> </tbody></table> <h3>Error Values</h3> <p>The server can return one of the following error messages:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Error Code<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 80%;" valign="top" width="80%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ASP 0222</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Invalid type library specification </p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ASP 0223</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Type library not found </p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ASP 0224</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Type library cannot be loaded</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ASP 0225</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Type library cannot be wrapped</p> </td> </tr> </tbody></table> <p><b>Note:</b> METADATA tags can appear anywhere in the Global.asa file (both inside and outside <script> tags). However, it is recommended that METADATA tags appear near the top of the Global.asa file. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Restrictions</h2> <p>Restrictions on what you can include in the Global.asa file: </p> <ul type="disc"><li class="MsoNormal" style="">You can not display text that is written in the Global.asa file. This file can't display information </li><li class="MsoNormal" style="">You can only use Server and Application objects in the Application_OnStart and Application_OnEnd subroutines. In the Session_OnEnd subroutine, you can use Server, Application, and Session objects. In the Session_OnStart subroutine you can use any built-in object </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to use the Subroutines</h2> <p>Global.asa is often used to initialize variables. </p> <p>The example below shows how to detect the exact time a visitor first arrives on a Web site. The time is stored in a Session variable named "started", and the value of the "started" variable can be accessed from any ASP page in the application:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><script language="vbscript" runat="server"></pre><pre>sub Session_OnStart</pre><pre>Session("started")=now()</pre><pre>end sub</pre><pre></script></pre></td> </tr> </tbody></table> <p>Global.asa can also be used to control page access. </p> <p>The example below shows how to redirect every new visitor to another page, in this case to a page called "newpage.asp": </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><script language="vbscript" runat="server"></pre><pre>sub Session_OnStart</pre><pre>Response.Redirect("newpage.asp")</pre><pre>end sub</pre><pre></script></pre></td> </tr> </tbody></table> <p>And you can include functions in the Global.asa file. </p> <p>In the example below the Application_OnStart subroutine occurs when the Web server starts. Then the Application_OnStart subroutine calls another subroutine named "getcustomers". The "getcustomers" subroutine opens a database and retrieves a record set from the "customers" table. The record set is assigned to an array, where it can be accessed from any ASP page without querying the database: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><script language="vbscript" runat="server"></pre><pre>sub Application_OnStart</pre><pre>getcustomers</pre><pre>end sub</pre><pre>sub getcustomers </pre><pre>set conn=Server.CreateObject("ADODB.Connection")</pre><pre>conn.Provider="Microsoft.Jet.OLEDB.4.0"</pre><pre>conn.Open "c:/webdata/northwind.mdb"</pre><pre>set rs=conn.execute("select name from customers")</pre><pre>Application("customers")=rs.GetRows</pre><pre>rs.Close</pre><pre>conn.Close</pre><pre>end sub</pre><pre></script></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Global.asa Example </h2> <p>In this example we will create a Global.asa file that counts the number of current visitors. </p> <ul type="disc"><li class="MsoNormal" style="">The Application_OnStart sets the Application variable "visitors" to 0 when the server starts </li><li class="MsoNormal" style="">The Session_OnStart subroutine adds one to the variable "visitors" every time a new visitor arrives </li><li class="MsoNormal" style="">The Session_OnEnd subroutine subtracts one from "visitors" each time this subroutine is triggered </li></ul> <p>The Global.asa file: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><script language="vbscript" runat="server"></pre><pre>Sub Application_OnStart</pre><pre>Application("visitors")=0</pre><pre>End Sub</pre><pre>Sub Session_OnStart</pre><pre>Application.Lock</pre><pre>Application("visitors")=Application("visitors")+1</pre><pre>Application.UnLock</pre><pre>End Sub</pre><pre>Sub Session_OnEnd</pre><pre>Application.Lock</pre><pre>Application("visitors")=Application("visitors")-1</pre><pre>Application.UnLock</pre><pre>End Sub</pre><pre></script></pre></td> </tr> </tbody></table> <p>To display the number of current visitors in an ASP file: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><html></pre><pre><head></pre><pre></head></pre><pre><body></pre><pre><p></pre><pre>There are <%response.write(Application("visitors"))%></pre><pre>online now!</pre><pre></p></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">CDOSYS is a built-in component in ASP. This component is used to send e-mails with ASP.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Sending e-mail with CDOSYS</h2> <p>CDO (Collaboration Data Objects) is a Microsoft technology that is designed to simplify the creation of messaging applications.</p> <p>CDOSYS is a built-in component in ASP. We will show you how to use this component to send e-mail with ASP.</p> <h2>How about CDONTs?</h2> <p>Microsoft has discontinued the use of CDONTs on Windows 2000, Windows XP and Windows 2003. If you have used CDONTs in your ASP applications, you should update the code and use the new CDO technology.</p> <h2>Examples using CDOSYS</h2> <p>Sending a text e-mail:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Set myMail=CreateObject("CDO.Message")</pre><pre>myMail.Subject="Sending email with CDO"</pre><pre>myMail.From="mymail@mydomain.com"</pre><pre>myMail.To="someone@somedomain.com"</pre><pre>myMail.TextBody="This is a message."</pre><pre>myMail.Send</pre><pre>set myMail=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p>Sending a text e-mail with Bcc and CC fields:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Set myMail=CreateObject("CDO.Message")</pre><pre>myMail.Subject="Sending email with CDO"</pre><pre>myMail.From="mymail@mydomain.com"</pre><pre>myMail.To="someone@somedomain.com"</pre><pre>myMail.Bcc="someoneelse@somedomain.com"</pre><pre>myMail.Cc="someoneelse2@somedomain.com"</pre><pre>myMail.TextBody="This is a message."</pre><pre>myMail.Send</pre><pre>set myMail=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p>Sending an HTML e-mail:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Set myMail=CreateObject("CDO.Message")</pre><pre>myMail.Subject="Sending email with CDO"</pre><pre>myMail.From="mymail@mydomain.com"</pre><pre>myMail.To="someone@somedomain.com"</pre><pre>myMail.HTMLBody = "<h1>This is a message.</h1>" </pre><pre>myMail.Send</pre><pre>set myMail=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p>Sending an HTML e-mail that sends a webpage from a website:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Set myMail=CreateObject("CDO.Message")</pre><pre>myMail.Subject="Sending email with CDO"</pre><pre>myMail.From="mymail@mydomain.com"</pre><pre>myMail.To="someone@somedomain.com"</pre><pre>myMail.CreateMHTMLBody "http://www.w3schools.com/asp/" </pre><pre>myMail.Send</pre><pre>set myMail=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p>Sending an HTML e-mail that sends a webpage from a file on your computer:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Set myMail=CreateObject("CDO.Message")</pre><pre>myMail.Subject="Sending email with CDO"</pre><pre>myMail.From="mymail@mydomain.com"</pre><pre>myMail.To="someone@somedomain.com"</pre><pre>myMail.CreateMHTMLBody "file://c:/mydocuments/test.htm" </pre><pre>myMail.Send</pre><pre>set myMail=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p>Sending a text e-mail with an Attachment:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Set myMail=CreateObject("CDO.Message")</pre><pre>myMail.Subject="Sending email with CDO"</pre><pre>myMail.From="mymail@mydomain.com"</pre><pre>myMail.To="someone@somedomain.com"</pre><pre>myMail.TextBody="This is a message."</pre><pre>myMail.AddAttachment "c:\mydocuments\test.txt"</pre><pre>myMail.Send</pre><pre>set myMail=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p>Sending a text e-mail using a remote server:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Set myMail=CreateObject("CDO.Message")</pre><pre>myMail.Subject="Sending email with CDO"</pre><pre>myMail.From="mymail@mydomain.com"</pre><pre>myMail.To="someone@somedomain.com"</pre><pre>myMail.TextBody="This is a message."</pre><pre>myMail.Configuration.Fields.Item _</pre><pre>("http://schemas.microsoft.com/cdo/configuration/sendusing")=2</pre><pre>'Name or IP of remote SMTP server</pre><pre>myMail.Configuration.Fields.Item _</pre><pre>("http://schemas.microsoft.com/cdo/configuration/smtpserver") _</pre><pre>="smtp.server.com"</pre><pre>'Server port</pre><pre>myMail.Configuration.Fields.Item _</pre><pre>("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _</pre><pre>=25 </pre><pre>myMail.Configuration.Fields.Update</pre><pre>myMail.Send</pre><pre>set myMail=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The ASP Response object is used to send output to the user from the server.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_text" target="_blank">Write text with ASP</a>
<br />This example demonstrates how to write text with ASP. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_formatting" target="_blank">Format text with HTML tags in ASP</a>
<br />This example demonstrates how to combine text and HTML tags with ASP. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_redirect" target="_blank">Redirect the user to a different URL</a>
<br />This example demonstrates how to redirect the user to a different URL. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_randomlink" target="_blank">Show a random link</a>
<br />This example demonstrates a link, each time you load the page, it will display one of two links: W3Schools.com! OR Refsnesdata.no! There is a 50% chance for each of them. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_buffer" target="_blank">Controlling the buffer</a>
<br />This example demonstrates how you can control the buffer. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_bufferclear" target="_blank">Clear the buffer</a>
<br />This example demonstrates how you can clear the buffer. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_end" target="_blank">End a script in the middle of processing and return the result</a>
<br />This example demonstrates how to end a script in the middle of processing. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_expires" target="_blank">Set how many minutes a page will be cached in a browser before it expires</a>
<br />This example demonstrates how to specify how many minutes a page will be cached in a browser before it expires. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_expiresabs" target="_blank">Set a date/time when a page cached in a browser will expire</a>
<br />This example demonstrates how to specify a date/time a page cached in a browser will expire. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_isclientconnected" target="_blank">Check if the user is still connected to the server</a>
<br />This example demonstrates how to check if a user is disconnected from the server. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_contenttype" target="_blank">Set the type of content</a>
<br />This example demonstrates how to specify the type of content. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_charset" target="_blank">Set the name of the character set</a>
<br />This example demonstrates how to specify the name of the character set. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Response Object</h2> <p>The ASP Response object is used to send output to the user from the server. Its collections, properties, and methods are described below:</p> <h3>Collections</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Collection<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_cookies.asp">Cookies</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets a cookie value. If the cookie does not exist, it will be created, and take the value that is specified</p> </td> </tr> </tbody></table> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_buffer.asp">Buffer</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies whether to buffer the page output or not</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_cachecontrol.asp">CacheControl</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets whether a proxy server can cache the output generated by ASP or not</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_charset.asp">Charset</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Appends the name of a character-set to the content-type header in the Response object</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_contenttype.asp">ContentType</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the HTTP content type for the Response object</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_expires.asp">Expires</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets how long (in minutes) a page will be cached on a browser before it expires</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_expiresabsolute.asp">ExpiresAbsolute</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets a date and time when a page cached on a browser will expire</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_isclientconnected.asp">IsClientConnected</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Indicates if the client has disconnected from the server</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_pics.asp">Pics</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Appends a value to the PICS label response header</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_status.asp">Status</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies the value of the status line returned by the server</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_addheader.asp">AddHeader</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds a new HTTP header and a value to the HTTP response</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_appendtolog.asp">AppendToLog</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds a string to the end of the server log entry</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_binarywrite.asp">BinaryWrite</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Writes data directly to the output without any character conversion</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_clear.asp">Clear</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Clears any buffered HTML output</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_end.asp">End</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Stops processing a script, and returns the current result</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_flush.asp">Flush</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sends buffered HTML output immediately</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_redirect.asp">Redirect</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Redirects the user to a different URL</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_response_write.asp">Write</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Writes a specified string to the output</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The ASP Request object is used to get information from the user.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>QueryString Collection Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_simplequerystring" target="_blank">Send query information when a user clicks on a link</a>
<br />This example demonstrates how to send some extra query information to a page within a link, and retrieve that information on the destination page (which is, in this example, the same page).</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_simplereqquery" target="_blank">A QueryString collection in its simplest use</a>
<br />This example demonstrates how the <b>QueryString </b>collection retrieves the values from a form. The form uses the GET method, which means that the information sent is visible to everybody (in the address field). The GET method also limits the amount of information that can be sent.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_reqquery" target="_blank">How to use information from forms</a>
<br />This example demonstrates how to use the values retrieved from a form. We use the <b>QueryString </b>collection. The form uses the get method.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_reqquery2" target="_blank">More information from a form</a>
<br />This example demonstrates what the <b>QueryString </b>contains if several input fields have the same name. It shows how to separate input fields with equal names from each other. It also shows how to use the <b>Count</b> keyword to count the "name" property. The form uses the get method.</p> <h2>Form Collection Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_simpleform1" target="_blank">A form collection in its simplest use</a>
<br />This example demonstrates how the <b>Form</b> collection retrieves the values from a form. The form uses the POST method, which means that the information sent is invisible to others, and it has no limits (you can send a large amount of information).</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_simpleform" target="_blank">How to use information from forms</a>
<br />This example demonstrates how to use the values retrieved from a form. We use the <b>Form </b>collection. The form uses the post method.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_form2" target="_blank">More information from a form</a>
<br />This example demonstrates what the <b>Form </b>collection contains if several input fields have the same name. It shows how to separate input fields with equal names from each other. It also shows how to use the <b>Count</b> keyword to count the "name" property. The form uses the post method.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_radiob" target="_blank">A form with radio buttons</a>
<br />This example demonstrates how to interact with the user through radio buttons, with the <b>Form</b> collection. The form uses the post method.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_checkboxes" target="_blank">A form with checkboxes</a>
<br />This example demonstrates how to interact with the user through checkboxes, with the <b>Form</b> collection. The form uses the post method.</p> <h2>Other Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_server" target="_blank">Get the server variables</a>
<br />This example demonstrates how to find out the visitors (yours) browser type, IP address, and more with the <b>ServerVariables</b> collection. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_cookies" target="_blank">Create a welcome cookie</a>
<br />This example demonstrates how to create a Welcome Cookie with the <b>Cookies</b> Collection.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_totalbytes" target="_blank">Find the total number of bytes the user sent</a>
<br />This example demonstrates how to use the <b>TotalBytes</b> property to find out the total number of bytes the user sent in the Request object.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Request Object</h2> <p>When a browser asks for a page from a server, it is called a request. The ASP Request object is used to get information from the user. Its collections, properties, and methods are described below:</p> <h3>Collections</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Collection<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ClientCertificate</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the field values stored in the client certificate</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_cookies.asp">Cookies</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the cookie values sent in a HTTP request</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_form.asp">Form</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the form (input) values from a form that uses the post method</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_querystring.asp">QueryString</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the variable values in a HTTP query string</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_servervariables.asp">ServerVariables</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the server variable values</p> </td> </tr> </tbody></table> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_totalbytes.asp">TotalBytes</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the total number of bytes the client sent in the body of the request</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_binaryread.asp">BinaryRead</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Retrieves the data sent to the server from the client as part of a post request and stores it in a safe array</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">A group of ASP files that work together to perform some purpose is called an application. The Application object in ASP is used to tie these files together.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Application Object</h2> <p>An application on the Web may be a group of ASP files. The ASP files work together to perform some purpose. The Application object in ASP is used to tie these files together.</p> <p>The Application object is used to store and access variables from any page, just like the Session object. The difference is that ALL users share one Application object, while with Sessions there is one Session object for EACH user.</p> <p>The Application object should hold information that will be used by many pages in the application (like database connection information). This means that you can access the information from any page. It also means that you can change the information in one place and the changes will automatically be reflected on all pages.</p> <p>The Application object's collections, methods, and events are described below:</p> <h3>Collections</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 30%;" valign="top" width="30%"> <p class="MsoNormal"><b>Collection<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 70%;" valign="top" width="70%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_contents.asp">Contents</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the items appended to the application through a script command</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_staticobjects.asp">StaticObjects</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the objects appended to the application with the HTML <object> tag</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 30%;" valign="top" width="30%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 70%;" valign="top" width="70%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_contents_remove.asp">Contents.Remove</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes an item from the Contents collection</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_contents_removeall.asp">Contents.RemoveAll()</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes all items from the Contents collection</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_lock_unlock.asp">Lock</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Prevents other users from modifying the variables in the Application object</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_lock_unlock.asp">Unlock</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Enables other users to modify the variables in the Application object (after it has been locked using the Lock method)</p> </td> </tr> </tbody></table> <h3>Events</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 30%;" valign="top" width="30%"> <p class="MsoNormal"><b>Event<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 70%;" valign="top" width="70%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/ev_app_onend_onstart.asp">Application_OnEnd</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Occurs when all user sessions are over, and the application ends</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/ev_app_onend_onstart.asp">Application_OnStart</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Occurs before the first new session is created (when the Application object is first referenced)</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The Session object is used to store information about, or change settings for a user session. Variables stored in the Session object hold information about one single user, and are available to all pages in one application.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_lcid" target="_blank">Set and return the LCID</a>
<br />This example demonstrates the "LCID" property. This property sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_sessionid" target="_blank">Return the SessionID</a>
<br />This example demonstrates the "SessionID" property. This property returns a unique id for each user. The id is generated by the server.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_gettimeout" target="_blank">A session's timeout</a>
<br />This example demonstrates the "Timeout" property. This example sets and returns the timeout (in minutes) for the session.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Session Object</h2> <p>When you are working with an application, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web server does not know who you are and what you do because the HTTP address doesn't maintain state. </p> <p>ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the client and it contains information that identifies the user. This interface is called the Session object. </p> <p>The Session object is used to store information about, or change settings for a user session. Variables stored in the Session object hold information about one single user, and are available to all pages in one application. Common information stored in session variables are name, id, and preferences. The server creates a new Session object for each new user, and destroys the Session object when the session expires. </p> <p>The Session object's collections, properties, methods, and events are described below:</p> <h3>Collections</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 32%;" valign="top" width="32%"> <p class="MsoNormal"><b>Collection<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 68%;" valign="top" width="68%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_contents.asp">Contents</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the items appended to the session through a script command</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_staticobjects.asp">StaticObjects</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Contains all the objects appended to the session with the HTML <object> tag</p> </td> </tr> </tbody></table> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 32%;" valign="top" width="32%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 68%;" valign="top" width="68%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_codepage.asp">CodePage</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies the character set that will be used when displaying dynamic content</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_lcid.asp">LCID</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_sessionid.asp">SessionID</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a unique id for each user. The unique id is generated by the server</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_timeout.asp">Timeout</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the timeout period (in minutes) for the Session object in this application</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 32%;" valign="top" width="32%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 68%;" valign="top" width="68%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_abandon.asp">Abandon</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Destroys a user session</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_contents_remove.asp">Contents.Remove</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes an item from the Contents collection</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_contents_removeall.asp">Contents.RemoveAll()</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes all items from the Contents collection</p> </td> </tr> </tbody></table> <h3>Events</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 32%;" valign="top" width="32%"> <p class="MsoNormal"><b>Event<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 68%;" valign="top" width="68%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/ev_sess_onend_onstart.asp">Session_OnEnd</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Occurs when a session ends</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/ev_sess_onend_onstart.asp">Session_OnStart</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Occurs when a session starts </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The ASP Server object is used to access properties and methods on the server.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_lastmodified" target="_blank">When was a file last modified?</a>
<br />Checks when this file was last modified.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_textstream" target="_blank">Open a text file for reading</a>
<br />This example opens the file "Textfile.txt" for reading.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_hitcounter" target="_blank">Homemade hit counter</a>
<br />This example reads a number from a file, adds 1 to the number, and writes the number back to the file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Server Object</h2> <p>The ASP Server object is used to access properties and methods on the server. Its properties and methods are described below:</p> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_scripttimeout.asp">ScriptTimeout</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the maximum number of seconds a script can run before it is terminated</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_server_createobject.asp">CreateObject</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Creates an instance of an object</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_execute.asp">Execute</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Executes an ASP file from inside another ASP file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getlasterror.asp">GetLastError()</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns an ASPError object that describes the error condition that occurred</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_htmlencode.asp">HTMLEncode</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Applies HTML encoding to a specified string</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_mappath.asp">MapPath</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Maps a specified path to a physical path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_transfer.asp">Transfer</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sends (transfers) all the information created in one ASP file to a second ASP file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_urlencode.asp">URLEncode</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Applies URL encoding rules to a specified string</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The ASPError object is used to display detailed information of any error that occurs in scripts in an ASP page.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The ASPError Object</h2> <p>The ASPError object was implemented in ASP 3.0 and is available in IIS5 and later.</p> <p>The ASPError object is used to display detailed information of any error that occurs in scripts in an ASP page. The ASPError object is created when Server.GetLastError is called, so the error information can only be accessed by using the Server.GetLastError method.</p> <p>The ASPError object's properties are described below (all properties are read-only): </p> <p><b>Note:</b> The properties below can only be accessed through the Server.GetLastError() method. </p> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">ASPCode</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns an error code generated by IIS</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">ASPDescription</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a detailed description of the error (if the error is ASP-related)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">Category</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the source of the error (was the error generated by ASP? By a scripting language? By an object?)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">Column</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the column position within the file that generated the error</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">Description</a></p> </td> <td style="padding: 2.25pt;"> <p class="MsoNormal">Returns a short description of the error</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">File</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the name of the ASP file that generated the error</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">Line</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the line number where the error was detected</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">Number</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the standard COM error code for the error</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_asperrorobject.asp">Source</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p>Returns the actual source code of the line where the error occurred</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The FileSystemObject object is used to access the file system on the server.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_fileexists" target="_blank">Does a specified file exist?</a>
<br />This example demonstrates how to first create a FileSystemObject Object, and then use the FileExists method to check if the file exists.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_folderexists" target="_blank">Does a specified folder exist?</a>
<br />This example demonstrates how to use the FolderExists method to check if a folder exists.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_driveexists" target="_blank">Does a specified drive exist?</a>
<br />This example demonstrates how to use the DriveExists method to check if a drive exists.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_getdrivename" target="_blank">Get the name of a specified drive</a>
<br />This example demonstrates how to use the GetDriveName method to get the name of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_getparentfoldername" target="_blank">Get the name of the parent folder of a specified path</a>
<br />This example demonstrates how to use the GetParentFolderName method to get the name of the parent folder of a specified path.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_getextensionname" target="_blank">Get the file extension</a>
<br />This example demonstrates how to use the GetExtensionName method to get the file extension of the last component in a specified path.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_getfilename" target="_blank">Get file name</a>
<br />This example demonstrates how to use the GetFileName method to get the file name of the last component in a specified path.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_getbasename" target="_blank">Get the base name of a file or folder</a>
<br />This example demonstrates how to use the GetBaseName method to return the base name of the file or folder, in a specified path.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The FileSystemObject Object</h2> <p>The FileSystemObject object is used to access the file system on the server. This object can manipulate files, folders, and directory paths. It is also possible to retrieve file system information with this object.</p> <p>The following code creates a text file (c:\test.txt) and then writes some text to the file:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim fs,fname
<br /> set fs=Server.CreateObject("Scripting.FileSystemObject")
<br /> set fname=fs.CreateTextFile("c:\test.txt",true)
<br /> fname.WriteLine("Hello World!")
<br /> fname.Close
<br /> set fname=nothing
<br /> set fs=nothing
<br /> %></p> </td> </tr> </tbody></table> <p class="MsoNormal">
<br />The FileSystemObject object's properties and methods are described below: </p> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 32%;" valign="top" width="32%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 68%;" valign="top" width="68%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_drives.asp">Drives</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a collection of all Drive objects on the computer</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 32%;" valign="top" width="32%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 68%;" valign="top" width="68%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_buildpath.asp">BuildPath</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Appends a name to an existing path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_copyfile.asp">CopyFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Copies one or more files from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_copyfolder.asp">CopyFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Copies one or more folders from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_createfolder.asp">CreateFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Creates a new folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_createtextfile.asp">CreateTextFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Creates a text file and returns a TextStream object that can be used to read from, or write to the file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_deletefile.asp">DeleteFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes one or more specified files</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_deletefolder.asp">DeleteFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes one or more specified folders</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_driveexists.asp">DriveExists</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Checks if a specified drive exists</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_fileexists.asp">FileExists</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Checks if a specified file exists</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_folderexists.asp">FolderExists</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Checks if a specified folder exists</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getabsolutepathname.asp">GetAbsolutePathName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the complete path from the root of the drive for the specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getbasename.asp">GetBaseName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the base name of a specified file or folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getdrive.asp">GetDrive</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a Drive object corresponding to the drive in a specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getdrivename.asp">GetDriveName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the drive name of a specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getextensionname.asp">GetExtensionName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the file extension name for the last component in a specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getfile.asp">GetFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a File object for a specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getfilename.asp">GetFileName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the file name or folder name for the last component in a specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getfolder.asp">GetFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a Folder object for a specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getparentfoldername.asp">GetParentFolderName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the name of the parent folder of the last component in a specified path</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_getspecialfolder.asp">GetSpecialFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the path to some of Windows' special folders</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_gettempname.asp">GetTempName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a randomly generated temporary file or folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_movefile.asp">MoveFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Moves one or more files from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_movefolder.asp">MoveFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Moves one or more folders from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_opentextfile.asp">OpenTextFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Opens a file and returns a TextStream object that can be used to access the file</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The TextStream object is used to access the contents of a text file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_readtextfile" target="_blank">Read textfile</a>
<br />This example demonstrates how to use the OpenTextFile method of the FileSystemObject to create a TextStream Object. The ReadAll method of the TextStream Object reads from the opened text file. </p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_readpartoftextfile" target="_blank">Read only a part of a textfile</a>
<br />This example demonstrates how to only read a part of a TextStream file.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_readline" target="_blank">Read one line of a textfile</a>
<br />This example demonstrates how to read one line from a TextStream file.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_readlines" target="_blank">Read all lines from a textfile</a>
<br />This example demonstrates how to read all the lines from a TextStream file.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_skip" target="_blank">Skip a part of a textfile</a>
<br />This example demonstrates how to skip a specified number of characters when reading the TextStream file.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_skipline" target="_blank">Skip a line of a textfile</a>
<br />This example demonstrates how to skip a line when reading the TextStream file.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_line" target="_blank">Return line-number</a>
<br />This example demonstrates how to return the current line number in a TextStream file.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_column" target="_blank">Get column number</a>
<br />This example demonstrates how to get the column number of the current character in a file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The TextStream Object</h2> <p>The TextStream object is used to access the contents of text files.</p> <p>The following code creates a text file (c:\test.txt) and then writes some text to the file (the variable f is an instance of the TextStream object):</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><% </pre><pre>dim fs, f </pre><pre>set fs=Server.CreateObject("Scripting.FileSystemObject") </pre><pre>set f=fs.CreateTextFile("c:\test.txt",true) </pre><pre>f.WriteLine("Hello World!")</pre><pre>f.Close</pre><pre>set f=nothing</pre><pre>set fs=nothing</pre><pre>%></pre></td> </tr> </tbody></table> <p>To create an instance of the TextStream object you can use the CreateTextFile or OpenTextFile methods of the FileSystemObject object, or you can use the OpenAsTextStream method of the File object. </p> <p>The TextStream object's properties and methods are described below:</p> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_atendofline.asp">AtEndOfLine</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns true if the file pointer is positioned immediately before the end-of-line marker in a TextStream file, and false if not</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_atendofstream.asp">AtEndOfStream</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns true if the file pointer is at the end of a TextStream file, and false if not</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_column.asp">Column</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the column number of the current character position in an input stream</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_line.asp">Line</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the current line number in a TextStream file</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_close.asp">Close</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Closes an open TextStream file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_read.asp">Read</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Reads a specified number of characters from a TextStream file and returns the result</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_readall.asp">ReadAll</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Reads an entire TextStream file and returns the result</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_readline.asp">ReadLine</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Reads one line from a TextStream file and returns the result</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_skip.asp">Skip</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Skips a specified number of characters when reading a TextStream file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_skipline.asp">SkipLine</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Skips the next line when reading a TextStream file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_write.asp">Write</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Writes a specified text to a TextStream file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_writeline.asp">WriteLine</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Writes a specified text and a new-line character to a TextStream file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_writeblanklines.asp">WriteBlankLines</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Writes a specified number of new-line character to a TextStream file</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The Drive object is used to return information about a local disk drive or a network share.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_availablespace" target="_blank">Get the available space of a specified drive</a>
<br />This example demonstrates how to first create a FileSystemObject object, and then use the AvailableSpace property to get the available space of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_freespace" target="_blank">Get the free space of a specified drive</a>
<br />This example demonstrates how to use the FreeSpace property to get the free space of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_totalsize" target="_blank">Get the total size of a specified drive</a>
<br />This example demonstrates how to use the TotalSize property to get the total size of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_driveletter" target="_blank">Get the drive letter of a specified drive</a>
<br />This example demonstrates how to use the DriveLetter property to get the drive letter of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_drivetype" target="_blank">Get the drive type of a specified drive</a>
<br />This example demonstrates how to use the DriveType property to get the drive type of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_filesystem" target="_blank">Get the file system of a specified drive</a>
<br />This example demonstrates how to use the FileSystem property to get the file system of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_isready" target="_blank">Is the drive ready?</a>
<br />This example demonstrates how to use the IsReady property to check whether a specified drive is ready.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_path" target="_blank">Get the path of a specified drive</a>
<br />This example demonstrates how to use the Path property to get the path of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_rootfolder" target="_blank">Get the root folder of a specified drive</a>
<br />This example demonstrates how to use the RootFolder property to get the root folder of a specified drive.</p> <p><a href="http://www.w3schools.com/asp/showfile.asp?filename=demo_serialnumber" target="_blank">Get the serialnumber of a specified drive</a>
<br />This example demonstrates how to use the Serialnumber property to get the serialnumber of a specified drive.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Drive Object</h2> <p>The Drive object is used to return information about a local disk drive or a network share. The Drive object can return information about a drive's type of file system, free space, serial number, volume name, and more.</p> <p><b>Note:</b> You cannot return information about a drive's content with the Drive object. For this purpose you will have to use the Folder object.</p> <p>To work with the properties of the Drive object, you will have to create an instance of the Drive object through the FileSystemObject object. First; create a FileSystemObject object and then instantiate the Drive object through the GetDrive method or the Drives property of the FileSystemObject object.</p> <p>The following example uses the GetDrive method of the FileSystemObject object to instantiate the Drive object and the TotalSize property to return the total size in bytes of the specified drive (c:):</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Dim fs,d</pre><pre>Set fs=Server.CreateObject("Scripting.FileSystemObject")</pre><pre>Set d=fs.GetDrive("c:")</pre><pre>Response.Write("Drive " & d & ":")</pre><pre>Response.Write("Total size in bytes: " & d.TotalSize)</pre><pre>set d=nothing</pre><pre>set fs=nothing</pre><pre>%></pre> <p>Output:</p> <p>Drive c: Total size in bytes: 4293563392</p> </td> </tr> </tbody></table> <p>The Drive object's properties are described below:</p> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_availablespace.asp">AvailableSpace</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the amount of available space to a user on a specified drive or network share</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_driveletter.asp">DriveLetter</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns one uppercase letter that identifies the local drive or a network share</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_drivetype.asp">DriveType</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the type of a specified drive</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_filesystem.asp">FileSystem</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the file system in use for a specified drive</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_freespace.asp">FreeSpace</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the amount of free space to a user on a specified drive or network share</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_isready.asp">IsReady</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns true if the specified drive is ready and false if not</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_path.asp">Path</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns an uppercase letter followed by a colon that indicates the path name for a specified drive</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_rootfolder.asp">RootFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a Folder object that represents the root folder of a specified drive</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_serialnumber.asp">SerialNumber</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the serial number of a specified drive</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_sharename.asp">ShareName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the network share name for a specified drive</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_totalsize.asp">TotalSize</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the total size of a specified drive or network share</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_volumename.asp">VolumeName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the volume name of a specified drive</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The File object is used to return information about a specified file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_datecreated" target="_blank">When was the file created?</a>
<br />This example demonstrates how to first create a FileSystemObject object, and then use the DateCreated property of the File object to get the date and time a specified file was created.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_datelastmodified" target="_blank">When was the file last modified?</a>
<br />This example demonstrates how to use the DateLastModified property to get the date and time a specified file was last modified.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_datelastaccessed" target="_blank">When was the file last accessed?</a>
<br />This example demonstrates how to use the DateLastAccessed property to get the date and time a specified file was last accessed.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_attributes" target="_blank">Return the attributes of a specified file</a>
<br />This example demonstrates how to use the Attributes property to return the attributes of a specified file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The File Object</h2> <p>The File object is used to return information about a specified file.</p> <p>To work with the properties and methods of the File object, you will have to create an instance of the File object through the FileSystemObject object. First; create a FileSystemObject object and then instantiate the File object through the GetFile method of the FileSystemObject object or through the Files property of the Folder object.</p> <p>The following code uses the GetFile method of the FileSystemObject object to instantiate the File object and the DateCreated property to return the date when the specified file was created:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Dim fs,f</pre><pre>Set fs=Server.CreateObject("Scripting.FileSystemObject")</pre><pre>Set f=fs.GetFile("c:\test.txt")</pre><pre>Response.Write("File created: " & f.DateCreated)</pre><pre>set f=nothing</pre><pre>set fs=nothing</pre><pre>%></pre> <p>Output:</p> <pre>File created: <st1:date month="9" day="19" year="2001" st="on">9/19/2001</st1:date> 10:01:19 AM</pre></td> </tr> </tbody></table> <p>The File object's properties and methods are described below:</p> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 28%;" valign="top" width="28%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 72%;" valign="top" width="72%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_attributes.asp">Attributes</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the attributes of a specified file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datecreated.asp">DateCreated</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified file was created</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datelastaccessed.asp">DateLastAccessed</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified file was last accessed</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datelastmodified.asp">DateLastModified</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified file was last modified</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_drive.asp">Drive</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the drive letter of the drive where a specified file or folder resides</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_name.asp">Name</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the name of a specified file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_parentfolder.asp">ParentFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the folder object for the parent of the specified file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_path.asp">Path</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the path for a specified file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_shortname.asp">ShortName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the short name of a specified file (the 8.3 naming convention)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_shortpath.asp">ShortPath</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the short path of a specified file (the 8.3 naming convention)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_size.asp">Size</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the size, in bytes, of a specified file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_type.asp">Type</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the type of a specified file</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 28%;" valign="top" width="28%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 72%;" valign="top" width="72%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_copy.asp">Copy</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Copies a specified file from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_delete.asp">Delete</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes a specified file</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_move.asp">Move</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Moves a specified file from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_openastextstream.asp">OpenAsTextStream</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Opens a specified file and returns a TextStream object to access the file</p> </td> </tr> </tbody></table> <p class="intro">The Folder Object is used to return information about a specified folder.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Folder Object</h2> <p>The Folder object is used to return information about a specified folder.</p> <p>To work with the properties and methods of the Folder object, you will have to create an instance of the Folder object through the FileSystemObject object. First; create a FileSystemObject object and then instantiate the Folder object through the GetFolder method of the FileSystemObject object.</p> <p>The following code uses the GetFolder method of the FileSystemObject object to instantiate the Folder object and the DateCreated property to return the date when the specified folder was created:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Dim fs,fo</pre><pre>Set fs=Server.CreateObject("Scripting.FileSystemObject")</pre><pre>Set fo=fs.GetFolder("c:\test")</pre><pre>Response.Write("Folder created: " & fo.DateCreated)</pre><pre>set fo=nothing</pre><pre>set fs=nothing</pre><pre>%></pre> <p>Output:</p> <pre>Folder created: <st1:date month="10" day="22" year="2001" st="on">10/22/2001</st1:date> 10:01:19 AM</pre></td> </tr> </tbody></table> <p>The Folder object's collections, properties, and methods are described below: </p> <h3>Collections</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Collection<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_files.asp">Files</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a collection of all the files in a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_subfolders.asp">SubFolders</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a collection of all subfolders in a specified folder</p> </td> </tr> </tbody></table> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_attributes.asp">Attributes</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the attributes of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datecreated.asp">DateCreated</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified folder was created</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datelastaccessed.asp">DateLastAccessed</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified folder was last accessed</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datelastmodified.asp">DateLastModified</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified folder was last modified</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_drive.asp">Drive</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the drive letter of the drive where the specified folder resides</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_isrootfolder.asp">IsRootFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns true if a folder is the root folder and false if not</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_name.asp">Name</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the name of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_parentfolder.asp">ParentFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the parent folder of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_path.asp">Path</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the path for a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_shortname.asp">ShortName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the short name of a specified folder (the 8.3 naming convention)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_shortpath.asp">ShortPath</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the short path of a specified folder (the 8.3 naming convention)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_size.asp">Size</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the size of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_type.asp">Type</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the type of a specified folder</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_copy.asp">Copy</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Copies a specified folder from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_delete.asp">Delete</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_move.asp">Move</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Moves a specified folder from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_createtextfile.asp">CreateTextFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Creates a new text file in the specified folder and returns a TextStream object to access the file</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The Folder Object is used to return information about a specified folder.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Folder Object</h2> <p>The Folder object is used to return information about a specified folder.</p> <p>To work with the properties and methods of the Folder object, you will have to create an instance of the Folder object through the FileSystemObject object. First; create a FileSystemObject object and then instantiate the Folder object through the GetFolder method of the FileSystemObject object.</p> <p>The following code uses the GetFolder method of the FileSystemObject object to instantiate the Folder object and the DateCreated property to return the date when the specified folder was created:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>Dim fs,fo</pre><pre>Set fs=Server.CreateObject("Scripting.FileSystemObject")</pre><pre>Set fo=fs.GetFolder("c:\test")</pre><pre>Response.Write("Folder created: " & fo.DateCreated)</pre><pre>set fo=nothing</pre><pre>set fs=nothing</pre><pre>%></pre> <p>Output:</p> <pre>Folder created: <st1:date month="10" day="22" year="2001" st="on">10/22/2001</st1:date> 10:01:19 AM</pre></td> </tr> </tbody></table> <p>The Folder object's collections, properties, and methods are described below: </p> <h3>Collections</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Collection<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_files.asp">Files</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a collection of all the files in a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/coll_subfolders.asp">SubFolders</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns a collection of all subfolders in a specified folder</p> </td> </tr> </tbody></table> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_attributes.asp">Attributes</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the attributes of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datecreated.asp">DateCreated</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified folder was created</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datelastaccessed.asp">DateLastAccessed</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified folder was last accessed</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_datelastmodified.asp">DateLastModified</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the date and time when a specified folder was last modified</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_drive.asp">Drive</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the drive letter of the drive where the specified folder resides</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_isrootfolder.asp">IsRootFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns true if a folder is the root folder and false if not</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_name.asp">Name</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets or returns the name of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_parentfolder.asp">ParentFolder</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the parent folder of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_path.asp">Path</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the path for a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_shortname.asp">ShortName</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the short name of a specified folder (the 8.3 naming convention)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_shortpath.asp">ShortPath</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the short path of a specified folder (the 8.3 naming convention)</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_size.asp">Size</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the size of a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/prop_type.asp">Type</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the type of a specified folder</p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 75%;" valign="top" width="75%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_copy.asp">Copy</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Copies a specified folder from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_delete.asp">Delete</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Deletes a specified folder</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_move.asp">Move</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Moves a specified folder from one location to another</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/met_createtextfile.asp">CreateTextFile</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Creates a new text file in the specified folder and returns a TextStream object to access the file</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro"><st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> can be used to access databases from your web pages.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Accessing a Database from an ASP Page</h2> <p>The common way to access a database from inside an ASP page is to:</p> <ol start="1" type="1"><li class="MsoNormal" style="">Create an <st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> connection to a database </li><li class="MsoNormal" style="">Open the database connection </li><li class="MsoNormal" style="">Create an <st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> recordset </li><li class="MsoNormal" style="">Open the recordset </li><li class="MsoNormal" style="">Extract the data you need from the recordset </li><li class="MsoNormal" style="">Close the recordset </li><li class="MsoNormal" style="">Close the connection </li></ol> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>What is <st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city>?</h2> <ul type="disc"><li class="MsoNormal" style=""><st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> is a Microsoft technology </li><li class="MsoNormal" style=""><st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> stands for <b>A</b>ctiveX <b>D</b>ata <b>O</b>bjects </li><li class="MsoNormal" style=""><st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> is a Microsoft Active-X component </li><li class="MsoNormal" style=""><st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> is automatically installed with Microsoft IIS </li><li class="MsoNormal" style=""><st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city> is a programming interface to access data in a database </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Where to go next?</h2> <p>If you want to study more <st1:city st="on"><st1:place st="on">ADO</st1:place></st1:city>, read our <a href="http://www.w3schools.com/ado/default.asp">ADO tutorial</a>.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_adrotator" target="_blank">Simple AdRotator Example</a>
<br />This example shows how to use the AdRotator component to display a different advertisement image, each time a user visits or refreshes the page.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_adrotator2" target="_blank">AdRotator - The Images are Hyperlinks</a>
<br />This example shows how to use the AdRotator component to display a different advertisement image, each time a user visits or refreshes the page. In addition, the images are hyperlinks.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>ASP AdRotator Component</h2> <p>The ASP AdRotator component creates an AdRotator object that displays a different image each time a user enters or refreshes a page. A text file includes information about the images.</p> <h3>Syntax</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> set adrotator=server.createobject("MSWC.AdRotator")
<br /> adrotator.GetAdvertisement("textfile.txt")
<br /> %></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Example</h2> <p>Assume we have a file called "banners.asp". It looks like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><html>
<br /> <body>
<br /> <%
<br /> set adrotator=Server.CreateObject("MSWC.AdRotator")
<br /> response.write(adrotator.GetAdvertisement("ads.txt"))
<br /> %>
<br /> </body>
<br /> </html></p> </td> </tr> </tbody></table> <p>The file "ads.txt" looks like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">*
<br /> w3schools.gif
<br /> http://www.w3schools.com/
<br /> Visit W3Schools
<br /> 80
<br /> microsoft.gif
<br /> http://www.microsoft.com/
<br /> Visit Microsoft
<br /> 20 </p> </td> </tr> </tbody></table> <p>The lines below the asterisk in the file "ads.txt" specifies the images to be displayed, the hyperlink addresses, the alternate text (for the images), and the display rates in percent of the hits. We see that the W3Schools image will be displayed for 80 % of the hits and the Microsoft image will be displayed for 20 % of the hits in the text file above.</p> <p><b>Note:</b> To get the links to work when a user clicks on them, we will have to modify the file "ads.txt" a bit:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">REDIRECT banners.asp
<br /> *
<br /> w3schools.gif
<br /> http://www.w3schools.com/
<br /> Visit W3Schools
<br /> 80
<br /> microsoft.gif
<br /> http://www.microsoft.com/
<br /> Visit Microsoft
<br /> 20 </p> </td> </tr> </tbody></table> <p>The redirection page (banners.asp) will now receive a querystring with a variable named URL containing the URL to redirect to.</p> <p><b>Note:</b> To specify the height, width, and border of the image, you can insert the following lines under REDIRECT:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">REDIRECT banners.asp
<br /> WIDTH 468
<br /> HEIGHT 60
<br /> BORDER 0
<br /> *
<br /> w3schools.gif
<br /> ...
<br /> ... </p> </td> </tr> </tbody></table> <p>The last thing to do is to add some lines of code to the "banners.asp" file:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> url=Request.QueryString("url")
<br /> If url<>"" then Response.Redirect(url)
<br /> %> </p> <p><html>
<br /> <body>
<br /> <%
<br /> set adrotator=Server.CreateObject("MSWC.AdRotator")
<br /> response.write(adrotator.GetAdvertisement("textfile.txt"))
<br /> %>
<br /> </body>
<br /> </html></p> </td> </tr> </tbody></table> <p>That's all!!</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h3>Properties</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 55%;" valign="top" width="55%"> <p class="MsoNormal"><b>Example<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies the size of the borders around the advertisement</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> set adrot=Server.CreateObject("MSWC.AdRotator")
<br /> adrot.Border="2"
<br /> Response.Write(adrot.GetAdvertisement("ads.txt"))
<br /> %></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Clickable</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies whether the advertisement is a hyperlink</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> set adrot=Server.CreateObject("MSWC.AdRotator")
<br /> adrot.Clickable=false
<br /> Response.Write(adrot.GetAdvertisement("ads.txt"))
<br /> %></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">TargetFrame</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Name of the frame to display the advertisement</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> set adrot=Server.CreateObject("MSWC.AdRotator")
<br /> adrot.TargetFrame="target='_blank'"
<br /> Response.Write(adrot.GetAdvertisement("ads.txt"))
<br /> %></p> </td> </tr> </tbody></table> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 55%;" valign="top" width="55%"> <p class="MsoNormal"><b>Example<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetAdvertisement</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns HTML that displays the advertisement in the page</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> set adrot=Server.CreateObject("MSWC.AdRotator")
<br /> Response.Write(adrot.GetAdvertisement("ads.txt"))
<br /> %></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_browsercap" target="_blank">The Browser Capabilities Component</a>
<br />This example shows how to determine the type, capabilities and version number of each browser visiting your site.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>ASP Browser Capabilities Component</h2> <p>The ASP Browser Capabilities component creates a BrowserType object that determines the type, capabilities and version number of each browser that visits your site.</p> <p>When a browser connects to a server, an HTTP User Agent Header is also sent to the server. This header contains information about the browser (like browser type and version number). The BrowserType object then compares the information in the header with information in a file on the server called "Browscap.ini".</p> <p>If there is a match between the browser type and version number sent in the header and the information in the "Browsercap.ini" file, you can use the BrowserType object to list the properties of the matching browser. If there is no match for the browser type and version number in the Browscap.ini file, it will set every property to "UNKNOWN".</p> <h3>Syntax</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> Set MyBrow=Server.CreateObject("MSWC.BrowserType")
<br /> %></p> </td> </tr> </tbody></table> <p>The example below creates a BrowserType object in an ASP file, and displays a table showing some of the capabilities of the current browser:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><html></pre><pre><body></pre><pre><%</pre><pre>Set MyBrow=Server.CreateObject("MSWC.BrowserType")</pre><pre>%></pre><pre><table border="1" width="100%"></pre><pre><tr></pre><pre><th>Client OS</th></pre><pre><th><%=MyBrow.platform%></th></pre><pre></tr><tr></pre><pre><td>Web Browser</td></pre><pre><td><%=MyBrow.browser%></td></pre><pre></tr><tr></pre><pre><td>Browser version</td></pre><pre><td><%=MyBrow.version%></td></pre><pre></tr><tr></pre><pre><td>Frame support?</td></pre><pre><td><%=MyBrow.frames%></td></pre><pre></tr><tr></pre><pre><td>Table support?</td></pre><pre><td><%=MyBrow.tables%></td></pre><pre></tr><tr></pre><pre><td>Sound support?</td></pre><pre><td><%=MyBrow.backgroundsounds%></td></pre><pre></tr><tr></pre><pre><td>Cookies support?</td></pre><pre><td><%=MyBrow.cookies%></td></pre><pre></tr><tr></pre><pre><td>VBScript support?</td></pre><pre><td><%=MyBrow.vbscript%></td></pre><pre></tr><tr></pre><pre><td>JavaScript support?</td></pre><pre><td><%=MyBrow.javascript%></td></pre><pre></tr></pre><pre></table></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p>Output:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Client OS<o:p></o:p></b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>WinNT<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">Web Browser</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">IE</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">Browser version</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">5.0</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">Frame support?</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">True</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">Table support?</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">True</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">Sound support?</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">True</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">Cookies support?</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">True</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">VBScript support?</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">True</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">JavaScript support?</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">True</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Browscap.ini File</h2> <p>The "Browsercap.ini" file is used to declare properties and to set default values for browsers.</p> <p>This section is not a tutorial on how to maintain "Browsercap.ini" files, it only shows you the basics; so you get an idea what a "Browsercap.ini" file is all about.</p> <p>The "Browsercap.ini" file can contain the following:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre>[;comments]</pre><pre>[HTTPUserAgentHeader] </pre><pre>[parent=browserDefinition]</pre><pre>[property1=value1]</pre><pre>[propertyN=valueN] </pre><pre>[Default Browser Capability Settings]</pre><pre>[defaultProperty1=defaultValue1]</pre><pre>[defaultPropertyN=defaultValueN]</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b>Parameter<o:p></o:p></b></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">comments</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Any line that starts with a semicolon are ignored by the BrowserType object</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">HTTPUserAgentHeader</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Specifies the HTTP User Agent header to associate with the browser-property value statements specified in propertyN. Wildcard characters are allowed</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">browserDefinition</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Specifies the HTTP User Agent header-string of a browser to use as the parent browser. The current browser's definition will inherit all of the property values declared in the parent browser's definition</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">propertyN</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Specifies the browser properties. The following table lists some possible properties: </p> <ul type="disc"><li class="MsoNormal" style="">ActiveXControls - Support ActiveX® controls? </li><li class="MsoNormal" style="">Backgroundsounds - Support background sounds? </li><li class="MsoNormal" style="">Cdf - Support Channel Definition Format for Webcasting? </li><li class="MsoNormal" style="">Tables - Support tables? </li><li class="MsoNormal" style="">Cookies - Support cookies? </li><li class="MsoNormal" style="">Frames - Support frames? </li><li class="MsoNormal" style="">Javaapplets - Support Java applets? </li><li class="MsoNormal" style="">Javascript - Supports JScript? </li><li class="MsoNormal" style="">Vbscript - Supports VBScript? </li><li class="MsoNormal" style="">Browser - Specifies the name of the browser </li><li class="MsoNormal" style="">Beta - Is the browser beta software? </li><li class="MsoNormal" style="">Platform - Specifies the platform that the browser runs on </li><li class="MsoNormal" style="">Version - Specifies the version number of the browser </li></ul> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">valueN</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Specifies the value of propertyN. Can be a string, an integer (prefix with #), or a Boolean value</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">defaultPropertyN</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Specifies the name of the browser property to which to assign a default value if none of the defined HTTPUserAgentHeader values match the HTTP User Agent header sent by the browser</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">defaultValueN</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Optional. Specifies the value of defaultPropertyN. Can be a string, an integer (prefix with #), or a Boolean value</p> </td> </tr> </tbody></table> <p>A "Browsercap.ini" file might look something like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre>;IE 5.0</pre><pre>[IE 5.0]</pre><pre>browser=IE</pre><pre>Version=5.0</pre><pre>majorver=#5</pre><pre>minorver=#0</pre><pre>frames=TRUE</pre><pre>tables=TRUE</pre><pre>cookies=TRUE</pre><pre>backgroundsounds=TRUE</pre><pre>vbscript=TRUE</pre><pre>javascript=TRUE</pre><pre>javaapplets=TRUE</pre><pre>ActiveXControls=TRUE</pre><pre>beta=False</pre><pre>;DEFAULT BROWSER</pre><pre>[*]</pre><pre>browser=Default</pre><pre>frames=FALSE </pre><pre>tables=TRUE </pre><pre>cookies=FALSE </pre><pre>backgroundsounds=FALSE </pre><pre>vbscript=FALSE </pre><pre>javascript=FALSE</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_contentlinking" target="_blank">The Content Linking Component</a>
<br />This example builds a table of contents.</p> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_contentlinking2" target="_blank">The Content Linking Component 2</a>
<br />The example uses the Content Linking Component to navigate between the pages in a text file.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>ASP Content Linking Component</h2> <p>The ASP Content Linking component is used to create a quick and easy navigation system!</p> <p>The Content Linking component returns a Nextlink object that is used to hold a list of Web pages to be navigated.</p> <h3>Syntax</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> Set nl=Server.CreateObject( "MSWC.NextLink" )
<br /> %></p> </td> </tr> </tbody></table> <p>First we create a text file - "links.txt". This file contains the pages to be navigated. The pages must be listed in the same order you want them to be displayed, and it also must contain a description for each file name (use the tab key to separate file name from description). <b>Note:</b> If you want to add a page to the list or change the order of the pages in the list; all you have to do is to modify the text file! The navigation will automatically be correct!</p> <p>"links.txt":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">asp_intro.asp ASP Intro
<br /> asp_syntax.asp ASP Syntax
<br /> asp_variables.asp ASP Variables
<br /> asp_procedures.asp ASP Procedures</p> </td> </tr> </tbody></table> <p>On each of the pages listed above, put one line of code: <!-- #include file="nlcode.inc"-->. This line will include the code below on every page listed in "links.txt" and the navigation will work.</p> <p>"nlcode.inc":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"><pre><%</pre><pre>'Use the Content Linking Component </pre><pre>'to navigate between the pages listed</pre><pre>'in links.txt</pre><pre>dim nl</pre><pre>Set nl=Server.CreateObject("MSWC.NextLink")</pre><pre>if (nl.GetListIndex("links.txt")>1) then</pre><pre><span style=""> </span>Response.Write("<a href="'"><pre><span style=""> </span>Response.Write("'>Previous Page</a>")</pre><pre>end if</pre><pre>Response.Write("<a href="'"><pre>Response.Write("'>Next Page</a>")</pre><pre>%></pre></td> </tr> </tbody></table> <p>The ASP Content Linking Component's methods are described below: </p> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 45%;" valign="top" width="45%"> <p class="MsoNormal"><b>Example<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetListCount</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the number of items listed in the Content Linking List file</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetListCount("links.txt")
<br /> Response.Write("There are ")
<br /> Response.Write(c)
<br /> Response.Write(" items in the list")
<br /> %> </p> <p>Output:</p> <p>There are 4 items in the list</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetListIndex</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the index number of the current item in the Content Linking List file. The index number of the first item is 1. 0 is returned if the current page is not in the Content Linking List file</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetListIndex("links.txt")
<br /> Response.Write("Item number ")
<br /> Response.Write(c)
<br /> %> </p> <p>Output:</p> <p>Item number 3</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetNextDescription</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the text description of the next item listed in the Content Linking List file. If the current page is not found in the list file it returns the text description of the last page on the list</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetNextDescription("links.txt")
<br /> Response.Write("Next ")
<br /> Response.Write("description is: ")
<br /> Response.Write(c)
<br /> %> </p> <p>Next description is: ASP Variables</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetNextURL</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the URL of the next item listed in the Content Linking List file. If the current page is not found in the list file it returns the URL of the last page on the list</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetNextURL("links.txt")
<br /> Response.Write("Next ")
<br /> Response.Write("URL is: ")
<br /> Response.Write(c)
<br /> %> </p> <p>Next URL is: asp_variables.asp</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetNthDescription</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the description of the Nth page listed in the Content Linking List file</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetNthDescription("links.txt",3)
<br /> Response.Write("Third ")
<br /> Response.Write("description is: ")
<br /> Response.Write(c)
<br /> %> </p> <p>Third description is: ASP Variables</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetNthURL</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the URL of the Nth page listed in the Content Linking List file</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetNthURL("links.txt",3)
<br /> Response.Write("Third ")
<br /> Response.Write("URL is: ")
<br /> Response.Write(c)
<br /> %> </p> <p>Third URL is: asp_variables.asp</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetPreviousDescription</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the text description of the previous item listed in the Content Linking List file. If the current page is not found in the list file it returns the text description of the first page on the list</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetPreviousDescription("links.txt")
<br /> Response.Write("Previous ")
<br /> Response.Write("description is: ")
<br /> Response.Write(c)
<br /> %> </p> <p>Previous description is: ASP Variables</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetPreviousURL</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Returns the URL of the previous item listed in the Content Linking List file. If the current page is not found in the list file it returns the URL of the first page on the list</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim nl,c
<br /> Set nl=Server.CreateObject("MSWC.NextLink")
<br /> c=nl.GetPreviousURL("links.txt")
<br /> Response.Write("Previous ")
<br /> Response.Write("URL is: ")
<br /> Response.Write(c)
<br /> %> </p> <p>Previous URL is: asp_variables.asp</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/asp/showasp.asp?filename=demo_contentrotator" target="_blank">The Content Rotator Component</a>
<br />This component displays a different HTML content string each time a user visits or refreshes the page.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>ASP Content Rotator Component</h2> <p>The ASP Content Rotator component creates a ContentRotator object that displays a different HTML content string each time a user enters or refreshes a page. A text file, called the Content Schedule File, includes the information about the content strings.</p> <p>The content strings can contain HTML tags so you can display any type of content that HTML can represent: text, images, colors, or hyperlinks.</p> <h3>Syntax</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> Set cr=Server.CreateObject( "MSWC.ContentRotator" )
<br /> %></p> </td> </tr> </tbody></table> <p>The following example displays a different content each time a user views the Web page. Create a text file named "textads.txt" in your default Web Site folder, in a subfolder called text.</p> <p>"textads.txt":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">%% #1
<br /> This is a great day!!
<br />
<br /> %% #2
<br /> <h1>Smile</h1>
<br />
<br /> %% #3
<br /> <img src="smiley.gif" />
<br />
<br /> %% #4
<br /> Here's a <a href="http://www.w3schools.com">link.</a></p> </td> </tr> </tbody></table> <p>Notice the #number at the beginning of each content string. This number is an optional parameter that indicates the relative weight of the HTML content string. In this example, the Content Rotator will display the first content string one-tenth of the time, the second string two-tenths of the time, the third string three-tenths of the time, and the fourth string four-tenths of the time. </p> <p>Then, create an ASP file, and insert the following code: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><html>
<br /> <body>
<br />
<br /> <%
<br /> set cr=server.createobject("MSWC.ContentRotator")
<br /> response.write(cr.ChooseContent("text/textads.txt"))
<br /> %>
<br />
<br /> </body>
<br /> </html></p> </td> </tr> </tbody></table> <p>The ASP Content Rotator Component's methods are described below: </p> <h3>Methods</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b>Method<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 50%;" valign="top" width="50%"> <p class="MsoNormal"><b>Example<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ChooseContent</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Gets and displays a content string</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim cr
<br /> Set cr=Server.CreateObject("MSWC.ContentRotator")
<br /> response.write(cr.ChooseContent("text/textads.txt"))
<br /> %> </p> <p>Output:
<br />
<br /> <!--[if gte vml 1]><v:shape id="_x0000_i1143" type="#_x0000_t75" alt="Smiley" style="'width:24pt;height:24pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image002.gif" href="http://www.w3schools.com/asp/smiley.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.gif" alt="Smiley" shapes="_x0000_i1143" border="0" width="32" height="32" /><!--[endif]--></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">GetAllContent</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Retrieves and displays all of the content strings in the text file</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><%
<br /> dim cr
<br /> Set cr=Server.CreateObject("MSWC.ContentRotator")
<br /> response.write(cr.GetAllContent("text/textads.txt"))
<br /> %> </p> <p>Output:</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p>This is a great day!! </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h1>Smile</h1> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p><!--[if gte vml 1]><v:shape id="_x0000_i1147" type="#_x0000_t75" alt="Smiley" style="'width:24pt;height:24pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image002.gif" href="http://www.w3schools.com/asp/smiley.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.gif" alt="Smiley" shapes="_x0000_i1147" border="0" width="32" height="32" /><!--[endif]--></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p>Here's a <a href="http://www.w3schools.com/">link.</a></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="MsoNormal"></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h1>ASP Quick Reference</h1> <p class="MsoNormal"><a href="http://www.w3schools.com/asp/asp_contentrotator.asp"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1151" type="#_x0000_t75" alt="Previous" style="'width:24pt;" button="t"><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image003.gif" alt="Previous" shapes="_x0000_i1151" border="0" width="32" height="32" /><!--[endif]--></span></a><a href="http://www.w3schools.com/asp/asp_summary.asp"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1152" type="#_x0000_t75" alt="Next" style="'width:75pt;height:15pt'" button="t"><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image004.gif" alt="Next" shapes="_x0000_i1152" border="0" width="100" height="20" /><!--[endif]--></span></a></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">ASP Quick Reference from W3Schools. Print it, and fold it in your pocket.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h3>Basic Syntax</h3> <p>ASP scripts are surrounded by <% and %>. To write some output to a browser:</p> <p><html>
<br /><body>
<br /><% response.write("Hello World!") %>
<br /></body>
<br /></html></p> <p>The default language in ASP is VBScript. To use another scripting language, insert a language specification at the top of the ASP page:</p> <p><%@ language="javascript" %>
<br /><html>
<br /><body></p> <p><%
<br />....
<br />%></p> <h3>Forms and User Input</h3> <p>Request.QueryString is used to collect values in a form with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.</p> <p>Request.Form is used to collect values in a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.</p> <h3>ASP Cookies</h3> <p>A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests for a page with a browser, it will send the cookie too.</p> <p>The Response.Cookies command is used to create cookies:</p> <p><%
<br />Response.Cookies("firstname")="Alex"
<br />Response.Cookies("firstname").Expires="May 10,2002"
<br />%></p> <p><b>Note:</b> The Response.Cookies command must appear BEFORE the <html> tag!</p> <p>The "Request.Cookies" command is used to retrieve a cookie value:</p> <p><%
<br />fname=Request.Cookies("firstname")
<br />response.write("Firstname=" & fname)
<br />%></p> <h3>Including Files</h3> <p>You can insert the content of one ASP file into another ASP file before the server executes it, with the #include directive. The #include directive is used to create functions, headers, footers, or elements that will be reused on multiple pages</p> <p>Syntax:</p> <p><!--#include virtual="somefile.inc"-->
<br />or
<br /><!--#include file ="somefile.inc"--></p> <p>Use the virtual keyword to indicate a path beginning with a virtual directory. If a file named "header.inc" resides in a virtual directory named /html, the following line would insert the contents of "header.inc":</p> <p><!-- #include virtual ="/html/header.inc" --></p> <p>Use the file keyword to indicate a relative path. A relative path begins with the directory that contains the including file. If you have a file in the html directory, and the file "header.inc" resides in html\headers, the following line would insert "header.inc" in your file:</p> <p><!-- #include file ="headers\header.inc" --></p> <p>Use the file keyword with the syntax (..\) to include a file from a higher-level directory.</p> <h3>Global.asa</h3> <p>The Global.asa file is an optional file that can contain declarations of objects, variables, and methods that can be accessed by every page in an ASP application.</p> <p><b>Note:</b> The Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa file.</p> <p>The Global.asa file can contain only the following:</p> <ul type="disc"><li class="MsoNormal" style="">Application events </li><li class="MsoNormal" style="">Session events </li><li class="MsoNormal" style=""><object> declarations </li><li class="MsoNormal" style="">TypeLibrary declarations </li><li class="MsoNormal" style="">the #include directive </li></ul> <p><b>Application and Session Events</b></p> <p>In Global.asa you can tell the application and session objects what to do when the application/session starts and what to do when the application/session ends. The code for this is placed in event handlers. <b>Note:</b> We do not use <% and %>, to insert scripts in the Global.asa file, we have to put the subroutines inside the HTML <script> tag:</p> <p><script language="vbscript" runat="server">
<br />sub Application_OnStart
<br /> ' some code
<br />end sub
<br />sub Application_OnEnd
<br /> ' some code
<br />end sub
<br />sub Session_OnStart
<br /> ' some code
<br />end sub
<br />sub Session_OnEnd
<br /> ' some code
<br />end sub
<br /></script></p> <p><b><object> Declarations</b></p> <p>It is also possible to create objects with session or application scope in Global.asa by using the <object> tag. <b>Note:</b> The <object> tag should be outside the <script> tag!</p> <p>Syntax:</p> <p><object runat="server" scope="scope" id="id"
<br />{progid="progID"|classid="classID"}>
<br />.......
<br /></object></p> <p><b>TypeLibrary Declarations</b></p> <p>A TypeLibrary is a container for the contents of a DLL file corresponding to a COM object. By including a call to the TypeLibrary in the Global.asa file, the constants of the COM object can be accessed, and errors can be better reported by the ASP code. If your Web application relies on COM objects that have declared data types in type libraries, you can declare the type libraries in Global.asa.</p> <p>Syntax:</p> <p> <!--METADATA TYPE="TypeLib"
<br />file="filename"
<br />uuid="typelibraryuuid"
<br />version="versionnumber"
<br />lcid="localeid"
<br />--></p> <h3>The Session Object</h3> <p>The Session object is used to store information about, or change settings for a user session. Variables stored in the Session object hold information about one single user, and are available to all pages in one application.</p> <p><b>Collections</b></p> <ul type="disc"><li class="MsoNormal" style="">Contents - Holds every item added to the session with script commands </li><li class="MsoNormal" style="">StaticObjects - Holds every object added to the session with the <object> tag, and a given session </li><li class="MsoNormal" style="">Contents.Remove(<i>item/index</i>) - Deletes an item from the Contents collection </li><li class="MsoNormal" style="">Contents.RemoveAll() - Deletes every item from the Contents collection </li></ul> <p><b>Properties</b></p> <ul type="disc"><li class="MsoNormal" style="">CodePage - Sets the code page that will be used to display dynamic content </li><li class="MsoNormal" style="">LCID - Sets the locale identifier that will be used to display dynamic content </li><li class="MsoNormal" style="">SessionID - Returns the session id </li><li class="MsoNormal" style="">Timeout - Sets the timeout for the session </li></ul> <p><b>Method</b></p> <ul type="disc"><li class="MsoNormal" style="">Abandon - Kills every object in a session object </li></ul> <h3>Application Object</h3> <p class="intro">A group of ASP files that work together to perform some purpose is called an application. The Application object in ASP is used to tie these files together. All users share one Application object. The Application object should hold information that will be used by many pages in the application (like database connection information).</p> <p><b>Collections</b></p> <ul type="disc"><li class="MsoNormal" style="">Contents - Holds every item added to the application with script commands </li><li class="MsoNormal" style="">StaticObjects - Holds every object added to the application with the <object> tag </li><li class="MsoNormal" style="">Contents.Remove - Deletes an item from a collection </li><li class="MsoNormal" style="">Contents.RemoveAll - Deletes every item from a collection </li></ul> <p><b>Methods</b></p> <ul type="disc"><li class="MsoNormal" style="">Lock - Prevents a user from changing the application object properties </li><li class="MsoNormal" style="">Unlock - Allows a user to change the application object properties </li></ul> <h3>The Response Object</h3> <p>The Response Object is used to send output to the user from the server.</p> <p><b>Collection</b></p> <ul type="disc"><li class="MsoNormal" style="">Cookies(name) - Sets a cookie value. If the cookie does not exist, it will be created, and take the value that is specified </li></ul> <p><b>Properties</b></p> <ul type="disc"><li class="MsoNormal" style="">Buffer - Whether to buffer the output or not. When the output is buffered, the server will hold back the response until all of the server scripts have been processed, or until the script calls the Flush or End method. If this property is set, it should be before the <html> tag in the ASP file </li><li class="MsoNormal" style="">CacheControl - Sets whether proxy servers can cache the output or not. When set to Public, the output can be cached by a proxy server </li><li class="MsoNormal" style="">Charset(<i>charset_name) - </i>Sets the name of the character set (like "ISO8859-1") to the content type header </li><li class="MsoNormal" style="">ContentType - Sets the HTTP content type (like "text/html", "image/gif", "image/jpeg", "text/plain"). Default is "text/html" </li><li class="MsoNormal" style="">Expires - Sets how long a page will be cached on a browser before it expires </li><li class="MsoNormal" style="">ExpiresAbsolute - Sets a date and time when a page cached on a browser will expire </li><li class="MsoNormal" style="">IsClientConnected - Checks if the client is still connected to the server </li><li class="MsoNormal" style="">Pics(<i>pics_label</i>) - Adds a value to the pics label response header </li><li class="MsoNormal" style="">Status - Specifies the value of the status line </li></ul> <p><b>Methods</b></p> <ul type="disc"><li class="MsoNormal" style="">AddHeader(<i>name, value</i>) - Adds an HTML header with a specified value </li><li class="MsoNormal" style="">AppendToLog <i>string - </i>Adds a string to the end of the server log entry </li><li class="MsoNormal" style="">BinaryWrite(<i>data_to_write</i>) - Writes the given information without any character-set conversion </li><li class="MsoNormal" style="">Clear - Clears the buffered output. Use this method to handle errors. If Response.Buffer is not set to true, this method will cause a run-time error </li><li class="MsoNormal" style="">End - Stops processing the script, and return the current result </li><li class="MsoNormal" style="">Flush - Sends buffered output immediately. If Response.Buffer is not set to true, this method will cause a run-time error </li><li class="MsoNormal" style="">Redirect(<i>url</i>) - Redirects the user to another url </li><li class="MsoNormal" style="">Write(<i>data_to_write</i>) - Writes a text to the user </li></ul> <h3>Request Object</h3> <p>When a browser asks for a page from a server, it is called a request. The Request Object is used to get information from the user.</p> <p><b>Collection</b></p> <ul type="disc"><li class="MsoNormal" style="">ClientCertificate - Holds field values stored in the client certificate </li><li class="MsoNormal" style="">Cookies(<i>name</i>) - Holds cookie values </li><li class="MsoNormal" style="">Form(<i>element_name</i>) - Holds form (input) values. The form must use the post method </li><li class="MsoNormal" style="">QueryString(<i>variable_name</i>) - Holds variable values in the query string </li><li class="MsoNormal" style="">ServerVariables(<i>server_variable</i>) - Holds server variable values </li></ul> <p><b>Property</b></p> <ul type="disc"><li class="MsoNormal" style="">TotalBytes - Holds the total number of bytes the client is sending in the body of the request </li></ul> <p><b>Method</b></p> <ul type="disc"><li class="MsoNormal" style="">BinaryRead - Fetches the data that is sent to the server from the client as part of a post request </li></ul> <h3>Server Object</h3> <p>The Server Object is used to access properties and methods on the server.</p> <p><b>Property</b></p> <ul type="disc"><li class="MsoNormal" style="">ScriptTimeout - Sets how long a script can run before it is terminated </li></ul> <p><b>Method</b></p> <ul type="disc"><li class="MsoNormal" style="">CreateObject(<i>type_of_object</i>) - Creates an instance of an object </li><li class="MsoNormal" style="">Execute(<i>path</i>) - Executes an ASP file from inside another ASP file. After executing the called ASP file, the control is returned to the original ASP file </li><li class="MsoNormal" style="">GetLastError() - Returns an ASPError object that will describe the error that occurred </li><li class="MsoNormal" style="">HTMLEncode(<i>string</i>) - Applies HTML encoding to a string </li><li class="MsoNormal" style="">MapPath(<i>path</i>) - Maps a relative or virtual path to a physical path </li><li class="MsoNormal" style="">Transfer(<i>path</i>) - Sends all of the state information to another ASP file for processing. After the transfer, procedural control is not returned to the original ASP file </li><li class="MsoNormal" style="">URLEncode(<i>string</i>) - Applies URL encoding rules to a string </li></ul> <p><b>Source : http://www.w3schools.com/asp/asp_quickref.asp</b></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>ASP Summary</h2> <p>This tutorial has taught you how to add server-side scripts to your web site, to make your web site more dynamic and interactive.</p> <p>You have learned how to dynamically edit, change or add any content of a web page, respond to data submitted from HTML forms, access any data or databases and return the results to a browser, customize a web page to make it more useful for individual users.</p> <p>For more information on ASP, please look at our <a href="http://www.w3schools.com/asp/asp_examples.asp">ASP examples</a>.</p> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-48724044414833908382009-01-02T02:35:00.000-08:002009-01-02T02:36:40.192-08:00CSS Tutorial 2<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h2 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 2 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:2; font-size:18.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} h3 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 3 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:3; font-size:13.0pt; font-family:"Arial","sans-serif"; mso-fareast-language:EN-US; font-weight:bold;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading2Char {mso-style-name:"Heading 2 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 2"; mso-ansi-font-size:18.0pt; mso-bidi-font-size:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.Heading3Char {mso-style-name:"Heading 3 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 3"; mso-ansi-font-size:13.0pt; mso-bidi-font-size:13.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-fareast-language:EN-US; font-weight:bold;} p.intro, li.intro, div.intro {mso-style-name:intro; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} span.value-inst-urinoxref {mso-style-name:"value-inst-uri noxref"; mso-style-unhide:no;} p.test, li.test, div.test {mso-style-name:test; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:17589459; mso-list-template-ids:-370277960;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:163128537; mso-list-template-ids:2125658818;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:287669910; mso-list-template-ids:77112874;} @list l2:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l3 {mso-list-id:778136831; mso-list-template-ids:-1663141514;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l4 {mso-list-id:1250699580; mso-list-template-ids:841756978;} @list l4:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l5 {mso-list-id:1762025732; mso-list-template-ids:879233114;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--><div class="MsoNormal" style="text-align: center;" align="center"><hr align="center" size="2" width="100%"> </div> <h2>What is CSS?</h2> <ul type="disc"><li class="MsoNormal" style=""><b>CSS</b> stands for <b>C</b>ascading <b>S</b>tyle <b>S</b>heets </li><li class="MsoNormal" style="">Styles define <b>how to display</b> HTML elements </li><li class="MsoNormal" style="">Styles are normally stored in <b>Style Sheets</b> </li><li class="MsoNormal" style="">Styles were added to HTML 4.0 <b>to solve a problem</b> </li><li class="MsoNormal" style=""><b>External Style Sheets</b> can save you a lot of work </li><li class="MsoNormal" style="">External Style Sheets are stored in <b>CSS files</b> </li><li class="MsoNormal" style="">Multiple style definitions will <b>cascade</b> into one </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Demo</h2> <p>With CSS, your HTML documents can be displayed using different output styles:</p> <p><a href="http://www.w3schools.com/css/demo_default.htm" target="_blank">See how it works</a></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Styles Solve a Common Problem</h2> <p>HTML tags were originally designed to define the content of a document. They were supposed to say "This is a header", "This is a paragraph", "This is a table", by using tags like <h1>, <p>, <table>, and so on. The layout of the document was supposed to be taken care of by the browser, without using any formatting tags.</p> <p>As the two major browsers - Netscape and Internet Explorer - continued to add new HTML tags and attributes (like the <span> tag and the color attribute) to the original HTML specification, it became more and more difficult to create Web sites where the content of HTML documents was clearly separated from the document's presentation layout.</p> <p>To solve this problem, the World Wide Web Consortium (W3C) - the non profit, standard setting consortium, responsible for standardizing HTML - created STYLES in addition to HTML 4.0. </p> <p>All major browsers support Cascading Style Sheets.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Style Sheets Can Save a <st1:place st="on">Lot</st1:place> of Work</h2> <p>Styles sheets define HOW HTML elements are to be displayed, just like the font tag and the color attribute in HTML 3.2. Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in your Web, just by editing one single CSS document!</p> <p>CSS is a breakthrough in Web design because it allows developers to control the style and layout of multiple Web pages all at once. As a Web developer you can define a style for each HTML element and apply it to as many Web pages as you want. To make a global change, simply change the style, and all elements in the Web are updated automatically. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Multiple Styles Will Cascade Into One</h2> <p>Style sheets allow style information to be specified in many ways. Styles can be specified inside a single HTML element, inside the <head> element of an HTML page, or in an external CSS file. Even multiple external style sheets can be referenced inside a single HTML document. </p> <h3>Cascading Order</h3> <p><b>What style will be used when there is more than one style specified for an HTML element?
<br /></b>
<br />Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority: </p> <ol start="1" type="1"><li class="MsoNormal" style="">Browser default </li><li class="MsoNormal" style="">External style sheet </li><li class="MsoNormal" style="">Internal style sheet (inside the <head> tag) </li><li class="MsoNormal" style="">Inline style (inside an HTML element) </li></ol> <p>So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style declared inside the <head> tag, in an external style sheet, or in a browser (a default value).</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Syntax</h2> <p>The CSS syntax is made up of three parts: a selector, a property and a value:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>selector {property: value}</pre></td> </tr> </tbody></table> <p>The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to change, and each property can take a value. The property and value are separated by a colon, and surrounded by curly braces:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>body {color: black}</pre></td> </tr> </tbody></table> <p><b>Note:</b> If the value is multiple words, put quotes around the value:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p {font-family: "sans serif"}</pre></td> </tr> </tbody></table> <p><b>Note:</b> If you wish to specify more than one property, you must separate each property with a semicolon. The example below shows how to define a center aligned paragraph, with a red text color:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p {text-align:center;color:red}</pre></td> </tr> </tbody></table> <p>To make the style definitions more readable, you can describe one property on each line, like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p</pre><pre>{</pre><pre>text-align: center;</pre><pre>color: black;</pre><pre>font-family: arial</pre><pre>}</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Grouping</h2> <p>You can group selectors. Separate each selector with a comma. In the example below we have grouped all the header elements. All header elements will be displayed in green text color:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>h1,h2,h3,h4,h5,h6 </pre><pre>{</pre><pre>color: green</pre><pre>}</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The class Selector</h2> <p>With the class selector you can define different styles for the same type of HTML element.</p> <p>Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one center-aligned paragraph. Here is how you can do it with styles: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p.right {text-align: right}</pre><pre>p.center {text-align: center}</pre></td> </tr> </tbody></table> <p>You have to use the class attribute in your HTML document:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><p class="right"></pre><pre>This paragraph will be right-aligned.</pre><pre></p></pre><pre><p class="center"></pre><pre>This paragraph will be center-aligned.</pre><pre></p></pre></td> </tr> </tbody></table> <p><b>Note: </b>Only one class attribute can be specified per HTML element! The example below is wrong:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><p class="right" class="center"></pre><pre>This is a paragraph.</pre><pre></p></pre></td> </tr> </tbody></table> <p>You can also omit the tag name in the selector to define a style that will be used by all HTML elements that have a certain class. In the example below, all HTML elements with class="center" will be center-aligned:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>.center {text-align: center}</pre></td> </tr> </tbody></table> <p>In the code below both the h1 element and the p element have class="center". This means that both elements will follow the rules in the ".center" selector: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><h1 class="center"></pre><pre>This heading will be center-aligned</pre><pre></h1></pre><pre><p class="center"></pre><pre>This paragraph will also be center-aligned.</pre><pre></p> </pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="0" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_i1047" type="#_x0000_t75" alt="Remark" style="'width:11.25pt;height:11.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image002.gif" href="http://www.w3schools.com/images/lamp.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.gif" alt="Remark" shapes="_x0000_i1047" border="0" width="15" height="15" /><!--[endif]-->Do <b>NOT</b> start a class name with a number! It will not work in Mozilla/Firefox.</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The id Selector</h2> <p>You can also define styles for HTML elements with the id selector. The id selector is defined as a #.</p> <p>The style rule below will match the element that has an id attribute with a value of "green":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>#green {color: green}</pre></td> </tr> </tbody></table> <p>The style rule below will match the p element that has an id with a value of "para1":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="" lang="ES">p#para1<o:p></o:p></span></pre><pre><span style="" lang="ES">{<o:p></o:p></span></pre><pre><span style="" lang="ES">text-align: center;<o:p></o:p></span></pre><pre><span style="" lang="ES">color: red<o:p></o:p></span></pre><pre>}</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="0" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_i1048" type="#_x0000_t75" alt="Remark" style="'width:11.25pt;height:11.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image002.gif" href="http://www.w3schools.com/images/lamp.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.gif" alt="Remark" shapes="_x0000_i1048" border="0" width="15" height="15" /><!--[endif]-->Do <b>NOT</b> start an ID name with a number! It will not work in Mozilla/Firefox.</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Comments</h2> <p>Comments are used to explain your code, and may help you when you edit the source code at a later date. A comment will be ignored by browsers. A CSS comment begins with "/*", and ends with "*/", like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>/* This is a comment */</pre><pre>p</pre><pre>{</pre><pre>text-align: center;</pre><pre>/* This is another comment */</pre><pre>color: black;</pre><pre>font-family: arial</pre><pre>}</pre></td> </tr> </tbody></table> <h2>Examples</h2> <ul type="disc"><li class="MsoNormal" style="">Look at <a href="http://www.w3schools.com/css/showit.asp?filename=ex1" target="_blank">Example 1</a> </li><li class="MsoNormal" style="">Look at <a href="http://www.w3schools.com/css/showit.asp?filename=ex2" target="_blank">Example 2</a> </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How to Insert a Style Sheet</h2> <p>When a browser reads a style sheet, it will format the document according to it. There are three ways of inserting a style sheet: </p> <h3>External Style Sheet</h3> <p>An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><head></pre><pre><link rel="stylesheet" type="text/css"><pre>href="mystyle.css" /></pre><pre></head></pre></td> </tr> </tbody></table> <p>The browser will read the style definitions from the file mystyle.css, and format the document according to it. </p> <p>An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>hr {color: sienna}</pre><pre>p {margin-left: 20px}</pre><pre>body {background-image: url("images/back40.gif")}</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="0" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p><!--[if gte vml 1]><v:shape id="_x0000_i1063" type="#_x0000_t75" alt="Remark" style="'width:11.25pt;height:11.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image002.gif" href="http://www.w3schools.com/images/lamp.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.gif" alt="Remark" shapes="_x0000_i1063" border="0" width="15" height="15" /><!--[endif]-->Do <b>NOT</b> leave spaces between the property value and the units! If you use "margin-left: 20 px" instead of "margin-left: 20px" it will only work properly in IE6 but it will not work in Mozilla/Firefox or Netscape.</p> </td> </tr> </tbody></table> <h3>Internal Style Sheet</h3> <p>An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section by using the <style> tag, like this: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><head></pre><pre><style type="text/css"></pre><pre>hr {color: sienna}</pre><pre>p {margin-left: 20px}</pre><pre>body {background-image: url("images/back40.gif")}</pre><pre></style></pre><pre></head></pre></td> </tr> </tbody></table> <p>The browser will now read the style definitions, and format the document according to it. </p> <p><b>Note:</b> A browser normally ignores unknown tags. This means that an old browser that does not support styles, will ignore the <style> tag, but the content of the <style> tag will be displayed on the page. It is possible to prevent an old browser from displaying the content by hiding it in the HTML comment element: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><head></pre><pre><style type="text/css"></pre><pre><!--</pre><pre>hr {color: sienna}</pre><pre>p {margin-left: 20px}</pre><pre>body {background-image: url("images/back40.gif")}</pre><pre>--></pre><pre></style></pre><pre></head></pre></td> </tr> </tbody></table> <h3>Inline Styles</h3> <p>An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly, such as when a style is to be applied to a single occurrence of an element. </p> <p>To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><p style="color: sienna; margin-left: 20px"></pre><pre>This is a paragraph</pre><pre></p></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Multiple Style Sheets</h2> <p>If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet. </p> <p>For example, an external style sheet has these properties for the h3 selector:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>h3 </pre><pre>{</pre><pre>color: red;</pre><pre>text-align: left;</pre><pre>font-size: 8pt</pre><pre>}</pre></td> </tr> </tbody></table> <p>And an internal style sheet has these properties for the h3 selector:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>h3 </pre><pre>{</pre><pre>text-align: right; </pre><pre>font-size: 20pt</pre><pre>}</pre></td> </tr> </tbody></table> <p>If the page with the internal style sheet also links to the external style sheet the properties for h3 will be:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>color: red; </pre><pre>text-align: right; </pre><pre>font-size: 20pt</pre></td> </tr> </tbody></table> <p>The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet.</p> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_background-color" target="_blank">Set the background color</a>
<br />This example demonstrates how to set the background color for an element.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_background-image" target="_blank">Set an image as the background</a>
<br />This example demonstrates how to set an image as the background.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_background-repeat" target="_blank">How to repeat a background image</a>
<br />This example demonstrates how to repeat a background image only vertically.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_background-position" target="_blank">How to place the background image</a>
<br />This example demonstrates how to place the image on the page.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_background-attachment" target="_blank">How to set a fixed background image</a>
<br />This example demonstrates how to set a fixed background image. The image will not scroll with the rest of the page.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_background" target="_blank">All the background properties in one declaration</a>
<br />This example demonstrates how to use the shorthand property for setting all of the background properties in one declaration.</p> <h2>CSS Background Properties</h2> <p>The CSS background properties allow you to control the background color of an element, set an image as the background, repeat a background image vertically or horizontally, and position an image on a page.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 29.92%;" width="29%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4.92%;" width="4%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7.46%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_background.asp">background</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all background properties in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>background-color
<br /> background-image
<br /> background-repeat background-attachment background-position</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_background-attachment.asp">background-attachment</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets whether a background image is fixed or scrolls with the rest of the page</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">scroll
<br /> fixed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_background-color.asp">background-color</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the background color of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>color-rgb
<br /> color-hex
<br /> color-name
<br /> </i>transparent</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_background-image.asp">background-image</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets an image as the background</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>url</i>
<br /> none</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_background-position.asp">background-position</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the starting position of a background image</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">top left
<br /> top center
<br /> top right
<br /> center left
<br /> center center
<br /> center right
<br /> bottom left
<br /> bottom center
<br /> bottom right
<br /> <i>x-% y-%</i>
<br /> <i>x-pos y-pos</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_background-repeat.asp">background-repeat</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets if/how a background image will be repeated</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">repeat
<br /> repeat-x
<br /> repeat-y
<br /> no-repeat</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> </tbody></table> <p class="intro">The CSS text properties define the appearance of text.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_color" target="_blank">Set the color of the text</a>
<br />This example demonstrates how to set the color of the text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_text_background" target="_blank">Set the background-color of the text</a>
<br />This example demonstrates how to set the background-color of a part of the text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_letter-spacing" target="_blank">Specify the space between characters</a>
<br />This example demonstrates how to increase or decrease the space between characters.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_text-align" target="_blank">Align the text</a>
<br />This example demonstrates how to align the text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_text-decoration" target="_blank">Decorate the text</a>
<br />This example demonstrates how to add decoration to text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_text-indent" target="_blank">Indent text</a>
<br />This example demonstrates how to indent the first line of a paragraph.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_text-transform" target="_blank">Control the letters in a text</a>
<br />This example demonstrates how to control the letters in a text.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Text Properties</h2> <p>The CSS text properties allow you to control the appearance of text. It is possible to change the color of a text, increase or decrease the space between characters in a text, align a text, decorate a text, indent the first line in a text, and more.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 29.92%;" width="29%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4.92%;" width="4%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7.46%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_color.asp">color</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the color of a text</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_direction.asp">direction</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the text direction</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">ltr
<br /> rtl</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_letter-spacing.asp">letter-spacing</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Increase or decrease the space between characters</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_text-align.asp">text-align</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Aligns the text in an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">left
<br /> right
<br /> center
<br /> justify</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_text-decoration.asp">text-decoration</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds decoration to text</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> underline
<br /> overline
<br /> line-through
<br /> blink</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_text-indent.asp">text-indent</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Indents the first line of text in an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">text-shadow</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> <i>color</i>
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_text-transform.asp">text-transform</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Controls the letters in an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> capitalize
<br /> uppercase
<br /> lowercase</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">unicode-bidi</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> embed
<br /> bidi-override</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_white-space.asp">white-space</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets how white space inside an element is handled</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> pre
<br /> nowrap</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_text_word-spacing.asp">word-spacing</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Increase or decrease the space between words</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> </tbody></table> <p class="intro">The CSS font properties define the font in text.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_font-family" target="_blank">Set the font of a text</a>
<br />This example demonstrates how to set a font of a text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_font-size" target="_blank">Set the size of the font</a>
<br />This example demonstrates how to set the size of a font.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_font-style" target="_blank">Set the style of the font</a>
<br />This example demonstrates how to set the style of a font.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_font-variant" target="_blank">Set the variant of the font</a>
<br />This example demonstrates how to set the variant of a font.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_font-weight" target="_blank">Set the boldness of the font</a>
<br />This example demonstrates how to set the boldness of a font.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_font" target="_blank">All the font properties in one declaration</a>
<br />This example demonstrates how to use the shorthand property for setting all of the font properties in one declaration.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Font Properties</h2> <p>The CSS font properties allow you to change the font family, boldness, size, and the style of a text.</p> <p><b>Note:</b> In CSS1 fonts are identified by a font name. If a browser does not support the specified font, it will use a default font.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 29.92%;" width="29%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4.92%;" width="4%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7.46%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_font.asp">font</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the properties for a font in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>font-style
<br /> font-variant
<br /> font-weight
<br /> font-size/line-height
<br /> font-family
<br /> </i>caption
<br /> icon
<br /> menu
<br /> message-box
<br /> small-caption
<br /> status-bar</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_font-family.asp">font-family</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A prioritized list of font family names and/or generic family names for an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>family-name
<br /> generic-family</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_font-size.asp">font-size</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the size of a font</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">xx-small
<br /> x-small
<br /> small
<br /> medium
<br /> large
<br /> x-large
<br /> xx-large
<br /> smaller
<br /> larger<i>
<br /> length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_font-size-adjust.asp">font-size-adjust</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies an aspect value for an element that will preserve the x-height of the first-choice font</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> <i>number</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_font-stretch.asp">font-stretch</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Condenses or expands the current font-family</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> wider
<br /> narrower
<br /> ultra-condensed
<br /> extra-condensed
<br /> condensed
<br /> semi-condensed
<br /> semi-expanded
<br /> expanded
<br /> extra-expanded
<br /> ultra-expanded</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_font-style.asp">font-style</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the style of the font</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> italic
<br /> oblique</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_font-variant.asp">font-variant</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Displays text in a small-caps font or a normal font</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> small-caps</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_font_weight.asp">font-weight</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the weight of a font</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> bold
<br /> bolder
<br /> lighter
<br /> 100
<br /> 200
<br /> 300
<br /> 400
<br /> 500
<br /> 600
<br /> 700
<br /> 800
<br /> 900</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> </tbody></table> <p class="intro">The CSS border properties define the borders around an element.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-style" target="_blank">Set the style of the four borders</a>
<br />This example demonstrates how to set the style of the four borders.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-style2" target="_blank">Set different borders on each side</a>
<br />This example demonstrates how to set different borders on each side of the element.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-color" target="_blank">Set the color of the four borders</a>
<br />This example demonstrates how to set the color of the four borders. It can have from one to four colors.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-bottom-width" target="_blank">Set the width of the bottom border</a>
<br />This example demonstrates how to set the width of the bottom border.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-left-width" target="_blank">Set the width of the left border</a>
<br />This example demonstrates how to set the width of the left border.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-right-width" target="_blank">Set the width of the right border</a>
<br />This example demonstrates how to set the width of the right border.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-top-width" target="_blank">Set the width of the top border</a>
<br />This example demonstrates how to set the width of the top border.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-bottom" target="_blank">All the bottom border properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting all of the properties for the bottom border in one declaration.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-left" target="_blank">All the left border properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting all of the properties for the left border in one declaration.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-right" target="_blank">All the right border properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting all of the properties for the right border in one declaration.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-top" target="_blank">All the top border properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting all of the properties for the top border in one declaration.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border-width" target="_blank">All the width of the border properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting the width of the four borders in one declaration, can have from one to four values.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_border" target="_blank">All the border properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting all of the properties for the four borders in one declaration, can have from one to three values.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Border Properties</h2> <p>The CSS border properties allow you to specify the style and color of an element's border. In HTML we use tables to create borders around a text, but with the CSS border properties we can create borders with nice effects, and it can be applied to any element.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 30%;" width="30%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border.asp">border</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the properties for the four borders in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-width
<br /> border-style
<br /> border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-bottom.asp">border-bottom</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the properties for the bottom border in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-bottom-width
<br /> border-style
<br /> border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-bottom_color.asp">border-bottom-color</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the color of the bottom border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-bottom_style.asp">border-bottom-style</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the style of the bottom border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-style</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-bottom_width.asp">border-bottom-width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the width of the bottom border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">thin
<br /> medium
<br /> thick
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-color.asp">border-color</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the color of the four borders, can have from one to four colors</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-left.asp">border-left</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the properties for the left border in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-left-width
<br /> border-style
<br /> border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-left_color.asp">border-left-color</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the color of the left border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-left_style.asp">border-left-style</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the style of the left border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-style</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-left_width.asp">border-left-width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the width of the left border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">thin
<br /> medium
<br /> thick
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-right.asp">border-right</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the properties for the right border in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-right-width
<br /> border-style
<br /> border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-right_color.asp">border-right-color</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the color of the right border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-right_style.asp">border-right-style</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the style of the right border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-style</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-right_width.asp">border-right-width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the width of the right border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">thin
<br /> medium
<br /> thick
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-style.asp">border-style</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the style of the four borders, can have from one to four styles</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> hidden
<br /> dotted
<br /> dashed
<br /> solid
<br /> double
<br /> groove
<br /> ridge
<br /> inset
<br /> outset</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-top.asp">border-top</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the properties for the top border in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-top-width
<br /> border-style
<br /> border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-top_color.asp">border-top-color</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the color of the top border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-color</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-top_style.asp">border-top-style</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the style of the top border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>border-style</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-top_width.asp">border-top-width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the width of the top border</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">thin
<br /> medium
<br /> thick
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_border-width.asp">border-width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting the width of the four borders in one declaration, can have from one to four values</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">thin
<br /> medium
<br /> thick
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The CSS margin properties define the space around elements.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_margin-left" target="_blank">Set the left margin of a text</a>
<br />This example demonstrates how to set the left margin of a text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_margin-right" target="_blank">Set the right margin of a text</a>
<br />This example demonstrates how to set the right margin of a text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_margin-top" target="_blank">Set the top margin of a text</a>
<br />This example demonstrates how to set the top margin of a text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_margin-bottom" target="_blank">Set the bottom margin of a text</a>
<br />This example demonstrates how to set the bottom margin of a text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_margin" target="_blank">All the margin properties in one declaration</a>
<br />This example demonstrates how to set a shorthand property for setting all of the margin properties in one declaration.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Margin Properties</h2> <p>The CSS margin properties define the space around elements. It is possible to use negative values to overlap content. The top, right, bottom, and left margin can be changed independently using separate properties. A shorthand margin property can also be used to change all of the margins at once.</p> <p><b>Note:</b> Netscape and IE give the body tag a default margin of 8px. Opera does not! Instead, Opera applies a default padding of 8px, so if one wants to adjust the margin for an entire page and have it display correctly in Opera, the body padding must be set as well!</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 30%;" width="30%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_margin.asp">margin</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting the margin properties in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>margin-top
<br /> margin-right
<br /> margin-bottom
<br /> margin-left</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p><a href="http://www.w3schools.com/css/pr_margin-bottom.asp">margin-bottom</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the bottom margin of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p><a href="http://www.w3schools.com/css/pr_margin-left.asp">margin-left</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the left margin of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p><a href="http://www.w3schools.com/css/pr_margin-right.asp">margin-right</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the right margin of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_margin-top.asp">margin-top</a> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the top margin of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The CSS padding properties define the space between the element border and the element content.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_padding-left" target="_blank">Set the left padding</a>
<br />This example demonstrates how to set the left padding of a tablecell.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_padding-right" target="_blank">Set the right padding</a>
<br />This example demonstrates how to set the right padding of a tablecell.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_padding-top" target="_blank">Set the top padding</a>
<br />This example demonstrates how to set the top padding of a tablecell.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_padding-bottom" target="_blank">Set the bottom padding</a>
<br />This example demonstrates how to set the bottom padding of a tablecell.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_padding" target="_blank">All the padding properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting all of the padding properties in one declaration, can have from one to four values.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Padding Properties</h2> <p>The CSS padding properties define the space between the element border and the element content. Negative values are not allowed. The top, right, bottom, and left padding can be changed independently using separate properties. A shorthand padding property is also created to control multiple sides at once.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 30%;" width="30%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_padding.asp">padding</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the padding properties in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>padding-top
<br /> padding-right
<br /> padding-bottom
<br /> padding-left</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p><a href="http://www.w3schools.com/css/pr_padding-bottom.asp">padding-bottom</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the bottom padding of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p><a href="http://www.w3schools.com/css/pr_padding-left.asp">padding-left</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the left padding of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p><a href="http://www.w3schools.com/css/pr_padding-right.asp">padding-right</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the right padding of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_padding-top.asp">padding-top</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the top padding of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The CSS list properties allow you to place the list-item marker, change between different list-item markers, or set an image as the list-item marker.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_list-style-type" target="_blank">The different list-item markers in unordered lists</a>
<br />This example demonstrates the different list-item markers in CSS.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_list-style-type2" target="_blank">The different list-item markers in ordered lists</a>
<br />This example demonstrates the different list-item markers in CSS.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_list-style-image" target="_blank">Set an image as the list-item marker</a>
<br />This example demonstrates how to set an image as the list-item marker.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_list-style-position" target="_blank">Place the list-item marker</a>
<br />This example demonstrates where to place the list-item marker.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_list-style" target="_blank">All list properties in one declaration</a>
<br />This example demonstrates a shorthand property for setting all of the properties for a list in one declaration.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS List Properties</h2> <p>The CSS list properties allow you to place the list-item marker, change between different list-item markers, or set an image as the list-item marker.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 29.92%;" width="29%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 24.92%;" width="24%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4.92%;" width="4%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 3.92%;" width="3%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7.46%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_list-style.asp">list-style</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">A shorthand property for setting all of the properties for a list in one declaration</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>list-style-type
<br /> list-style-position
<br /> list-style-image</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_list-style-image.asp">list-style-image</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets an image as the list-item marker</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> <i>url</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_list-style-position.asp">list-style-position</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets where the list-item marker is placed in the list</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">inside
<br /> outside</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_list-style-type.asp">list-style-type</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the type of the list-item marker</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> disc
<br /> circle
<br /> square
<br /> decimal
<br /> decimal-leading-zero
<br /> lower-roman
<br /> upper-roman
<br /> lower-alpha
<br /> upper-alpha
<br /> lower-greek
<br /> lower-latin
<br /> upper-latin
<br /> hebrew
<br /> armenian
<br /> georgian
<br /> cjk-ideographic
<br /> hiragana
<br /> katakana
<br /> hiragana-iroha
<br /> katakana-iroha </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">marker-offset</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">7</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> </tbody></table> <p class="intro">The CSS dimension properties allow you to control the height and width of an element. It also allows you to increase the space between two lines.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_line-height" target="_blank">Increase the space between lines</a>
<br />This example demonstrates how to increase the space between the lines.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Dimension Properties</h2> <p>The CSS dimension properties allow you to control the height and width of an element. It also allows you to increase the space between two lines.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 30%;" width="30%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_dim_height.asp">height</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the height of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto<i>
<br /> length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_dim_line-height.asp">line-height</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the distance between lines</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">normal
<br /> <i>number
<br /> length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_dim_max-height.asp">max-height</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the maximum height of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> <i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_dim_max-width.asp">max-width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the maximum width of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> <i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_dim_min-height.asp">min-height</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the minimum height of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_dim_min-width.asp">min-width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the minimum width of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>length
<br /> %</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_dim_width.asp">width</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the width of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>%
<br /> length</i> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The CSS classification properties allow you to specify how and where to display an element.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_display" target="_blank">How to display an element</a>
<br />This example demonstrates how to display an element.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_float" target="_blank">A simple use of the float property</a>
<br />Let an image float to the right in a paragraph.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_float2" target="_blank">An image with border and margins that floats to the right in a paragraph</a>
<br />Let an image float to the right in a paragraph. Add border and margins to the image.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_float3" target="_blank">An image with a caption that floats to the right</a>
<br />Let an image with a caption float to the right.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_float4" target="_blank">Let the first letter of a paragraph float to the left</a>
<br />Let the first letter of a paragraph float to the left and style the letter.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_float5" target="_blank">Creating a horizontal menu</a>
<br />Use float with a list of hyperlinks to create a horizontal menu.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_float6" target="_blank">Creating a homepage without tables</a>
<br />Use float to create a homepage with a header, footer, left content and main content.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_position_relative" target="_blank">Position:relative</a>
<br />This example demonstrates how to position an element relative to its normal position.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_position_absolute" target="_blank">Position:absolute</a>
<br />This example demonstrates how to position an element using an absolute value.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_visibility" target="_blank">How to make an element invisible</a>
<br />This example demonstrates how to make an element invisible. Do you want the element to show or not?</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_cursor" target="_blank">Change the cursor</a>
<br />This example demonstrates how to change the cursor.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Classification Properties</h2> <p>The CSS classification properties allow you to control how to display an element, set where an image will appear in another element, position an element relative to its normal position, position an element using an absolute value, and how to control the visibility of an element.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 30%;" width="30%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_class_clear.asp">clear</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the sides of an element where other floating elements are not allowed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">left
<br /> right
<br /> both
<br /> none</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_class_cursor.asp">cursor</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Specifies the type of cursor to be displayed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span class="value-inst-urinoxref"><i>url</i></span>
<br /> auto
<br /> crosshair
<br /> default
<br /> pointer
<br /> move
<br /> e-resize
<br /> ne-resize
<br /> nw-resize
<br /> n-resize
<br /> se-resize
<br /> sw-resize
<br /> s-resize
<br /> w-resize
<br /> text
<br /> wait
<br /> help</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_class_display.asp">display</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets how/if an element is displayed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">none
<br /> inline
<br /> block
<br /> list-item
<br /> run-in
<br /> compact
<br /> marker
<br /> table
<br /> inline-table
<br /> table-row-group
<br /> table-header-group
<br /> table-footer-group
<br /> table-row
<br /> table-column-group
<br /> table-column
<br /> table-cell
<br /> table-caption</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_class_float.asp">float</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets where an image or a text will appear in another element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">left
<br /> right
<br /> none</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_class_position.asp">position</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Places an element in a static, relative, absolute or fixed position</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">static
<br /> relative
<br /> absolute
<br /> fixed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_class_visibility.asp">visibility</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets if an element should be visible or invisible</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">visible
<br /> hidden
<br /> collapse</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The CSS positioning properties allows you to position an element.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_position_relative" target="_blank">Position:relative</a>
<br />This example demonstrates how to position an element relative to its normal position.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_position_absolute" target="_blank">Position:absolute</a>
<br />This example demonstrates how to position an element using an absolute value.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_clip" target="_blank">Set the shape of an element</a>
<br />This example demonstrates how to set the shape of an element. The element is clipped into this shape, and displayed.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_overflow" target="_blank">Overflow</a>
<br />This example demonstrates how to set the overflow property to specify what should happen when an element's content is too big to fit in a specified area.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_vertical-align" target="_blank">Vertical align an image</a>
<br />This example demonstrates how to vertical align an image in a text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_zindex2" target="_blank">Z-index</a>
<br />Z-index can be used to place an element "behind" another element.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_zindex1" target="_blank">Z-index</a>
<br />The elements in the example above have now changed their Z-index.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Positioning Properties</h2> <p>The CSS positioning properties allow you to specify the left, right, top, and bottom position of an element. It also allows you to set the shape of an element, place an element behind another, and to specify what should happen when an element's content is too big to fit in a specified area.</p> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Property<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 30%;" width="30%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>Values<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_bottom.asp">bottom</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets how far the bottom edge of an element is above/below the bottom edge of the parent element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>%
<br /> length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_clip.asp">clip</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the shape of an element. The element is clipped into this shape, and displayed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i>shape
<br /> </i>auto</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_left.asp">left</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets how far the left edge of an element is to the right/left of the left edge of the parent element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>%
<br /> length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_overflow.asp">overflow</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets what happens if the content of an element overflow its area</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">visible
<br /> hidden
<br /> scroll
<br /> auto</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_class_position.asp">position</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Places an element in a static, relative, absolute or fixed position</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">static
<br /> relative
<br /> absolute
<br /> fixed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_right.asp">right</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets how far the right edge of an element is to the left/right of the right edge of the parent element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>%
<br /> length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_top.asp">top</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets how far the top edge of an element is above/below the top edge of the parent element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>%
<br /> length</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_vertical-align.asp">vertical-align</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the vertical alignment of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">baseline
<br /> sub
<br /> super
<br /> top
<br /> text-top
<br /> middle
<br /> bottom
<br /> text-bottom
<br /> <i>length</i>
<br />
<br /> <i>%</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><a href="http://www.w3schools.com/css/pr_pos_z-index.asp">z-index</a></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Sets the stack order of an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">auto
<br /> <i>number</i></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">6</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">CSS pseudo-classes are used to add special effects to some selectors.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_link" target="_blank">Hyperlink</a>
<br />This example demonstrates how to add different colors to a hyperlink in a document.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_link2" target="_blank">Hyperlink 2</a>
<br />This example demonstrates how to add other styles to hyperlinks.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_first-child" target="_blank">:first-child</a> (does not work in IE)
<br />This example demonstrates the use of the :first-child pseudo-class.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_lang" target="_blank">:lang</a> (does not work in IE)
<br />This example demonstrates the use of the :lang pseudo-class.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Syntax</h2> <p>The syntax of pseudo-classes:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>selector:pseudo-class {property: value}</pre></td> </tr> </tbody></table> <p>CSS classes can also be used with pseudo-classes:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>selector.class:pseudo-class {property: value}</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Anchor Pseudo-classes</h2> <p>A link that is active, visited, unvisited, or when you mouse over a link can all be displayed in different ways in a CSS-supporting browser:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>a:link {color: #FF0000}<span style=""> </span>/* unvisited link */</pre><pre>a:visited {color: #00FF00}<span style=""> </span>/* visited link */</pre><pre>a:hover {color: #FF00FF}<span style=""> </span>/* mouse over link */</pre><pre>a:active {color: #0000FF}<span style=""> </span>/* selected link */</pre></td> </tr> </tbody></table> <p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective!!</p> <p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be effective!!</p> <p><b>Note:</b> Pseudo-class names are not case-sensitive.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Pseudo-classes and CSS Classes</h2> <p>Pseudo-classes can be combined with CSS classes: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>a.red:visited {color: #FF0000}</pre><pre><a class="red" href="css_syntax.asp">CSS Syntax</a></pre></td> </tr> </tbody></table> <p>If the link in the example above has been visited, it will be displayed in red.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS2 - The :first-child Pseudo-class</h2> <p>The :first-child pseudo-class matches a specified element that is the first child of another element.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p>In this example, the selector matches <b>any p element that is the first child of a div element</b>, and indents the first paragraph inside a div element:</p> <pre>div > p:first-child</pre><pre>{</pre><pre>text-indent:25px</pre><pre>}</pre> <p>This selector will match the first paragraph inside the div in the following HTML:</p> <pre><div></pre><pre><p></pre><pre>First paragraph in div.</pre><pre>This paragraph will be indented.</pre><pre></p></pre><pre><p></pre><pre>Second paragraph in div.</pre><pre>This paragraph will not be indented.</pre><pre></p></pre><pre></div></pre> <p>but it will not match the paragraph in this HTML:</p> <pre><div></pre><pre><h1>Header</h1></pre><pre><p></pre><pre>The first paragraph inside the div.</pre><pre>This paragraph will not be indented.</pre><pre></p></pre><pre></div></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p>In this example, the selector matches <b>any em element that is the first child of a p element</b>, and sets the font-weight to bold for the first em inside a p element:</p> <pre>p:first-child em</pre><pre>{</pre><pre>font-weight:bold</pre><pre>}</pre> <p>For example, the em in the HTML below is the first child of the paragraph:</p> <pre><p>I am a <em>strong</em> man.</p></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p>In this example, the selector matches <b>any a element that is the first child of any element</b>, and sets the text-decoration to none:</p> <pre>a:first-child</pre><pre>{</pre><pre>text-decoration:none</pre><pre>}</pre> <p>For example, the first a in the HTML below is the first child of the paragraph and will not be underlined. But the second a in the paragraph is not the first child of the paragraph and will be underlined:</p> <pre><p></pre><pre>Visit <a href="http://www.w3schools.com">W3Schools</a></pre><pre>and learn CSS!</pre><pre>Visit <a href="http://www.w3schools.com">W3Schools</a></pre><pre>and learn HTML!</pre><pre></p></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS2 - The :lang Pseudo-class</h2> <p>The :lang pseudo-class allows you to define special rules for different languages. In the example below, the :lang class defines the type of quotation marks for q elements with a lang attribute with a value of "no":</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><head></pre><pre><style type="text/css"></pre><pre>q:lang(no)</pre><pre>{</pre><pre>quotes: "~" "~"</pre><pre>}</pre><pre></style></pre><pre></head></pre><pre><body></pre><pre><p>Some text <q lang="no">A quote in a paragraph</q></pre><pre>Some text.</p></pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Pseudo-classes</h2> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Pseudo-class<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 55%;" valign="top" width="55%"> <p class="MsoNormal"><b>Purpose<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" valign="top" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" valign="top" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" valign="top" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" valign="top" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:active</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to an activated element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">8</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:focus</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to an element while the element has focus</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">-</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:hover</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to an element when you mouse over it</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">7</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:link</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to an unvisited link</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:visited</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to a visited link</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">3</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">4</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:first-child</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to an element that is the first child of some other element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">7</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:lang</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Allows the author to specify a language to use in a specified element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">8</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">CSS pseudo-elements are used to add special effects to some selectors.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Examples</h2> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_firstletter" target="_blank">Make the first letter special</a>
<br />This example demonstrates how to add a special effect to the first letter of a text.</p> <p><a href="http://www.w3schools.com/css/tryit.asp?filename=trycss_firstline" target="_blank">Make the first line special</a>
<br />This example demonstrates how to add a special effect to the first line of a text.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Syntax</h2> <p>The syntax of pseudo-elements:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>selector:pseudo-element {property: value}</pre></td> </tr> </tbody></table> <p>CSS classes can also be used with pseudo-elements:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>selector.class:pseudo-element {property: value}</pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The :first-line Pseudo-element</h2> <p>The "first-line" pseudo-element is used to add special styles to the first line of the text in a selector:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p {font-size: 12pt}</pre><pre>p:first-line {color: #0000FF; font-variant: small-caps}</pre><pre><p>Some text that ends up on two or more lines</p></pre></td> </tr> </tbody></table> <p>The output could be something like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p><span style="font-variant: small-caps; color: blue;">Some text that ends</span>
<br /> up on two or more lines</p> </td> </tr> </tbody></table> <p>In the example above the browser displays the first line formatted according to the "first-line" pseudo element. <b>Where</b> the browser breaks the line depends on the size of the browser window.</p> <p><b>Note:</b> The "first-line" pseudo-element can only be used with block-level elements.</p> <p><b>Note:</b> The following properties apply to the "first-line" pseudo-element: </p> <ul type="disc"><li class="MsoNormal" style="">font properties </li><li class="MsoNormal" style="">color properties </li><li class="MsoNormal" style="">background properties </li><li class="MsoNormal" style="">word-spacing </li><li class="MsoNormal" style="">letter-spacing </li><li class="MsoNormal" style="">text-decoration </li><li class="MsoNormal" style="">vertical-align </li><li class="MsoNormal" style="">text-transform </li><li class="MsoNormal" style="">line-height </li><li class="MsoNormal" style="">clear </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The :first-letter Pseudo-element</h2> <p>The "first-letter" pseudo-element is used to add special style to the first letter of the text in a selector:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p {font-size: 12pt}</pre><pre>p:first-letter {font-size: 200%; float: left}</pre><pre><p>The first words of an article.</p></pre></td> </tr> </tbody></table> <p>The output could be something like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p>___
<br /> | he first
<br /> | words of an
<br /> article.</p> </td> </tr> </tbody></table> <p><b>Note:</b> The "first-letter" pseudo-element can only be used with block-level elements.</p> <p><b>Note:</b> The following properties apply to the "first-letter" pseudo- element: </p> <ul type="disc"><li class="MsoNormal" style="">font properties </li><li class="MsoNormal" style="">color properties </li><li class="MsoNormal" style="">background properties </li><li class="MsoNormal" style="">margin properties </li><li class="MsoNormal" style="">padding properties </li><li class="MsoNormal" style="">border properties </li><li class="MsoNormal" style="">text-decoration </li><li class="MsoNormal" style="">vertical-align (only if 'float' is 'none') </li><li class="MsoNormal" style="">text-transform </li><li class="MsoNormal" style="">line-height </li><li class="MsoNormal" style="">float </li><li class="MsoNormal" style="">clear </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Pseudo-elements and CSS Classes</h2> <p>Pseudo-elements can be combined with CSS classes: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p.article:first-letter {color: #FF0000}</pre><pre><p class="article">A paragraph in an article</p></pre></td> </tr> </tbody></table> <p>The example above will make the first letter of all paragraphs with class="article" red.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Multiple Pseudo-elements</h2> <p>Several pseudo-elements can be combined:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>p {font-size: 12pt}</pre><pre>p:first-letter {color: #FF0000; font-size: 200%}</pre><pre>p:first-line {color: #0000FF}</pre><pre><p>The first words of an article</p></pre></td> </tr> </tbody></table> <p>The output could be something like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p><span style="color: red;">___</span>
<br /> <span style="color: red;">|</span> <span style="color: blue;">he first</span>
<br /> <span style="color: red;">|</span> words of an
<br /> article.</p> </td> </tr> </tbody></table> <p>In the example above the first letter of the paragraph will be red with a font size of 24pt. The rest of the first line would be blue while the rest of the paragraph would be the default color.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS2 - The :before Pseudo-element</h2> <p>The ":before" pseudo-element can be used to insert some content before an element.</p> <p>The style below will play a sound before each occurrence of a header one element.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p>h1:before
<br /> {
<br /> content: url(beep.wav)
<br /> }</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS2 - The :after Pseudo-element</h2> <p>The ":after" pseudo-element can be used to insert some content after an element.</p> <p>The style below will play a sound after each occurrence of a header one element.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p>h1:after
<br /> {
<br /> content: url(beep.wav)
<br /> }</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Pseudo-elements</h2> <p><b>Browser support:</b> IE: Internet Explorer, F: Firefox, N: Netscape.</p> <p><b>W3C:</b> The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Pseudo-element<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 55%;" valign="top" width="55%"> <p class="MsoNormal"><b>Purpose<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 5%;" valign="top" width="5%"> <p class="MsoNormal"><b>IE<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" valign="top" width="4%"> <p class="MsoNormal"><b>F<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 4%;" valign="top" width="4%"> <p class="MsoNormal"><b>N<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 7%;" valign="top" width="7%"> <p class="MsoNormal"><b>W3C<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:first-letter</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to the first letter of a text</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">8</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:first-line</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Adds special style to the first line of a text</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">8</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:before</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Inserts some content before an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1.5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">8</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">:after</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Inserts some content after an element</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"> </p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">1.5</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">8</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">2</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">Media Types allow you to specify how documents will be presented in different media. The document can be displayed differently on the screen, on the paper, with an aural browser, etc. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Media Types</h2> <p class="test">Some CSS properties are only designed for a certain media. For example the "voice-family" property is designed for aural user agents. Some other properties can be used for different media types. For example, the "font-size" property can be used for both screen and print media, but perhaps with different values. A document usually needs a larger font-size on a screen than on paper, and sans-serif fonts are easier to read on the screen, while serif fonts are easier to read on paper.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The @media Rule</h2> <p>The @media rule allows different style rules for different media in the same style sheet.</p> <p>The style in the example below tells the browser to display a 14 pixels Verdana font on the screen. But if the page is printed, it will be in a 10 pixels Times font. Notice that the font-weight is set to bold, both on screen and on paper:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><html></pre><pre><head></pre><pre><style></pre><pre>@media screen</pre><pre>{</pre><pre><span style="" lang="FR">p.test {font-family:verdana,sans-serif; font-size:14px}<o:p></o:p></span></pre><pre>}</pre><pre><o:p> </o:p></pre><pre>@media print</pre><pre>{</pre><pre>p.test {font-family:times,serif; font-size:10px}</pre><pre>}</pre><pre>@media screen,print</pre><pre>{</pre><pre>p.test {font-weight:bold}</pre><pre>}</pre><pre></style></pre><pre></head></pre><pre><body></pre><pre>....</pre><pre></body></pre><pre></html></pre></td> </tr> </tbody></table> <p><b>See it yourself !</b> If you are using Mozilla/Firefox or IE 5+ and print this page, you will see that the paragraph under "Media Types" will be displayed in another font, and have a smaller font size than the rest of the text.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Different Media Types </h2> <p><b>Note:</b> The media type names are not case-sensitive. </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Media Type<o:p></o:p></b></p> </td> <td style="padding: 2.25pt; width: 80%;" valign="top" width="80%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">all</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for all media type devices</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">aural</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for speech and sound synthesizers</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">braille</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for braille tactile feedback devices</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">embossed</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for paged braille printers</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">handheld</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for small or handheld devices</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">print</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for printers</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">projection</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for projected presentations, like slides</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">screen</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for computer screens</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">tty</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for media using a fixed-pitch character grid, like teletypes and terminals</p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">tv</p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal">Used for television-type devices</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>CSS Summary</h2> <p>This tutorial has taught you how to create style sheets to control the style and layout of multiple web sites at once.</p> <p>You have learned how to use CSS to add backgrounds, format text, add and format borders, and specify padding and margins of elements.</p> <p>You have also learned how to position an element, control the visibility and size of an element, set the shape of an element, place an element behind another, and to add special effects to some selectors, like links.</p> <p>For more information on CSS, please take a look at our <a href="http://www.w3schools.com/css/css_examples.asp">CSS examples</a> and our <a href="http://www.w3schools.com/css/css_reference.asp">CSS reference</a>.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Now You Know CSS, What's Next?</h2> <p>The next step is to learn XHTML and JavaScript.</p> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-74593499897599251112009-01-02T02:21:00.000-08:002009-01-02T02:34:33.071-08:00XHTML Tutorial<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="0" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="HTML Top of Form"> <w:lsdexception locked="false" priority="0" name="HTML Bottom of Form"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Code"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h2 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 2 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:2; font-size:18.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} h3 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 3 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:3; font-size:13.0pt; font-family:"Arial","sans-serif"; mso-fareast-language:EN-US; font-weight:bold;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} code {mso-style-unhide:no; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading2Char {mso-style-name:"Heading 2 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 2"; mso-ansi-font-size:18.0pt; mso-bidi-font-size:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.Heading3Char {mso-style-name:"Heading 3 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 3"; mso-ansi-font-size:13.0pt; mso-bidi-font-size:13.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-fareast-language:EN-US; font-weight:bold;} p.intro, li.intro, div.intro {mso-style-name:intro; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} span.z-TopofFormChar {mso-style-name:"z-Top of Form Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"z-Top of Form"; mso-ansi-font-size:8.0pt; mso-bidi-font-size:8.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; display:none; mso-hide:all; mso-fareast-language:EN-US;} span.z-BottomofFormChar {mso-style-name:"z-Bottom of Form Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"z-Bottom of Form"; mso-ansi-font-size:8.0pt; mso-bidi-font-size:8.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; display:none; mso-hide:all; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:17972892; mso-list-template-ids:1397798754;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:443811354; mso-list-template-ids:-1623982008;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:491023713; mso-list-template-ids:-538511772;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l3 {mso-list-id:634603496; mso-list-template-ids:-1234382882;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l4 {mso-list-id:759910666; mso-list-template-ids:1870415226;} @list l4:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l5 {mso-list-id:1125974222; mso-list-template-ids:-51992004;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l6 {mso-list-id:1929461401; mso-list-template-ids:2034683860;} @list l6:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l7 {mso-list-id:1936329178; mso-list-template-ids:1882609360;} @list l7:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--><div class="MsoNormal" style="text-align: center;" align="center"><hr align="center" size="2" width="100%"> </div> <h2>What Is XHTML? </h2> <ul type="disc"><li class="MsoNormal" style="">XHTML stands for E<b>X</b>tensible <b>H</b>yper<b>T</b>ext <b>M</b>arkup <b>L</b>anguage </li><li class="MsoNormal" style="">XHTML is aimed to <b>replace</b> HTML </li><li class="MsoNormal" style="">XHTML is almost <b>identical</b> to HTML 4.01 </li><li class="MsoNormal" style="">XHTML is a <b>stricter and cleaner</b> version of HTML </li><li class="MsoNormal" style="">XHTML is HTML defined as an <b>XML application</b> </li><li class="MsoNormal" style="">XHTML is a W3C Recommendation </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>What You Should Already Know</h2> <p>Before you continue you should have a basic understanding of the following:</p> <ul type="disc"><li class="MsoNormal" style="">HTML and the basics of building web pages </li></ul> <p>If you want to study HTML first, please read our <a href="http://www.w3schools.com/html/default.asp">HTML tutorial</a>.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">XHTML is a combination of HTML and XML (EXtensible Markup Language).</p> <p class="intro">XHTML consists of all the elements in HTML 4.01 combined with the syntax of XML.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Why XHTML?</h2> <p>We have reached a point where many pages on the WWW contain "bad" HTML.</p> <p>The following HTML code will work fine if you view it in a browser, even if it does not follow the HTML rules:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre></pre><pre><title>This is bad HTML</title></pre><pre></pre><pre><h1>Bad HTML</h1></pre><pre></pre></td> </tr> </tbody></table> <p>XML is a markup language where everything has to be marked up correctly, which results in "well-formed" documents.</p> <p>XML was designed to describe data and HTML was designed to display data. </p> <p>Today's market consists of different browser technologies, some browsers run Internet on computers, and some browsers run Internet on mobile phones and hand helds. The last-mentioned do not have the resources or power to interpret a "bad" markup language.</p> <p>Therefore - by combining HTML and XML, and their strengths, we got a markup language that is useful now and in the future - XHTML.</p> <p>XHTML pages can be read by all XML enabled devices AND while waiting for the rest of the world to upgrade to XML supported browsers, XHTML gives you the opportunity to write "well-formed" documents now, that work in all browsers and that are backward browser compatible !!!</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">You can prepare yourself for XHTML by starting to write strict HTML.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How To Get Ready For XHTML</h2> <p>XHTML is not very different from HTML 4.01, so bringing your code up to the 4.01 standard is a good start. Our complete <a href="http://www.w3schools.com/html/html_reference.asp">HTML 4.01 reference</a> can help you with that.</p> <p>In addition, you should start NOW to write your HTML code in lowercase letters, and NEVER make the bad habit of skipping end tags like the </p>.<p></p> <p>Happy coding!</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Most Important Differences:</h2> <ul type="disc"><li class="MsoNormal" style="">XHTML elements must be <b>properly nested</b> </li><li class="MsoNormal" style="">XHTML documents must be <b>well-formed</b> </li><li class="MsoNormal" style="">Tag names must be in <b>lowercase</b> </li><li class="MsoNormal" style="">All XHTML elements must be <b>closed</b> </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Elements Must Be Properly Nested</h2> <p>In HTML some elements can be improperly nested within each other like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><b><i>This text is bold and italic</i></b><i></i></pre></td> </tr> </tbody></table> <p>In XHTML all elements must be properly nested within each other like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><b><i>This text is bold and italic</i></b></pre></td> </tr> </tbody></table> <p><b>Note:</b> A common mistake in nested lists, is to forget that the inside list must be within a li element, like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><ul></ul></pre><pre><span style=""> </span><li>Coffee</li></pre><pre><span style=""> </span><li>Tea</li></pre><pre><span style=""> </span><ul></ul></pre><pre><span style=""> </span><li>Black tea</li></pre><pre><span style=""> </span><li>Green tea</li></pre><pre><span style=""> </span></pre><pre><span style=""> </span><li>Milk</li></pre><pre></pre></td> </tr> </tbody></table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><ul></ul></pre><pre><span style=""> </span><li>Coffee</li></pre><pre><span style=""> </span><li>Tea</li></pre><pre><span style=""> </span><ul></ul></pre><pre><span style=""> </span><li>Black tea</li></pre><pre><span style=""> </span><li>Green tea</li></pre><pre><span style=""> </span></pre><pre><span style=""> </span></pre><pre><span style=""> </span><li>Milk</li></pre><pre></pre></td> </tr> </tbody></table> <p>Notice that we have inserted a tag after the tag in the "correct" code example.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Documents Must Be Well-formed</h2> <p>All XHTML elements must be nested within the root element. All other elements can have sub (children) elements. Sub elements must be in pairs and correctly nested within their parent element. The basic document structure is:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre> ... </pre><pre> ... </pre><pre></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Tag Names Must Be In Lower Case</h2> <p>This is because XHTML documents are XML applications. XML is case-sensitive. Tags like <code><span style="font-size:10;">
<br /></span></code> and <code><span style="font-size:10;">
<br /></span></code> are interpreted as different tags.</p> <p>This is wrong:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre><p>This is a paragraph</p></pre><pre></pre></td> </tr> </tbody></table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre><p>This is a paragraph</p></pre><pre></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>All XHTML Elements Must Be Closed</h2> <p><b>Non-empty elements must have an end tag.</b></p> <p>This is wrong:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><p>This is a paragraph</p></pre><pre><p>This is another paragraph</p></pre></td> </tr> </tbody></table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><p>This is a paragraph</p></pre><pre><p>This is another paragraph</p></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Empty Elements Must Also Be Closed</h2> <p><b>Empty elements must either have an end tag or the start tag must end with </b><code><b><span style="font-size:10;">/></span></b></code><b>.</b></p> <p>This is wrong:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>This is a break
<br /></pre><pre>Here comes a horizontal rule:<hr /></pre><pre>Here's an image <img src="http://www.blogger.com/happy.gif" alt="Happy face" /></pre></td> </tr> </tbody></table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre>This is a break
<br /></pre><pre><o:p> </o:p></pre><pre>Here comes a horizontal rule:<hr /></pre><pre>Here's an image <img src="http://www.blogger.com/happy.gif" alt="Happy face" /></pre></td> </tr> </tbody></table> <p class="MsoNormal">
<br /><b>IMPORTANT Compatibility Note:</b> </p> <p>To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol like this:
<br />, and this: </p><hr />. <p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">Writing XHTML demands a clean HTML syntax.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Some More XHTML Syntax Rules:</h2> <ul type="disc"><li class="MsoNormal" style="">Attribute names must be in <b>lower case</b> </li><li class="MsoNormal" style="">Attribute values must be <b>quoted</b> </li><li class="MsoNormal" style="">Attribute minimization is <b>forbidden</b> </li><li class="MsoNormal" style="">The id attribute <b>replaces</b> the name attribute </li><li class="MsoNormal" style="">The XHTML DTD defines <b>mandatory</b> elements </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Attribute Names Must Be In Lower Case</h2> <p>This is wrong:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><table width="100%"> </table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><table width="100%"> </table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Attribute Values Must Be Quoted</h2> <p>This is wrong:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><table width="100%"> </table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><table width="100%"> </table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Attribute Minimization Is Forbidden</h2> <p>This is wrong: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><input></pre><pre><input></pre><pre><input></pre><pre></pre><pre></pre></td> </tr> </tbody></table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><input checked="checked"></pre><pre><input readonly="readonly"></pre><pre><input disabled="disabled"></pre><pre></pre><pre></pre></td> </tr> </tbody></table> <p>Here is a list of the minimized attributes in HTML and how they should be written in XHTML:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><b>HTML<o:p></o:p></b></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><b>XHTML <o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">compact</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">compact="compact" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">checked</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">checked="checked" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">declare</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">declare="declare" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">readonly</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">readonly="readonly" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">disabled</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">disabled="disabled" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">selected</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">selected="selected" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">defer</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">defer="defer" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">ismap</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">ismap="ismap" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">nohref</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">nohref="nohref" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">noshade</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">noshade="noshade" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">nowrap</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">nowrap="nowrap" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">multiple</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">multiple="multiple" </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">noresize</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">noresize="noresize" </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The id Attribute Replaces The name Attribute</h2> <p>HTML 4.01 defines a name attribute for the elements a, applet, frame, iframe, img, and map. In XHTML the name attribute is deprecated. Use id instead.</p> <p>This is wrong:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><img src="http://www.blogger.com/picture.gif" name="picture1" /></pre></td> </tr> </tbody></table> <p>This is correct:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><img src="http://www.blogger.com/picture.gif" id="picture1" /></pre></td> </tr> </tbody></table> <p><b>Note:</b> To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><img src="http://www.blogger.com/picture.gif" id="picture1" name="picture1" /></pre></td> </tr> </tbody></table> <p><b>IMPORTANT Compatibility Note:</b></p> <p>To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Lang Attribute</h2> <p>The lang attribute applies to almost every XHTML element. It specifies the language of the content within an element.</p> <p>If you use the lang attribute in an element, you must add the xml:lang attribute, like this: </p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><div lang="no">Heia Norge!</div></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Mandatory XHTML Elements</h2> <p>All XHTML documents must have a DOCTYPE declaration. The html, head and body elements must be present, and the title must be present inside the head element.</p> <p>This is a minimum XHTML document template:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre></pre><pre></pre><pre><title>Title goes here</title></pre><pre></pre><pre></pre><pre>Body text goes here</pre><pre></pre><pre></pre></td> </tr> </tbody></table> <p><b>Note</b>: The DOCTYPE declaration is not a part of the XHTML document itself. It is not an XHTML element, and it should not have a closing tag.</p> <p><b>Note</b>: The xmlns attribute inside the tag is required in XHTML. However, the validator on w3.org does not complain when this attribute is missing in an XHTML document. This is because "xmlns=http://www.w3.org/1999/xhtml" is a fixed value and will be added to the tag even if you do not include it.</p> <p>You will learn more about the XHTML document type definition in the next chapter.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">The XHTML standard defines three Document Type Definitions.</p> <p class="intro">The most common is the XHTML Transitional.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Is Mandatory</h2> <p>An XHTML document consists of three main parts:</p> <ul type="disc"><li class="MsoNormal" style="">the DOCTYPE </li><li class="MsoNormal" style="">the Head </li><li class="MsoNormal" style="">the Body </li></ul> <p>The basic document structure is:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre></pre><pre></pre><pre><title>... </title></pre><pre></pre><pre> ... </pre><pre></pre></td> </tr> </tbody></table> <p>The DOCTYPE declaration should always be the first line in an XHTML document.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>An XHTML Example</h2> <p>This is a simple (minimal) XHTML document:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre>PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></pre><pre></pre><pre></pre><pre><title>simple document</title></pre><pre></pre><pre></pre><pre><p>a simple paragraph</p></pre><pre></pre><pre></pre></td> </tr> </tbody></table> <p>The DOCTYPE declaration defines the document type:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre>PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></pre></td> </tr> </tbody></table> <p>The rest of the document looks like HTML:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre></pre><pre><title>simple document</title></pre><pre></pre><pre></pre><pre><p>a simple paragraph</p></pre><pre></pre><pre></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The 3 Document Type Definitions</h2> <ul type="disc"><li class="MsoNormal" style="">DTD specifies the syntax of a web page in SGML. </li><li class="MsoNormal" style="">DTD is used by SGML applications, such as HTML, to specify rules that apply to the markup of documents of a particular type, including a set of element and entity declarations. </li><li class="MsoNormal" style="">XHTML is specified in an SGML document type definition or 'DTD'. </li><li class="MsoNormal" style="">An XHTML DTD describes in precise, computer-readable language, the allowed syntax and grammar of XHTML markup. </li></ul> <p><b>There are currently 3 XHTML document types:</b></p> <ul type="disc"><li class="MsoNormal" style="">STRICT </li><li class="MsoNormal" style="">TRANSITIONAL </li><li class="MsoNormal" style="">FRAMESET </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p>XHTML 1.0 specifies three XML document types that correspond to three DTDs: Strict, Transitional, and Frameset.</p> <h3>XHTML 1.0 Strict</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre>PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" </pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></pre></td> </tr> </tbody></table> <p>Use this when you want really clean markup, free of presentational clutter. Use this together with Cascading Style Sheets.</p> <h3>XHTML 1.0 Transitional</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre>PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></pre></td> </tr> </tbody></table> <p>Use this when you need to take advantage of HTML's presentational features and when you want to support browsers that don't understand Cascading Style Sheets.</p> <h3>XHTML 1.0 Frameset</h3> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre>PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"></pre></td> </tr> </tbody></table> <p>Use this when you want to use HTML Frames to partition the browser window into two or more frames.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>How W3Schools Was Converted To XHTML</h2> <p>W3Schools was converted from HTML to XHTML the weekend of 18. and 19. December 1999, by Hege Refsnes and Ståle Refsnes.</p> <p>To convert a Web site from HTML to XHTML, you should be familiar with the XHTML syntax rules of the previous chapters. The following steps were executed (in the order listed below):</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>A DOCTYPE Definition Was Added</h2> <p>The following DOCTYPE declaration was added as the first line of every page:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre>"-//W3C//DTD XHTML 1.0 Transitional//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></pre></td> </tr> </tbody></table> <p>Note that we used the transitional DTD. We could have chosen the strict DTD, but found it a little too "strict", and a little too hard to conform to.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>A Note About The DOCTYPE</h2> <p>Your pages must have a DOCTYPE declaration if you want them to validate as correct XHTML.</p> <p>Be aware however, that newer browsers (like Internet Explorer 6) might treat your document differently depending on the declaration. If the browser reads a document with a DOCTYPE, it might treat the document as "correct". Malformed XHTML might fall over and display differently than without a DOCTYPE.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Lower Case Tag And Attribute Names</h2> <p>Since XHTML is case sensitive, and since XHTML only accepts lower case HTML tags and attribute names, a general search and replace function was executed to replace all upper case tags with lowercase tags. The same was done for attribute names. We have always tried to use lower case names in our Web, so the replace function did not produce many real substitutions. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>All Attributes Were Quoted</h2> <p>Since the W3C XHTML 1.0 Recommendation states that all attribute values must be quoted, every page in the web was checked to see that attributes values were properly quoted. This was a time-consuming job, and we will surely never again forget to put quotes around our attribute values. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Empty Tags: <hr /> ,
<br />and <img src="" /></h2> <p>Empty tags are not allowed in XHTML. The </p><hr /> and
<br />tags should be replaced with <hr /> and
<br />.<p></p> <p>This produced a problem with Netscape that misinterpreted the
<br />tag. We don't know why, but changing it to
<br />worked fine. After that discovery, a general search and replace function was executed to swap the tags.</p> <p>A few other tags (like the <img src="" /> tag) were suffering from the same problem as above. We decided not to close the <img src="" /> tags with , but with /> at the end of the tag. This was done manually.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>The Web Site Was Validated</h2> <p>After that, all pages were validated against the official W3C DTD with this link: <a href="http://validator.w3.org/check/referer" target="_blank">XHTML Validator</a>. A few more errors were found and edited manually. The most common error was missing tags in lists. </p> <p>Should we have used a converting tool? Well, we could have used <b>TIDY</b>. </p> <p><a href="http://www.w3.org/People/Raggett/tidy/" target="_blank">Dave Raggett's HTML TIDY</a> is a free utility for cleaning up HTML code. It also works great on the hard-to-read markup generated by specialized HTML editors and conversion tools, and it can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities. </p> <p>The reason why we didn't use Tidy? We knew about XHTML when we started writing this web site. We knew that we had to use lowercase tag names and that we had to quote our attributes. So when the time came (to do the conversion), we simply had to test our pages against the W3C XHTML validator and correct the few mistakes. AND - we have learned a lot about writing "tidy" HTML code. </p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="intro">An XHTML document is validated against a Document Type Definition.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Validate XHTML With A DTD</h2> <p>An XHTML document is validated against a Document Type Definition (DTD). Before an XHTML file can be properly validated, a correct DTD must be added as the first line of the file.</p> <p>The Strict DTD includes elements and attributes that have not been deprecated or do not appear in framesets:</p> <pre>!DOCTYPE html PUBLIC</pre><pre>"-//W3C//DTD XHTML 1.0 Strict//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"</pre> <p>The Transitional DTD includes everything in the strict DTD plus deprecated elements and attributes:</p> <pre>!DOCTYPE html PUBLIC</pre><pre>"-//W3C//DTD XHTML 1.0 Transitional//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</pre> <p>The Frameset DTD includes everything in the transitional DTD plus frames as well:</p> <pre>!DOCTYPE html PUBLIC</pre><pre>"-//W3C//DTD XHTML 1.0 Frameset//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"</pre> <p>This is a simple XHTML document:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre></pre><pre>PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"</pre><pre>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></pre><pre></pre><pre></pre><pre><title>simple document</title></pre><pre></pre><pre></pre><pre><p>a simple paragraph</p></pre><pre></pre><pre></pre></td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Test Your XHTML With The W3C Validator</h2> <form> <p>Input your page address in the box below:</p> <p><input size="60" name="uri" value="http://www.w3schools.com/xhtml/default.asp" type="text"></p> <p class="MsoNormal"><input action="http://validator.w3.org/check" value="Validate the page" method="get" type="submit"></p> </form> <p class="intro">The XHTML modularization model defines the modules of XHTML.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Why XHTML Modularization?</h2> <p>XHTML is a simple, but large language. XHTML contains most of the functionality a web developer will need.</p> <p>For some purposes XHTML is too large and complex, and for other purposes it is much too simple.</p> <p>By splitting XHTML into modules, the W3C (World Wide web Consortium) has created small and well-defined sets of XHTML elements that can be used separately for simple devices as well as combined with other XML standards into larger and more complex applications.</p> <p>With modular XHTML, product and application designers can:</p> <ul type="disc"><li class="MsoNormal" style="">Choose the elements to be supported by a device using standard XHTML building blocks. </li><li class="MsoNormal" style="">Add extensions to XHTML, using XML, without breaking the XHTML standard. </li><li class="MsoNormal" style="">Simplify XHTML for devices like hand held computers, mobile phones, TV, and home appliances. </li><li class="MsoNormal" style="">Extend XHTML for complex applications by adding new XML functionality (like MathML, SVG, Voice and Multimedia). </li><li class="MsoNormal" style="">Define XHTML profiles like XHTML Basic (a subset of XHTML for mobile devices). </li></ul> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>XHTML Modules</h2> <p>W3C has split the definition of XHTML into 28 modules:</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b>Module name<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 65%;" valign="top" width="65%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Applet Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the deprecated* applet element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Base Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the base element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Basic Forms Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the basic forms elements.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Basic Tables Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the basic table elements.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Bi-directional Text Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the bdo element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Client Image Map Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines browser side image map elements.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Edit Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the editing elements <st1:state st="on"><st1:place st="on">del</st1:place></st1:state> and ins.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Forms Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines all elements used in forms.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Frames Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the frameset elements.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Hypertext Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the a element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Iframe Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the iframe element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Image Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the img element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Intrinsic Events Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines event attributes like onblur and onchange.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Legacy Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines deprecated* elements and attributes.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Link Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the link element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">List Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the list elements ol, li, ul, dd, dt, and dl.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Metainformation Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the meta element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Name Identification Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the deprecated* name attribute.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Object Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the object and param elements.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Presentation Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines presentation elements like b and i.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Scripting Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the script and noscript elements.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Server Image Map Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines server side image map elements.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Structure Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the elements html, head, title and body.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Style Attribute Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the style attribute.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Style Sheet Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the style element.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Tables Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the elements used in tables.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Target Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines the target attribute.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Text Module</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Defines text container elements like p and h1.</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <p>* Deprecated elements should not be used in XHTML.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p>XHTML tags can have attributes. The special attributes for each tag are listed under each tag description. The attributes listed here are the core and language attributes that are standard for all tags (with a few exceptions).</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Core Attributes</h2> <p>Not valid in base, head, html, meta, param, script, style, and title elements.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Attribute<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b>Value<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 45%;" valign="top" width="45%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">class</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>class_rule </i>or<i> style_rule</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">The class of the element</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">id</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>id_name</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">A unique id for the element </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">style</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>style_definition</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">An inline style definition </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">title</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>tooltip_text </i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">A text to display in a tool tip </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Language Attributes</h2> <p>Not valid in base, br, frame, frameset, hr, iframe, param, and script elements.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Attribute<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b>Value<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 45%;" valign="top" width="45%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">dir</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">ltr | rtl</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Sets the text direction </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">lang</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>language_code</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Sets the language code </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Keyboard Attributes</h2> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 20%;" valign="top" width="20%"> <p class="MsoNormal"><b>Attribute<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 35%;" valign="top" width="35%"> <p class="MsoNormal"><b>Value<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 45%;" valign="top" width="45%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">accesskey</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>character</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Sets a keyboard shortcut to access an element</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">tabindex</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>number</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Sets the tab order of an element</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p>New to HTML 4.0 was the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of attributes that can be inserted into HTML tags to define event actions.</p> <p>If you want to learn more about programming with these events, you should study our <a href="http://www.w3schools.com/js/default.asp">JavaScript tutorial</a> and our <a href="http://www.w3schools.com/dhtml/default.asp">DHTML tutorial</a>.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Window Events</h2> <p>Only valid in body and frameset elements</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Attribute<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b>Value<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onload</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when a document loads </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onunload</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when a document unloads </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Form Element Events</h2> <p>Only valid in form elements.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Attribute<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b>Value<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onchange</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when the element changes </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onsubmit</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when the form is submitted </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onreset</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when the form is reset </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onselect</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script </i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when the element is selected </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onblur</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script </i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when the element loses focus </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onfocus</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script </i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Script to be run when the element gets focus </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Keyboard Events</h2> <p>Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Attribute<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b>Value<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onkeydown</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when key is pressed </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onkeypress</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when key is pressed and released </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onkeyup</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when key is released </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>Mouse Events</h2> <p>Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.</p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 25%;" valign="top" width="25%"> <p class="MsoNormal"><b>Attribute<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 15%;" valign="top" width="15%"> <p class="MsoNormal"><b>Value<o:p></o:p></b></p> </td> <td style="padding: 0.75pt; width: 60%;" valign="top" width="60%"> <p class="MsoNormal"><b>Description<o:p></o:p></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onclick</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do on a mouse click </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">ondblclick</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do on a mouse doubleclick </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onmousedown</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when mouse button is pressed </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onmousemove</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when mouse pointer moves </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onmouseover</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when mouse pointer moves over an element </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onmouseout</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i></p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when mouse pointer moves out of an element </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">onmouseup</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><i>script</i> </p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">What to do when mouse button is released </p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <h2>XHTML Summary</h2> <p>This tutorial has taught you how to create stricter and cleaner HTML pages.</p> <p>You have learned that all XHTML elements must be properly nested, XHTML documents must be well-formed, all tag names must be in lowercase, and that all XHTML elements must be closed.</p> <p>You have also learned that all XHTML documents must have a DOCTYPE declaration, and that the html, head, title, and body elements must be present.</p> <p>For more information on XHTML, please look at our <a href="http://www.w3schools.com/tags/default.asp">XHTML reference</a>.</p> <div class="MsoNormal" style="text-align: center;" align="center"> <hr align="center" size="2" width="100%"> </div> <p class="MsoNormal"><span style="font-size:11;"><o:p> </o:p></span></p> </pre></td></tr></tbody></table></pre></td></tr></tbody></table></pre></td></tr></tbody></table></pre></td></tr></tbody></table>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-20190548909353130912009-01-02T02:03:00.000-08:002009-01-02T02:21:23.420-08:00Servlet<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="0" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Code"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Helvetica; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:Courier; panose-1:2 7 4 9 2 2 5 2 4 4; mso-font-charset:0; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"Tms Rmn"; panose-1:2 2 6 3 4 5 5 2 3 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:Helv; panose-1:2 11 6 4 2 2 2 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"New York"; panose-1:2 4 5 3 6 5 6 2 3 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:System; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"MS Mincho"; panose-1:2 2 6 9 4 2 5 8 3 4; mso-font-alt:"MS 明朝"; mso-font-charset:128; mso-generic-font-family:modern; mso-font-pitch:fixed; mso-font-signature:-1610612033 1757936891 16 0 131231 0;} @font-face {font-family:Batang; panose-1:2 3 6 0 0 1 1 1 1 1; mso-font-alt:바탕; mso-font-charset:129; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 151388160 16 0 524288 0;} @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:PMingLiU; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-alt:新細明體; mso-font-charset:136; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:1 134742016 16 0 1048576 0;} @font-face {font-family:"MS Gothic"; panose-1:2 11 6 9 7 2 5 8 2 4; mso-font-alt:"MS ゴシック"; mso-font-charset:128; mso-generic-font-family:modern; mso-font-pitch:fixed; mso-font-signature:-1610612033 1757936891 16 0 131231 0;} @font-face {font-family:Dotum; panose-1:2 11 6 0 0 1 1 1 1 1; mso-font-alt:돋움; mso-font-charset:129; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 151388160 16 0 524288 0;} @font-face {font-family:SimHei; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:黑体; mso-font-charset:134; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:MingLiU; panose-1:2 2 3 9 0 0 0 0 0 0; mso-font-alt:細明體; mso-font-charset:136; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 134742016 16 0 1048576 0;} @font-face {font-family:Mincho; panose-1:2 2 6 9 4 3 5 8 3 5; mso-font-alt:明朝; mso-font-charset:128; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 134676480 16 0 131072 0;} @font-face {font-family:Gulim; panose-1:2 11 6 0 0 1 1 1 1 1; mso-font-alt:굴림; mso-font-charset:129; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:1 151388160 16 0 524288 0;} @font-face {font-family:Century; panose-1:2 4 6 4 5 5 5 2 3 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"Angsana New"; panose-1:2 2 6 3 5 4 5 2 3 4; mso-font-charset:222; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:16777217 0 0 0 65536 0;} @font-face {font-family:"Cordia New"; panose-1:2 11 3 4 2 2 2 2 2 4; mso-font-charset:222; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:16777217 0 0 0 65536 0;} @font-face {font-family:Mangal; panose-1:0 0 4 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:8192 0 0 0 0 0;} @font-face {font-family:Latha; panose-1:2 0 4 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:262144 0 0 0 0 0;} @font-face {font-family:Sylfaen; panose-1:1 10 5 2 5 3 6 3 3 3; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:12583555 0 0 0 13 0;} @font-face {font-family:Vrinda; panose-1:1 1 6 0 1 1 1 1 1 1; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Raavi; panose-1:2 0 5 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Shruti; panose-1:2 0 5 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Sendnya; panose-1:0 0 4 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Gautami; panose-1:2 0 5 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Tunga; panose-1:0 0 4 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:"Estrangelo Edessa"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:"Arial Unicode MS"; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1073741899 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:1627400839 -2147483648 8 0 66047 0;} @font-face {font-family:"Arial Narrow"; panose-1:2 11 6 6 2 2 2 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 2048 0 0 159 0;} @font-face {font-family:Consolas; panose-1:2 11 6 9 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h1 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 1 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:1; font-size:24.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} code {mso-style-unhide:no; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 1"; mso-ansi-font-size:24.0pt; mso-bidi-font-size:24.0pt; mso-font-kerning:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} span.msoIns {mso-style-type:export-only; mso-style-name:""; text-decoration:underline; text-underline:single; color:teal;} span.msoDel {mso-style-type:export-only; mso-style-name:""; text-decoration:line-through; color:red;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:.5in 1.25in .5in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:25524463; mso-list-template-ids:-2064469416;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:209610033; mso-list-template-ids:-1004109678;} @list l1:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l2 {mso-list-id:280648188; mso-list-template-ids:-1423792486;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l3 {mso-list-id:472212577; mso-list-template-ids:794434452;} @list l3:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l4 {mso-list-id:515777162; mso-list-template-ids:1952363212;} @list l4:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l5 {mso-list-id:584268219; mso-list-template-ids:-804759574;} @list l5:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l6 {mso-list-id:624626267; mso-list-template-ids:-164618924;} @list l6:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l7 {mso-list-id:679740824; mso-list-template-ids:-1277926438;} @list l7:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l8 {mso-list-id:841627151; mso-list-template-ids:388393006;} @list l8:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l9 {mso-list-id:860356738; mso-list-template-ids:1757726618;} @list l9:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l10 {mso-list-id:971056835; mso-list-template-ids:1976725074;} @list l10:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l10:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l11 {mso-list-id:1016268656; mso-list-template-ids:-339447434;} @list l11:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l12 {mso-list-id:1049184677; mso-list-template-ids:-85679004;} @list l12:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l13 {mso-list-id:1077245988; mso-list-template-ids:-1349386040;} @list l13:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l14 {mso-list-id:1106970398; mso-list-template-ids:1852455730;} @list l14:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l15 {mso-list-id:1129711588; mso-list-template-ids:-1276759484;} @list l15:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l16 {mso-list-id:1140920341; mso-list-template-ids:1193288814;} @list l16:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l17 {mso-list-id:1252160803; mso-list-template-ids:378144638;} @list l17:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l18 {mso-list-id:1333605106; mso-list-template-ids:1640152796;} @list l18:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l19 {mso-list-id:1382703903; mso-list-template-ids:-511043944;} @list l19:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l20 {mso-list-id:1467121180; mso-list-template-ids:1936877314;} @list l20:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l21 {mso-list-id:1505585108; mso-list-template-ids:-710782186;} @list l21:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l22 {mso-list-id:1516915699; mso-list-template-ids:-544583508;} @list l22:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l23 {mso-list-id:1567108218; mso-list-template-ids:-265229406;} @list l23:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l24 {mso-list-id:1650086864; mso-list-template-ids:1249793610;} @list l24:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l25 {mso-list-id:1843275197; mso-list-template-ids:398886964;} @list l25:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l26 {mso-list-id:1855683978; mso-list-template-ids:-1061382308;} @list l26:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l27 {mso-list-id:1855879716; mso-list-template-ids:812840696;} @list l27:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l28 {mso-list-id:1999503641; mso-list-template-ids:-1343599512;} @list l28:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <h1><span style=";font-family:";font-size:9;color:navy;" >Writing Hello World</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >As we know that the our servlet extends the <b>HttpServlet</b> and overrides the <i>doGet() </i>method which it inherits from the HttpServlet class. The server invokes doGet() method whenever web server recieves the GET request from the servlet. The doGet() method takes two arguments first is HttpServletRequest object and the second one is HttpServletResponse object and this method throws the ServletException.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Whenever the user sends the request to the server then server generates two obects, first is HttpServletRequest object and the second one is HttpServletResponse object. HttpServletRequest object represents the client's request and the HttpServletResponse represents the servlet's response. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Inside the doGet(() method our servlet has first used the <i>setContentType() </i>method of the response object which sets the content type of the response to <i>text/html</i>. It is the standard MIME content type for the Html pages. After that it has used the method <i>getWriter()</i> of the response object to retrieve a <b>PrintWriter</b> object. To display the output on the browser we use the <i>println()</i> method of the <b>PrintWriter</b> class. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >HelloWorld </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{ </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException,IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"<title>Hello World</title>"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"<h1>Hello World</h1>"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:<o:p></o:p></span></b></p> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>HelloWorld</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/HelloWorld</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below: </span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p>
<br /><h1><span style=";font-family:";font-size:9;color:navy;" >Displaying Date in Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to show how we can display a current date and time on our browser. It is very easy to display it on our browser by using the <b>Date</b> class of the <b>java.util</b> package.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.util.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >DisplayingDate </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code><span style="color:black;">
<br /> </span> <code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > response) </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Date today = </span></code><code><b><span style=";font-family:";" >new </span></b></code><code><span style=";font-family:";color:black;" >Date();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"<h1>Today Date is</h1>"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"<b>"</b></span></code><code><span style=";font-family:";color:black;" ><b>+ today+</b></span></code><code><span style=";font-family:";" ><b>"</b>"</span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><b><span style=";font-family:";font-size:9;color:navy;" >XML File for this program<o:p></o:p></span></b></p> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>DateDisplay</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/DateDisplay</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <b><span style="color:navy;">The output of the program is given below:</span></b><o:p></o:p></span></p>
<br /><h1><span style=";font-family:";font-size:9;color:navy;" ><o:p> </o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p> </o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p> </o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p> </o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p> </o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" >Simple Counter In Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to know how we can make a program on counter which will keep track how many times the servlet has been accessed. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make this program firstly we have to make one class <b>SimpleCounterInServlet.</b> The name of the class should follow the naming convention. Remember to keep the name of the class in such a way that it becomes easy to understand what the program is going to do just by seeing the class name. After making a class define one variable <i>counter </i>which will keep record for how many times the servlet has been accessed. Now use method either <b>doGet() </b>or <b>doPost() </b>to write a logic of the program. Our program logic is simple. We have to just increment the value of the counter by 1. To display the output use the method <b>getWriter()</b> method of the response object which will in turn return the object of the PrintWriter class. Now display the value of the counter. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >SimpleCounter </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >counter = </span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >counter++;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"At present the value of the counter is " </span></code><code><span style=";font-family:";color:black;" >+ counter);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 75.34%;" border="1" cellpadding="0" width="75%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.1%;" width="99%">
<br /></td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p>
<br /></o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p> </o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p> </o:p>A Holistic counter in Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to make a such a servlet which will count the number it has been accessed and the number of threads created by the server.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example firstly we are going to create one class named as HolisticCounterInServlet. Now declare a variable counter of int with initial value 0, the value of this counter will be different for each servlet and create a <b>Hashtable</b> object. This object will be shared by all the threads in the container. Inside the doGet() method use the method getWriter() method of the response object which will return the PrintWriter object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.IOException;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.util.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >HolisticCounter </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >counter = </span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >; </span></code><code><span style=";font-family:";" >//separate For Each Servlet</span></code>
<br /> <code><b><span style=";font-family:";" >static </span></b></code><code><span style=";font-family:";color:black;" >Hashtable hashTable = </span></code><code><b><span style=";font-family:";" >new </span></b></code><code><span style=";font-family:";color:black;" >Hashtable(); </span></code><code><span style=";font-family:";" >//Shared by all the threads </span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >counter++;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"This servlet has been accessed" </span></code><code><span style=";font-family:";color:black;" >+ counter + </span></code><code><span style=";font-family:";" >"times
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >hashTable.put(this,this);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"There are currently" </span></code><code><span style=";font-family:";color:black;" >+ hashTable.size() + </span></code><code><span style=";font-family:";" >"threads
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 75.34%;" border="1" cellpadding="0" width="75%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.1%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" alt="" style="'width:324pt;height:120.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image006.gif" href="http://www.roseindia.net/servlets/HolisticCounter.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" ><o:p>
<br /></o:p></span></h1> <h1><span style=";font-family:";font-size:9;color:navy;" >Counter in Init() Method</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to make a such a servlet which will count and displays the number of times it has been accessed and by reading the init parameter to know from where the counting will begin.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to make use of the init method of the <b>Servlet</b> interface which takes one argument of ServletConfig. Firstly declare a variable counter which will have the initial value of the counter. The init() method accepts an object which implements ServletConfig interface. It uses the method getInitParameter() method of the ServletConfig interface to the value of the init parameter <i>initial</i> which we have defined in the deployment descriptor file. You need to <i>parse</i> the String value which you will get from the <b>getInitParameter() </b>method to a Integer. <o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >CounterInInit </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >counter;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >init(ServletConfig config) </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >super</span></b></code><code><span style=";font-family:";color:black;" >.init(config);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String initValue = config.getInitParameter(</span></code><code><span style=";font-family:";" >"initial"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >counter = Integer.parseInt(initValue);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(NumberFormatException e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >counter = </span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >counter++;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Since loading this servlet has been accessed" </span></code><code><span style=";font-family:";color:black;" >+ counter + </span></code><code><span style=";font-family:";" >"times"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:<o:p></o:p></span></b></p> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>CounterInInit</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/CounterInInit</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 84.42%;" border="1" cellpadding="0" width="84%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.18%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" alt="" style="'width:363.75pt;height:68.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image007.png" href="http://www.roseindia.net/servlets/CounterinInit.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Snooping the server</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to tell you how can a use servlet to display information about its server. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Firstly we will create a class in which there will be <b>doGet()</b> method which takes two objects as arguments, first is request object and the second one is of response. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To display the name of the server you are using use the method <b>getServerName()</b> of the <b><i>ServletRequest</i></b> interface. To display the server port number use the method <b>getServerPort()</b>. You can also use other methods of the <b><i>ServletRequest</i></b> interface like <b>getProtocol()</b> to display the protocol you are using and many more methods depending on your needs. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >SnoopingServerServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" > throws </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The server name is " </span></code><code><span style=";font-family:";color:black;" >+ request.getServerName() + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The server port number is " </span></code><code><span style=";font-family:";color:black;" >+ request.getServerPort()+ </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The protocol is " </span></code><code><span style=";font-family:";color:black;" >+ request.getProtocol()+ </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The scheme used is " </span></code><code><span style=";font-family:";color:black;" >+ request.getScheme());</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>SnoopingServerServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/SnoopingServerServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below: </span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 82%;" border="1" cellpadding="0" width="82%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.16%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" alt="" style="'width:353.25pt;height:141pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image009.gif" href="http://www.roseindia.net/servlets/SnoopingServer.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >nooping Headers</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to going to make a servlet which will retrieve all the Http request header. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make a program over this firstly we need to make one class named <b>GettingSnoopingHeader</b>. In <b>HttpRequest</b> there are too many headers. To retrieve all the headers firstly we need to call the <b>getWriter()</b> which returns <b>PrintWriter</b> object and helps us to display all the headers. To get a header names call the method getHeaderNames() of the request object which will return the Enumeration of the headers. Now to retrieve all the headers from the Enumeration use the method hasMoreElements(). This method checks whether there are more headers or not. To display the output on your browser use the PrintWriter object.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 83.32%; margin-left: -0.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="83%"> <tbody><tr style=""> <td style="border: medium none ; padding: 0in;" width="0%"><p class="MsoNormal"> </p>
<br /></td> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.util.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >HeaderSnoopServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Request Headers are"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Enumeration enumeration = request.getHeaderNames();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while</span></b></code><code><span style=";font-family:";color:black;" >(enumeration.hasMoreElements()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String headerName = (String)enumeration.nextElement();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Enumeration headerValues = request.getHeaders(headerName);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(headerValues != </span></code><code><b><span style=";font-family:";" >null</span></b></code><code><span style=";font-family:";color:black;" >){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while </span></b></code><code><span style=";font-family:";color:black;" >(headerValues.hasMoreElements()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String values = (String) headerValues.nextElement();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(headerName + </span></code><code><span style=";font-family:";" >": " </span></code><code><span style=";font-family:";color:black;" >+ values);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code><o:p></o:p></span></p> </td> <td style="border: medium none ; padding: 0in;" width="5%"><p class="MsoNormal"> </p>
<br /></td> </tr> <tr style=""> <td style="border-style: none none outset; border-color: -moz-use-text-color; border-width: medium medium 1pt;" width="0%"><p class="MsoNormal"> </p>
<br /></td> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:<o:p></o:p></span></b></p> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>HeaderSnoopServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/HeaderSnoopServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> <td style="border-style: none none outset; border-color: -moz-use-text-color; border-width: medium medium 1pt;" width="5%"><p class="MsoNormal"> </p>
<br /></td> </tr> <tr style="height: 77.25pt;"> <td colspan="3" style="border: 1pt inset ; padding: 0.75pt; background: transparent none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; height: 77.25pt;" width="100%"> <p class="MsoNormal"><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1031" type="#_x0000_t75" alt="" style="'width:357.75pt;height:77.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image010.png" href="http://www.roseindia.net/servlets/SnoopingHeaders.gif"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--><o:p></o:p></span></p> </td> </tr> <!--[if !supportMisalignedColumns]--> <tr height="0"> <td style="border: medium none ;" width="1">
<br /></td> <td style="border: medium none ;" width="590">
<br /></td> <td style="border: medium none ;" width="32">
<br /></td> </tr> <!--[endif]--> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Dice Roller</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >We are going to make one program on the dice roller in which the number in the dice will be selected randomly. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make a program over this firstly we need to make a class <b>DiceRoller</b> in which we will have a <b>doGet() </b>method in which we will have our application logic. To make the dice working randomly use the random() method of the class <b>java.lang.Math.</b> To print the number on the browser call the method <b>getWriter()</b> of the response object which will return the <b>PrintWriter</b> object. Now by the object of the <b>PrintWriter</b> class print the values of the dice on the browser. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >DiceRollerServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" >throws </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String dice1 = Integer.toString((</span></code><code><b><span style=";font-family:";" >int</span></b></code><code><span style=";font-family:";color:black;" >)(Math.random()*</span></code><code><span style=";font-family:";" >6</span></code><code><span style=";font-family:";color:black;" >)+</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String dice2 = Integer.toString((</span></code><code><b><span style=";font-family:";" >int</span></b></code><code><span style=";font-family:";color:black;" >)(Math.random()*</span></code><code><span style=";font-family:";" >6</span></code><code><span style=";font-family:";color:black;" >)+</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"dice roller
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"dice1 value is " </span></code><code><span style=";font-family:";color:black;" >+ dice1 + </span></code><code><span style=";font-family:";" >" and
<br />dice2 value is " </span></code><code><span style=";font-family:";color:black;" >+dice2);</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >XML File for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 393pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="524"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 387pt;" valign="top" width="516" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>DiceRollerServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/DiceRollerServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 77.42%;" border="1" cellpadding="0" width="77%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.12%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1032" type="#_x0000_t75" alt="" style="'width:333pt;height:135pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image012.gif" href="http://www.roseindia.net/servlets/DiceRoller.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Getting Init Parameter Names</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to retreive the init paramater values which we have given in the <b>web.xml</b> file.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Whenever the container makes a servlet it always reads it deployment descriptor file i.e. web.xml. Container creates name/value pairs for the <b>ServletConfig </b>object. Once the parameters are in <b>ServletConfig</b> they will never be read again by the Container.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The main job of the <b>ServletConfig </b>object is to give the init parameters.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To retrieve the init parameters in the program firstly we have made one class named <b>GettingInitParameterNames</b>. The container calls the servlet's <b>service()</b> method then depending on the type of request, the service method calls either the doGet() or the doPost(). By default it will be doGet() method. Now inside the <b>doGet() </b>method use <b>getWriter()</b> method of the <b>response</b> object which will return a object of the PrintWriter class which helps us to print the content on the browser.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To retrieve all the values of the init parameter use method <b>getInitParameterNames()</b> which will return the Enumeration of the init parameters.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.util.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >InitServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.print(</span></code><code><span style=";font-family:";" >"Init Parameters are : "</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Enumeration enumeration = getServletConfig().getInitParameterNames();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while</span></b></code><code><span style=";font-family:";color:black;" >(enumeration.hasMoreElements()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.print(enumeration.nextElement() + </span></code><code><span style=";font-family:";" >" "</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"\nThe email address is " </span></code><code><span style=";font-family:";color:black;" >+ getServletConfig().getInitParameter(</span></code><code><span style=";font-family:";" >"AdminEmail"</span></code><code><span style=";font-family:";color:black;" >));</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The address is " </span></code><code><span style=";font-family:";color:black;" >+ getServletConfig().getInitParameter(</span></code><code><span style=";font-family:";" >"Address"</span></code><code><span style=";font-family:";color:black;" >));</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The phone no is " </span></code><code><span style=";font-family:";color:black;" >+ getServletConfig().getInitParameter(</span></code><code><span style=";font-family:";" >"PhoneNo"</span></code><code><span style=";font-family:";color:black;" >));</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file of this program:<o:p></o:p></span></b></p> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><init-param></init-param></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><param-name>AdminEmail</param-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><param-value>zulfiqar_mca</param-value></span></code><code><span style=";font-family:";" >@yahoo.co.in</span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><init-param></init-param></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><param-name>Address</param-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><param-value>Okhla</param-value></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><init-param></init-param></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><param-name>PhoneNo</param-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><param-value></param-value></span></code><code><span style=";font-family:";" >9911217074</span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>InitServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/InitServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <b><span style="color:navy;">The output of the program is given below:</span></b><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 72.6%;" border="1" cellpadding="0" width="72%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.06%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1033" type="#_x0000_t75" alt="" style="'width:312pt;height:137.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image013.gif" href="http://www.roseindia.net/servlets/InitParameterNames.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Passing Parameter Using Html Form</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/GettingInitParameterNames.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1036" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1036" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1037" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1037" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/GetParameterValues.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1038" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1038" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This is a very simple example in which we are going to display the name on the browser which we have entered from the Html page. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To get the desired result firstly we have to make one html form which will have only one field named as name in which we will enter the name. And we will also have one submit button, on pressing the submit button the request will go to the server and the result will be displayed to us. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the servlet which will work as a controller here picks the value from the html page by using the method <b>getParameter()</b>. The output will be displayed to you by the object of the <b>PrintWriter</b> class. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><span style=";font-family:";font-size:9;" >
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ><title>New Page </span></code><code><span style="font-family: ">1</span></code><code><span style="font-family: "></title></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><h2>Login</h2></span></code>
<br /> <code><span style=";font-family:";color:black;" ><p>Please enter your username and password</p></span></code>
<br /> <code><span style=";font-family:";color:black;" ><form method="</span"></form></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><code><span style=";font-family:";" >"GET" </span></code><code><span style=";font-family:";color:black;" >action=</span></code><code><span style=";font-family:";" >"/htmlform/LoginServlet"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p> Username <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"username" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p> Password <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p><input type="</span"><code><span style=";font-family:";" >"submit" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"Submit" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"B1"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code></code>
<br /> <code><span style=";font-family:";color:black;" ><p> </p></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >LoginServlet.java</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >LoginServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter out = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String name = request.getParameter(</span></code><code><span style=";font-family:";" >"username"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String pass = request.getParameter(</span></code><code><span style=";font-family:";" >"password"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"Thanks Mr." </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >" " </span></code><code><span style=";font-family:";color:black;" >+ name + </span></code><code><span style=";font-family:";" >" " </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"for visiting roseindia
<br />" </span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"Now you can see your password : " </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >" " </span></code><code><span style=";font-family:";color:black;" >+ pass + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" > web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>LoginServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/LoginServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <b><span style="color:navy;">The output of the program is given below:</span></b><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 40%;" border="1" cellpadding="0" width="40%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1039" type="#_x0000_t75" alt="" style="'width:350.25pt;height:227.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image017.gif" href="http://www.roseindia.net/servlets/htmlforma.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 100%;" border="1" cellpadding="0" width="100%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.32%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1040" type="#_x0000_t75" alt="" style="'width:525.75pt;height:125.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image018.gif" href="http://www.roseindia.net/servlets/htmlformb.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Multiple values for a single parameter</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/PrintingNameUsingHtmlForm.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1043" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1043" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1044" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1044" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/TimeUpdater.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1045" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1045" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In our program it may be that we may have multiples values for a single parameter like in checkboxes. We are going to make one program over it.
<br />To make such a servlet which we have made one html form from where the values will be passed to the controller. In this program we have used the checkbox which will have the same name but with different values. We have one more button submit, on pressing this button the request will be forwarded. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Now in the servlet that is working like a controller will retrieve the values we have entered in the html form by the method <b>getParameterValues()</b> which returns the <i>array</i> of <b>String</b>. At last to retrieve all the values from the array use the <b>for</b> loop. The output will be displayed to you by the <b>PrintWriter</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Index.html</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"-//W3C//DTD HTML 4.01 Transitional//EN"</span></code><code><span style=";font-family:";font-size:9;color:black;" >></span></code><span style=";font-family:";font-size:9;" >
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ><title>Insert title here</title></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ><form method=" </span"></form></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><code><span style=";font-family:";" >"post" </span></code><code><span style=";font-family:";color:black;" >action = </span></code><code><span style=";font-family:";" >"/GetParameterServlet/GetParameterValues"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><p>Which of the whisky you like most</p></span></code>
<br /> <code><span style=";font-family:";color:black;" ><input type=" </span"></span></code><code><span style=";font-family:";" >"checkbox" </span></code><code><span style=";font-family:";color:black;" >name =</span></code><code><span style=";font-family:";" >"whisky" </span></code><code><span style=";font-family:";color:black;" >value = </span></code><code><span style=";font-family:";" >"RoyalChallenge"</span></code><code><span style=";font-family:";color:black;" >>RoyalChallenge.
<br /></span></code>
<br /> <code><span style=";font-family:";color:black;" ><input type=" </span"></span></code><code><span style=";font-family:";" >"checkbox" </span></code><code><span style=";font-family:";color:black;" >name =</span></code><code><span style=";font-family:";" >"whisky" </span></code><code><span style=";font-family:";color:black;" >value = </span></code><code><span style=";font-family:";" >"RoyalStag"</span></code><code><span style=";font-family:";color:black;" >>RoyalStag.
<br /></span></code>
<br /> <code><span style=";font-family:";color:black;" ><input type=" </span"></span></code><code><span style=";font-family:";" >"checkbox" </span></code><code><span style=";font-family:";color:black;" >name =</span></code><code><span style=";font-family:";" >"whisky" </span></code><code><span style=";font-family:";color:black;" >value = </span></code><code><span style=";font-family:";" >"Bagpiper"</span></code><code><span style=";font-family:";color:black;" >>Bagpiper.
<br /></span></code>
<br /> <code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"submit" </span></code><code><span style=";font-family:";color:black;" >name= </span></code><code><span style=";font-family:";" >"submit"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" > GetParameterValues.java</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >GetParameterValues </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doPost(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String[] whisky = request.getParameterValues(</span></code><code><span style=";font-family:";" >"whisky"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >for</span></b></code><code><span style=";font-family:";color:black;" >(</span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i=</span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >; i<whisky.length;></whisky.length;></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"
<br />whisky : " </span></code><code><span style=";font-family:";color:black;" >+ whisky[i]);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>GetParameterValues</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/GetParameterValues</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 50%;" border="1" cellpadding="0" width="50%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1046" type="#_x0000_t75" alt="" style="'width:330pt;height:186pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image019.gif" href="http://www.roseindia.net/servlets/ParamValuea.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image019.gif" shapes="_x0000_i1046" border="0" width="440" height="248" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Here is the result of the above selection:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 95.72%;" border="1" cellpadding="0" width="95%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.28%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1047" type="#_x0000_t75" alt="" style="'width:413.25pt;height:132.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image020.gif" href="http://www.roseindia.net/servlets/ParamValueb.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Time Updater in Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/GetParameterValues.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1050" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1050" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1051" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1051" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/SendRedirectToHtmlOrJspPage.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1052" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1052" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to make one program on servlet which will keep on updating the time in every second and the result will be displayed to you. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make this servlet firstly we need to make a class named TimeUpdater. The name of the class should be such that it becomes easy to understand what the program is going to do. Call the method <b>getWriter()</b> method of the <b>response</b> object which will return a <b>PrintWriter </b>object. Use the method <b>getHeader() </b>of the response object to add a new header. We can also use<b> setHeader()</b> in place of <b>getHeader()</b>. The setHeader() method overrides the previous set header. Now by using the <b>PrintWriter</b> object display the result on the browser.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import java.util.*;
<br /> import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class TimeUpdater extends HttpServlet {
<br />
<br /> public void doGet(HttpServletRequest request, HttpServletResponse response)
<br /> throws ServletException, IOException {
<br /> PrintWriter pw = response.getWriter();
<br />
<br /> response.addHeader("Refresh", "1");
<br /> pw.println(new Date().toString());
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1053" type="#_x0000_t75" alt="" style="'width:256.5pt;height:45.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image021.gif" href="http://www.roseindia.net/servlets/TimeUp1.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >Send Redirect in Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/TimeUpdater.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1056" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1057" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/session-tracking.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1058" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1058" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >When we want that someone else should handle the response of our servlet, then there we should use <b>sendRedirect()</b> method. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In send Redirect whenever the client makes any request it goes to the container, there the container decides whether the concerned servlet can handle the request or not. If not then the servlet decides that the request can be handle by other servlet or jsp. Then the servlet calls the <b>sendRedirect()</b> method of the response object and sends back the response to the browser along with the status code. Then the browser sees the status code and look for that servlet which can now handle the request. Again the browser makes a new request, but with the name of that servlet which can now handle the request and the result will be displayed to you by the browser. In all this process the client is unaware of the processing. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to make one html in which we will submit the user name and his password. The controller will check if the password entered by the user is correct or not. If the password entered by the user is correct then the servlet will redirect the request to the other servlet which will handle the request. If the password entered by the user is wrong then the request will be forwarded to the html form.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the example is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" > html file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><span style=";font-family:";font-size:9;" >
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ><title>New Page </span></code><code><span style="font-family: ">1</span></code><code><span style="font-family: "></title></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><form method="</span"></form></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><code><span style=";font-family:";" >"POST" </span></code><code><span style=";font-family:";color:black;" >action=</span></code><code><span style=";font-family:";" >"/SendRedirect/SendRedirectServlet"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Enter your name </p></span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > <input type="</span"></span></code></span><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"username" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></code></span>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Enter your password <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p> </p></span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code>
<br /> <code><span style=";font-family:";" > </span></code></span>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"submit" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"Submit" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"B1"</span></code><code><span style=";font-family:";color:black;" >><p></p></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code></p>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p><p></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >SendRedirectServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doPost(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String name = request.getParameter(</span></code><code><span style=";font-family:";" >"username"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String password = request.getParameter(</span></code><code><span style=";font-family:";" >"password"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if</span></b></code><code><span style=";font-family:";color:black;" >(name.equals(</span></code><code><span style=";font-family:";" >"James"</span></code><code><span style=";font-family:";color:black;" >)&& password.equals(</span></code><code><span style=";font-family:";" >"abc"</span></code><code><span style=";font-family:";color:black;" >)){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.sendRedirect(</span></code><code><span style=";font-family:";" >"/SendRedirect/ValidUserServlet"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"u r not a valid user"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code>
<br />
<br /> <code><span style=";font-family:";color:white;" > </span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ValidUserServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Welcome to roseindia.net " </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >" "</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"how are you"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>SendRedirectServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/SendRedirectServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ValidUserServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ValidUserServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 50%;" border="1" cellpadding="0" width="50%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%">
<br /></td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 51%;" border="1" cellpadding="0" width="51%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%">
<br /></td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 52%;" border="1" cellpadding="0" width="52%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%">
<br /></td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 85.46%;" border="1" cellpadding="0" width="85%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.2%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1062" type="#_x0000_t75" alt="" style="'width:368.25pt;height:117pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image025.gif" href="http://www.roseindia.net/servlets/SendRedirectd.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Session Tracking</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SendRedirectToHtmlOrJspPage.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1065" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1065" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1066" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1066" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/CheckingTheSession.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1067" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1067" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >As we know that the Http is a <i>stateless</i> protocol, means that it can't persist the information. It always treats each request as a new request. In Http client makes a connection to the server, sends the request., gets the response, and closes the connection.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In session management client first make a request for any servlet or any page, the container receives the request and generate a unique session ID and gives it back to the client along with the response. This ID gets stores on the client machine. Thereafter when the client request again sends a request to the server then it also sends the session Id with the request. There the container sees the Id and sends back the request. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Session Tracking can be done in three ways:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >Hidden Form Fields:</span></b><span style=";font-family:";font-size:9;color:navy;" > This is one of the way to support the session tracking. As we know by the name, that in this fields are added to an HTML form which are not displayed in the client's request. The hidden form field are sent back to the server when the form is submitted.</span><span style=";font-family:";font-size:9;" > <span style="color:navy;">In hidden form fields the html entry will be like this : <input name="name" value="" type="hidden">. This means that when you submit the form, the specified name and value will be get included in get or post method. In this session ID information would be embedded within the form as a hidden field and submitted with the Http POST command.</span> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >URL Rewriting: </span></b><span style=";font-family:";font-size:9;color:navy;" >This is another way to support the session tracking.</span><span style=";font-family:";font-size:9;" > <b><span style="color:navy;">URLRewriting</span></b><span style="color:navy;"> can be used in place where we don't want to use cookies. It is used to maintain the session. Whenever the browser sends a request then it is always interpreted as a new request because http protocol is a stateless protocol as it is not persistent. Whenever we want that out request object to stay alive till we decide to end the request object then, there we use the concept of session tracking. In session tracking firstly a session object is created when the first request goes to the server. Then server creates a token which will be used to maintain the session. The token is transmitted to the client by the response object and gets stored on the client machine. By default the server creates a cookie and the cookie get stored on the client machine.</span> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >Cookies: </span></b><span style=";font-family:";font-size:9;color:navy;" >When cookie based session management is used, a token is generated which contains user's information, is sent to the browser by the server. The cookie is sent back to the server when the user sends a new request. By this cookie, the server is able to identify the user. In this way the session is maintained. Cookie is nothing but a name- value pair, which is stored on the client machine. By default the cookie is implemented in most of the browsers. If we want then we can also disable the cookie. For security reasons, cookie based session management uses two types of cookies.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >To Determine whether the Session is New or Old</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/session-tracking.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1070" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1070" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1071" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1071" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/PreExistingSession.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1072" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1072" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to make one servlet on session in which we will check whether the session is new or old. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make this program firstly we need to make one class named <b>CheckingTheSession</b>. Inside the <b>doGet()</b> method, which takes two objects one of request and second of response. Inside this method call the method <b>getWriter()</b> of the response object. Use <b>getSession()</b> of the request object, which returns the <b>HttpSession</b> object. Now by using the <b>HttpSession</b> we can find out whether the session is new or old. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >CheckingTheSession </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Checking whether the session is new or old
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >HttpSession session = request.getSession();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if</span></b></code><code><span style=";font-family:";color:black;" >(session.isNew()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"You have created a new session"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Session already exists"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ><!--<!DOCTYPE web-app</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">PUBLIC </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">> --></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>CheckingTheSession</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Hello</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/CheckingTheSession</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 91.62%;" border="1" cellpadding="0" width="91%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.26%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1073" type="#_x0000_t75" alt="" style="'width:395.25pt;height:125.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image026.gif" href="http://www.roseindia.net/servlets/CheckingTheSession.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Pre- Existing Session</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/CheckingTheSession.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1076" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1076" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1077" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/SessionId.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1078" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1078" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to find out whether the session is <i>pre-existing</i> or not. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where servlet want to use only a existing session. It is not always a good idea to create a new session. To perform this work we have one overloaded method <b>getSession(boolean)</b> of the request object. If we don't want to create a new session then we should use <b>getSession(false)</b>. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the example below we have used the method <b>getSession(false)</b> which will test whether the session is null or not. If there will be no session then the new session will be created by the method <b>getSession()</b>.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >PreExistingSessionServlet.java</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >PreExistingSessionServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Testing The Session : "</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >HttpSession session = request.getSession(</span></code><code><b><span style=";font-family:";" >false</span></b></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if</span></b></code><code><span style=";font-family:";color:black;" >(session==</span></code><code><b><span style=";font-family:";" >null</span></b></code><code><span style=";font-family:";color:black;" >){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"There is no session"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Can we create a session for you. Creating........."</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >session = request.getSession();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Session already exists"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>PreExistingSessionServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/PreExistingSessionServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 90.24%;" border="1" cellpadding="0" width="90%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.24%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1079" type="#_x0000_t75" alt="" style="'width:389.25pt;height:106.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image027.gif" href="http://www.roseindia.net/servlets/PreExistingSession.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Get Session Id</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/PreExistingSession.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1082" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1082" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1083" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1083" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletInsertingData.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1084" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1084" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to make a program in which we will find the session id which was generated by the container. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >HttpSession session = request.getSession();</span></b><span style=";font-family:";font-size:9;color:navy;" > Inside the service method we ask for the session and every thing gets automatically, like the creation of the HttpSession object. There is no need to generate the unique session id. There is no need to make a new Cookie object. Everything happens automatically behind the scenes. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >As soon as call the method <b>getSession()</b> of the request object a new object of the session gets created by the container and a unique session id generated to maintain the session. This session id is transmitted back to the response object so that whenever the client makes any request then it should also attach the session id with the requsest object so that the container can identify the session. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >SessionIdServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >protected void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >HttpSession session = request.getSession();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String id = session.getId();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Session Id is : " </span></code><code><span style=";font-family:";color:black;" >+ id);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>SessionIdServlet</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/SessionIdServlet</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 77.76%;" border="1" cellpadding="0" width="77%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.12%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1085" type="#_x0000_t75" alt="" style="'width:334.5pt;height:118.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image028.gif" href="http://www.roseindia.net/servlets/SessionId.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >sendRedirect</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SelectColor.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1088" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1088" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1089" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1089" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/SendRedirect.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1090" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1090" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In send Redirect whenever the client makes any request it goes to the container, there the container decides whether the concerned servlet can handle the request or not. If not then the servlet decides that the request can be handle by other servlet or jsp. Then the servlet calls the <b>sendRedirect()</b> method of the response object and sends back the response to the browser along with the status code. Then the browser sees the status code and look for that servlet which can now handle the request. Again the browser makes a new request, but with the name of that servlet which can now handle the request and the result will be displayed to you by the browser. The URL will have the address of the new servlet. In all this process the client is unaware of the processing.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Servlet Redirect forces the browser to do work.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >Send Redirect in Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/Redirect.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1093" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1093" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1094" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1094" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/SiteSelectionInServlet.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1095" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1095" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >When we want that someone else should handle the response of our servlet, then there we should use <b>sendRedirect()</b> method. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In send Redirect whenever the client makes any request it goes to the container, there the container decides whether the concerned servlet can handle the request or not. If not then the servlet decides that the request can be handle by other servlet or jsp. Then the servlet calls the <b>sendRedirect()</b> method of the response object and sends back the response to the browser along with the status code. Then the browser sees the status code and look for that servlet which can now handle the request. Again the browser makes a new request, but with the name of that servlet which can now handle the request and the result will be displayed to you by the browser. In all this process the client is unaware of the processing. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><meta equiv="Content-Type" content="text/html; charset=ISO-8859-1"><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><title>Redirecting the page</title><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><span style=""> </span><form action="/ServletProject/SendRedirect" method="post"><o:p></o:p></form></span><span style=";font-family:";font-size:9;" ></span><span style=";font-family:";font-size:9;" ></span><span style=";font-family:";font-size:9;" ></span><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre></pre></td></tr><tr><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><td>Enter your name :</td><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><td><input name="username" type="text"></td><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre></tr>
<br /><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><tr><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><td>Enter your password :</td><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><td><input name="password" type="password"></td><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre></tr>
<br /><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><tr><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><td><input name="submit" type="submit"></td><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre></tr><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span></pre><o:p></o:p><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import java.io.IOException;
<br /> import javax.servlet.ServletException;
<br /> import javax.servlet.http.HttpServletRequest;
<br /> import javax.servlet.http.HttpServletResponse;
<br />
<br /> public class SendRedirect extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
<br /> public SendRedirect() {
<br /> super();
<br /> }
<br /> protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
<br /> ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> response.setContentType("text/html");
<br /> PrintWriter pw = response.getWriter();
<br /> String name = request.getParameter("username");
<br /> String password = request.getParameter("password");
<br /> if(name.equals("James")&& password.equals("abc"))
<br /> {
<br /> response.sendRedirect("/ServletProject/ValidUser");
<br /> }
<br /> else
<br /> {
<br /> pw.println("u r not a valid user");
<br /> }
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import java.io.IOException;
<br /> import javax.servlet.ServletException;
<br /> import javax.servlet.http.HttpServletRequest;
<br /> import javax.servlet.http.HttpServletResponse;
<br />
<br /> /**
<br /> * Servlet implementation class for Servlet: ValidUser
<br /> *
<br /> */
<br /> public class ValidUser extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#HttpServlet()
<br /> */
<br /> public ValidUser() {
<br /> super();
<br /> }
<br />
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
<br /> */
<br /> protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
<br /> ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br />
<br /> }
<br />
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
<br /> */
<br /> protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
<br /> ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> PrintWriter pw = response.getWriter();
<br /> pw.println("Welcome to roseindia.net
<br />");
<br /> pw.println("how are you");
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1097" type="#_x0000_t75" alt="" style="'width:279.75pt;height:86.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image030.gif" href="http://www.roseindia.net/servlets/SendRe3.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > </span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1098" type="#_x0000_t75" alt="" style="'width:261pt;height:57pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image031.gif" href="http://www.roseindia.net/servlets/SendRe4.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >Random Redirector</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SendRedirect.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1101" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1101" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1102" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletContext.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1103" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1103" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to make such a servlet which will be responsible to select a site randomly from the list of sites you have entered. Note that the selection of the site will be randomly. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make such a servlet firstly make a class named SiteSelectionServlet. Use the <b>Vector</b> class where you can store the sites which you want to select randomly and the other class <b>Random </b>which will helps you to select the site randomly. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import java.util.*;
<br /> import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class SiteSelectionInServlet extends HttpServlet {
<br />
<br /> Vector sites = new Vector();
<br /> Random random = new Random();
<br />
<br /> public void init() throws ServletException {
<br /> sites.addElement("http://www.roseindia.net");
<br /> sites.addElement("http://www.java.sun.com");
<br /> sites.addElement("http://www.rediffmail.com");
<br /> sites.addElement("http://www.yahoo.com");
<br /> sites.addElement("http://www.indiatimes.com");
<br /> }
<br />
<br /> public void doGet(HttpServletRequest request, HttpServletResponse response)
<br /> throws ServletException, IOException {
<br /> response.setContentType("text/html");
<br /> PrintWriter out = response.getWriter();
<br />
<br /> int siteIndex = Math.abs(random.nextInt()) % sites.size();
<br /> String site = (String)sites.elementAt(siteIndex);
<br />
<br /> response.setStatus(response.SC_MOVED_TEMPORARILY);
<br /> response.setHeader("Location", site);
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1104" type="#_x0000_t75" alt="" style="'width:378.75pt;height:295.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image032.jpg" href="http://www.roseindia.net/servlets/SiteSe1.jpg"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Note:</span></b><span style=";font-family:";font-size:9;color:navy;" > The selection will be random.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >Servlet Context</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SiteSelectionInServlet.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1107" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1107" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1108" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1108" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletContextListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1109" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1109" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >ServletContext</span></i></b><span style=";font-family:";font-size:9;color:navy;" > is a interface which helps us to communicate with the servlet container. There is only one ServletContext for the entire web application and the components of the web application can share it. The information in the ServletContext will be common to all the components. Remember that each servlet will have its own <b>ServletConfig</b>. The ServetContext is created by the container when the web application is deployed and after that only the context is available to each servlet in the web application. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Web application initialization:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><span style=";font-family:";font-size:9;color:navy;" >First of all the web container reads the deployment descriptor file and then creates a name/value pair for each <context-param> tag. </context-param></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><span style=";font-family:";font-size:9;color:navy;" >After creating the name/value pair it creates a new instance of ServletContext.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><span style=";font-family:";font-size:9;color:navy;" >Its the responsibility of the Container to give the reference of the ServletContext to the context init parameters.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">4.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><span style=";font-family:";font-size:9;color:navy;" >The servlet and jsp which are part of the same web application can have the access of the ServletContext.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The Context init parameters are available to the entire web application not just to the single servlet like servlet init parameters.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >How can we do the mapping of the Context init parameters in web.xml</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" ><servlet>
<br /> <servlet-name>Mapping</servlet-name>
<br /> <servlet-class>ContextMapping</servlet-class>
<br /></servlet>
<br />
<br /><context-param>
<br /> <param-name>Email</param-name>
<br /> <param-value>admin@roseindia.net</param-value>
<br /></context-param></span></b><span style=";font-family:";font-size:9;color:navy;" >
<br />
<br />In the servlet code we will write this as</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >ServletContext context = getServletContext();
<br />pw.println(context.getInitParameter("Email")</span></b><span style=";font-family:";font-size:9;color:navy;" >;</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:blue;" >Thanks Jyoti, We have corrected the typo error.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >ServletContextListener</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletContext.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1112" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1112" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1113" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1113" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletContextListener-example.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1114" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1114" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >ServletContextListener </span></i></b><span style=";font-family:";font-size:9;color:navy;" >is a interface which contains two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >public void contextInitialized(ServletContextEvent event)</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >public void contextDestroyed(ServletContextEvent event)</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >When we implement any interface then we have to implement its all methods. This listener will help a application to start and shutdown the events. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >How the <b><i>ServletContextListener</i></b> is useful:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >1. ServletContextListener is notified when the context is initialized. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >a). ServletContextListener gets the context init parameters from the ServletContext. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >b). It stores the database connection as an attribute, so that the other components in the web application can access it. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >2. It will be notified when the context is destroyed. It closes the database connection. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >ServletContextListener example</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletContextListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1117" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1117" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1118" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1118" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletContextAttributeListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1119" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1119" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Before going into the details of ServletContextListener we should understand what is ServletContext. <b><i>ServletContext</i></b> is a interface which helps us to communicate with the servlet container. There is only one ServletContext for the entire web application and the components of the web application can share it. The information in the ServletContext will be common to all the components. Remember that each servlet will have its own <b>ServletConfig</b>. The ServetContext is created by the container when the web application is deployed and after that only the context is available to each servlet in the web application.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >ServletContextListener </span></i></b><span style=";font-family:";font-size:9;color:navy;" >is a interface which contains two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >public void contextInitialized(ServletContextEvent event)</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >public void contextDestroyed(ServletContextEvent event) </span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >When we implement any interface then we have to implement its all methods. This listener will help a application to start and shutdown the events. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >How the <b><i>ServletContextListener</i></b> is useful:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >1. ServletContextListener is notified when the context is initialized. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >a). ServletContextListener gets the context init parameters from the ServletContext. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >b). It stores the database connection as an attribute, so that the other components in the web application can access it. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >2. It will be notified when the context is destroyed. It closes the database connection. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class MyServletContextListener implements ServletContextListener{
<br /> public void contextInitialized(ServletContextEvent event)
<br /> {
<br /> ServletContext sc = event.getServletContext();
<br /> String whatType = sc.getInitParameter("typeSelected");
<br /> Furniture f = new Furniture(whatType);
<br /> sc.setAttribute("furniture", f);
<br /> }
<br /> public void contextDestroyed(ServletContextEvent event)
<br /> {
<br />
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class ListenerTester extends javax.servlet.http.HttpServlet
<br /> implements javax.servlet.Servlet {
<br /> public ListenerTester() {
<br /> super();
<br /> }
<br />
<br /> public void doGet(HttpServletRequest request, }
<br /> HttpServletResponse response) throws
<br /> ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> response.setContentType("text/html");
<br /> PrintWriter pw = response.getWriter();
<br /> pw.println("context attributes set by the listener
<br />");
<br /> Furniture f = (Furniture)getServletContext().getAttribute("furniture");
<br /> pw.println("The furniture you have selected is :" + f.getTypeSelected());
<br /> }
<br />
<br /> public void doPost(HttpServletRequest request,
<br /> HttpServletResponse response) throws ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1120" type="#_x0000_t75" alt="" style="'width:258pt;height:56.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image033.gif" href="http://www.roseindia.net/servlets/MyServ1.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >ServletContextAttributeListener</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletContextListener-example.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1123" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1123" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1124" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1124" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/MySessionListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1125" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1125" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >As we know that the <b><i>javax.servlet.ServletContext</i></b> interface used to represents a Servlet's view of the web application it belongs to. All the servlets in an application can access the <b>SevletContext</b>. It means that we keep such information in the servlet context which are common to all the servlets. The elements of the <b>ServletContext</b> are stored in <b>web.xml</b> file. Whenever the container gets start it reads the <b>web.xml</b> file. Occurrence of <b><context-param></context-param></b> tag should appear before the <b>Servlet</b> tags. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >ServletContext</span></i></b><span style=";font-family:";font-size:9;color:navy;" > is a interface which helps us to communicate with the servlet container. There is only one <b>ServletContext </b>for the entire web application and the components of the web application can share it. The information in the ServletContext will be common to all the components. Remember that each servlet will have its own <b>ServletConfig</b>. The ServetContext is created by the container when the web application is deployed and after that only the context is available to each servlet in the web application.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The listener <b><i>ServletContextAttributeListener</i></b> is an interface and extends the <b>java.util.EventListener</b> class. This listener come into existence when this interface receives notifications of changes to the attribute list on the servlet context of a web application. Remember one thing before gets notified by the container, you should make sure that the implementation class is configured in deployment descriptor for the web application. This listener is used when we want to know when a attribute has been added in a context, when a attribute has been removed and when it is replaced by another attribute. We can also say that this attribute is used when the developer is interested to be notified when the context attribute changes. Now you may be wondering what is an attribute. An attribute is an object set or you can simply say that it is name/value pair where the name refers to a <b>String</b> and a value refers to the <b>Object. </b></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >javax.servlet.ServletContextAttributeListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > interface has following methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeAdded(ServletContextAttributeEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever a new attribute is added to the servlet context.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeRemoved(ServletContextAttributeEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute is removed from the servlet context.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeReplaced(ServletContextAttributeEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute gets replaced on the servlet context.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above methods you can see that we have used <b>ServletContextAttributeEvent</b> class as a parameter to the above methods. This class is a event class which is used for notifications when the changes are made to the attributes of <b>ServletContext</b> in an application.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The class <b>ServletContextAttributeEvent</b> has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getName() :</span></b><span style=";font-family:";font-size:9;color:navy;" > This method returns the name of the attribute that has been changed on the ServletContext.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getValue():</span></b><span style=";font-family:";font-size:9;color:navy;" > This method will return the value of the attribute that has been added, removed or replaced by other attribute.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >HttpSessionListener</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletContextAttributeListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1128" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1128" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1129" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1129" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ListenerSession.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1130" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1130" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Before going into the details of the <b>SessionListener </b>we should firstly know about the sessions. As we know that Http protocol is a "<i>stateless</i>" protocol. The term stateless means that it can't persist the information. It can't remember the previous transactions. Whenever a client makes a request for any resources to the server, the server receives the request and processes the request and sends back the response. After sending the response the server closes the connection and forgets about the previous requests. Whenever a client sends any request to the server, the server treats each request as a new request. To remove this we have been provided the facility of the session. In session tracking whenever a client sends a request to the server then server creates a unique id for that request and sends back the unique id to the client along with the response object, now whenever a client sends a request to the server it also sends a unique id with it so that the server can know from where the request is coming. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Listeners</span></b><span style=";font-family:";font-size:9;color:navy;" > listen the events. Whenever any event occurs it is listened by the listener. The listener will be controller by the web servers. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >HttpSessionListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > is an interface which extends<b> java.util.EventListener</b> class. The main purpose of this listener is to notify whenever there is a change in the list of active sessions in a web application </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This interface has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >sessionCreated(HttpSessionEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It will notify when the session is created.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >sessionDestroyed(HttpSessionEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It will notify when the session gets invalidated.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above methods we can see that we have used <b>HttpSessionEvent</b> as the parameter of both the methods. This class has only one method getSession() which returns the current session.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Make the entry of this file in the deployment descriptor file that is web.xml</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class MySessionListener
<br /> implements HttpSessionListener {
<br /> public MySessionListener() {
<br /> }
<br /> public void sessionCreated(HttpSessionEvent sessionEvent) {
<br /> // Get the session
<br /> HttpSession session = sessionEvent.getSession();
<br /> try {
<br /> System.out.println("Session created: "+session);
<br /> session.setAttribute("foo","bar");
<br /> } catch (Exception e) {
<br /> System.out.println("Error in setting session attribute: "
<br /> }+ e.getMessage());
<br /> }
<br /> }
<br /> public void sessionDestroyed(HttpSessionEvent sessionEvent) {
<br /> // Get the session that was invalidated
<br /> HttpSession session = sessionEvent.getSession();
<br /> // Log a message
<br /> System.out.println("Session invalidated: "+session);
<br /> System.out.println("The name is: " + session.getAttribute("foo"));
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br /> import java.io.*;
<br />
<br /> public class ServletSessionListener extends HttpServlet{
<br /> public void doGet(HttpServletRequest request,
<br /> HttpServletResponse response) throws ServletException, IOException
<br /> {
<br /> response.setContentType("text/html");
<br /> PrintWriter pw = response.getWriter();
<br /> HttpSession session= request.getSession();
<br /> String str = (String)session.getAttribute("foo");
<br /> pw.println("The name is " + str);
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1131" type="#_x0000_t75" alt="" style="'width:351pt;height:78.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image034.gif" href="http://www.roseindia.net/servlets/MySess4.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >HttpSessionListener example</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/MySessionListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1134" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1134" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1135" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1135" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/HttpSessionAttributeListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1136" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1136" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Before going into the details of the <b>SessionListener </b>we should firstly know about the sessions. As we know that Http protocol is a "<i>stateless</i>" protocol. The term stateless means that it can't persist the information. It can't remember the previous transactions. Whenever a client makes a request for any resources to the server, the server receives the request and processes the request and sends back the response. After sending the response the server closes the connection and forgets about the previous requests. Whenever a client sends any request to the server, the server treats each request as a new request. To remove this we have been provided the facility of the session. In session tracking whenever a client sends a request to the server then server creates a unique id for that request and sends back the unique id to the client along with the response object, now whenever a client sends a request to the server it also sends a unique id with it so that the server can know from where the request is coming. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Listeners</span></b><span style=";font-family:";font-size:9;color:navy;" > listen the events. Whenever any event occurs it is listened by the listener. The listener will be controller by the web servers. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >HttpSessionListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > is an interface which extends<b> java.util.EventListener</b> class. The main purpose of this listener is to notify whenever there is a change in the list of active sessions in a web application </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This interface has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >sessionCreated(HttpSessionEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It will notify when the session is created.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >sessionDestroyed(HttpSessionEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It will notify when the session gets invalidated.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above methods we can see that we have used <b>HttpSessionEvent</b> as the parameter of both the methods. This class has only one method <b>getSession()</b> which returns the current session.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Make the entry of this file in the deployment descriptor file that is web.xml</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class ListenerSession
<br /> implements HttpSessionListener {
<br /> public ListenerSession() {
<br /> }
<br /> public void sessionCreated(HttpSessionEvent sessionEvent) {
<br /> // Get the session that was created
<br /> HttpSession session = sessionEvent.getSession();
<br /> // Store something in the session, and log a message
<br /> try {
<br /> System.out.println("Session created: "+session);
<br /> session.setAttribute("dog", "labrador");
<br /> session.setAttribute("name", "Diana");
<br /> } catch (Exception e) {
<br /> System.out.println("Error in setting session attribute: " +
<br /> e.getMessage());
<br /> }
<br /> }
<br /> public void sessionDestroyed(HttpSessionEvent sessionEvent) {
<br /> // Get the session that was invalidated
<br /> HttpSession session = sessionEvent.getSession();
<br /> // Log a message
<br /> System.out.println("Session invalidated: "+session);
<br /> System.out.println("The breed of the dog is: " + session.getAttribute("dog"));
<br /> System.out.println("The name of the dog is : " + session.getAttribute("name"));
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br /> import java.io.*;
<br />
<br /> public class ServletListenerSession extends HttpServlet{
<br /> public void doGet(HttpServletRequest request,
<br /> HttpServletResponse response) throws ServletException, IOException
<br /> {
<br /> response.setContentType("text/html");
<br /> PrintWriter pw = response.getWriter();
<br /> HttpSession session= request.getSession();
<br /> String str = (String)session.getAttribute("dog");
<br /> String dogName = (String)session.getAttribute("name");
<br /> pw.println("The breed of the dog is " + str);
<br /> pw.println("The name of the dog is " + dogName);
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the example is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1137" type="#_x0000_t75" alt="" style="'width:345.75pt;height:90pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image035.gif" href="http://www.roseindia.net/servlets/Listen5.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >HttpSessionAttributeListener</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ListenerSession.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1140" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1140" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1141" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1141" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/SessionAttributeListenerExample.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1142" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1142" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >As we know that the Session is used to maintain the session between request. Session object is responsible to hold the conversational state across multiple requests.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The listener <b><i>HttpSessionAttributeListener</i></b> is an interface and extends the <b>java.util.EventListener</b> class. This listener will be called by the container whenever there there will be change to the attribute list on the servlet session of a web application. This listener is used when we want to know when a attribute has been added in a session, when a attribute has been removed and when it is replaced by another attribute. We can also say that this attribute is used when the developer is interested to be notified when the session attribute changes. Now you may be wondering what is an attribute. An attribute is an object set or you can simply say that it is <b>name/value</b> pair where the name refers to a <b>String</b> and a value refers to the <b>Object. </b></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >javax.servlet.http.HttpSessionAttributeListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > interface has following methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeAdded(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever a new attribute is added to the servlet session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeRemoved(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute is removed from the servlet session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeReplaced(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute gets replaced on the servlet session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above methods you can see that we have used <b>HttpSessionBindingEvent</b> class as a parameter to the above methods. This class is a event class which is used for notifications when the changes are made to the attributes of in a session.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The class <b>HttpSessionBindingEvent</b> has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getName() :</span></b><span style=";font-family:";font-size:9;color:navy;" > This method returns the name of the attribute that has been change in the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getValue():</span></b><span style=";font-family:";font-size:9;color:navy;" > This method will return the value of the attribute that has been added, removed or replaced by other attribute.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getSession(): </span></b><span style=";font-family:";font-size:9;color:navy;" >This method will return the session that has been changed.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >HttpSessionAttributeListener Example</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/HttpSessionAttributeListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1145" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1145" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1146" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1146" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/httpsessionbindinglistener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1147" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1147" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >As we know that the Session is used to maintain the session between request. Session object is responsible to hold the conversational state across multiple requests.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The listener <b><i>HttpSessionAttributeListener</i></b> is an interface and extends the <b>java.util.EventListener</b> class. This listener will be called by the container whenever there there will be change to the attribute list on the servlet session of a web application. This listener is used when we want to know when a attribute has been added in a session, when a attribute has been removed and when it is replaced by another attribute. We can also say that this attribute is used when the developer is interested to be notified when the session attribute changes. Now you may be wondering what is an attribute. An attribute is an object set or you can simply say that it is <b>name/value</b> pair where the name refers to a <b>String</b> and a value refers to the <b>Object. </b></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >javax.servlet.http.HttpSessionAttributeListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > interface has following methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeAdded(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever a new attribute is added to the servlet session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeRemoved(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute is removed from the servlet session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeReplaced(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute gets replaced on the servlet session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above methods you can see that we have used <b>HttpSessionBindingEvent</b> class as a parameter to the above methods. This class is a event class which is used for notifications when the changes are made to the attributes of in a session.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The class <b>HttpSessionBindingEvent</b> has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getName() :</span></b><span style=";font-family:";font-size:9;color:navy;" > This method returns the name of the attribute that has been change in the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getValue():</span></b><span style=";font-family:";font-size:9;color:navy;" > This method will return the value of the attribute that has been added, removed or replaced by other attribute.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getSession(): </span></b><span style=";font-family:";font-size:9;color:navy;" >This method will return the session that has been changed.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class SessionAttributeListenerExample
<br /> implements HttpSessionAttributeListener {
<br /> public void attributeAdded(HttpSessionBindingEvent
<br /> sessionBindingEvent) {
<br /> // Get the session
<br /> HttpSession session = sessionBindingEvent.getSession();
<br /> // Log some information
<br /> System.out.println("[SessionAttr] "+new java.util.Date()+
<br /> " Attribute added, session "+session+": "
<br /> +sessionBindingEvent.getName()+"="+
<br /> sessionBindingEvent.getValue());
<br /> }
<br /> public void attributeRemoved(HttpSessionBindingEvent
<br /> sessionBindingEvent) {
<br /> // Get the session
<br /> HttpSession session = sessionBindingEvent.getSession();
<br /> System.out.println(new java.util.Date()+" Attribute removed,
<br /> session "+session+": "+sessionBindingEvent.getName());
<br /> }
<br /> public void attributeReplaced(HttpSessionBindingEvent
<br /> sessionBindingEvent) {
<br /> // Get the session
<br /> HttpSession session = sessionBindingEvent.getSession();
<br /> // Log some information
<br /> System.out.println(new java.util.Date()+" Attribute
<br /> replaced, session "+session+": "+sessionBindingEvent
<br /> .getName()+"="+sessionBindingEvent.getValue());
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br /> import java.io.*;
<br />
<br /> public class AttributeSessionForSession extends HttpServlet{
<br /> public void doGet(HttpServletRequest request, HttpServletResponse
<br /> response) throws ServletException, IOException
<br /> {
<br /> response.setContentType("text/html");
<br /> PrintWriter pw = response.getWriter();
<br /> HttpSession session = request.getSession();
<br /> session.setAttribute("dog", "Labrador");
<br /> session.setAttribute("name", "moti");
<br /> session.setAttribute("age","5");
<br /> String str1 = (String)session.getAttribute("dog");
<br /> pw.println("The breed of the dog is " + str1);
<br /> String str2 = (String)session.getAttribute("age");
<br /> pw.println("The age of the dog is " + str2);
<br /> session.removeAttribute("name");
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1148" type="#_x0000_t75" alt="" style="'width:5in;height:75.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image036.gif" href="http://www.roseindia.net/servlets/Sessio6.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <p><u><span style=";font-family:";font-size:9;color:navy;" >The output on the server will look like this:</span></u><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1149" type="#_x0000_t75" alt="" style="'width:481.5pt;height:98.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image037.gif" href="http://www.roseindia.net/servlets/Sessio7.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >httpsessionbindinglistener</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SessionAttributeListenerExample.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1152" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1152" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1153" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1153" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/SessionBindingListenerExample.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1154" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1154" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Before going into the details of the <b><i>HttpSessionBindingListener</i> </b>we should firstly know about the sessions. As we know that Http protocol is a "<i>stateless</i>" protocol. The term stateless means that it can't persist the information. It can't remember the previous transactions. Whenever a client makes a request for any resources to the server, the server receives the request and processes the request and sends back the response. After sending the response the server closes the connection and forgets about the previous requests. Whenever a client sends any request to the server, the server treats each request as a new request. To remove this we have been provided the facility of the session. In session tracking whenever a client sends a request to the server then server creates a unique id for that request and sends back the unique id to the client along with the response object, now whenever a client sends a request to the server it also sends a unique id with it so that the server can know from where the request is coming. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >HttpSessionBindingListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > is a interface which extends <b><i>java.util.EventListener</i></b><i> </i>interface. The purpose of the this interface is to notify an object when it is bound to or unbound from a session. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This interface has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >valueBound(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies the object that is being bound to a session and is responsible for identifying the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >valueUnBound(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies the object that is being unbound from a session and is responsible for identifying the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above method we can see that we have used the class <b>HttpSessionBindingEvent</b> as a argument to the methods. The object is notified by an <b>HttpSessionBindingEvent</b> object</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This class has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getName():</span></b><span style=";font-family:";font-size:9;color:navy;" > It returns the name with which the object is bound or unbound from the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getSession():</span></b><span style=";font-family:";font-size:9;color:navy;" > This method returns the session to or from which the object is bound or unbound.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;" > <span style="color:navy;">httpsessionbindinglistener example</span><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/httpsessionbindinglistener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1157" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1157" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1158" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1158" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletRequestAttributeListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1159" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1159" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Before going into the details of the <b><i>HttpSessionBindingListener</i> </b>we should firstly know about the sessions. As we know that Http protocol is a "<i>stateless</i>" protocol. The term stateless means that it can't persist the information. It can't remember the previous transactions. Whenever a client makes a request for any resources to the server, the server receives the request and processes the request and sends back the response. After sending the response the server closes the connection and forgets about the previous requests. Whenever a client sends any request to the server, the server treats each request as a new request. To remove this we have been provided the facility of the session. In session tracking whenever a client sends a request to the server then server creates a unique id for that request and sends back the unique id to the client along with the response object, now whenever a client sends a request to the server it also sends a unique id with it so that the server can know from where the request is coming. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >HttpSessionBindingListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > is a interface which extends <b><i>java.util.EventListener</i></b><i> </i>interface. The purpose of the this interface is to notify an object when it is bound to or unbound from a session. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This interface has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >valueBound(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies the object that is being bound to a session and is responsible for identifying the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >valueUnBound(HttpSessionBindingEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies the object that is being unbound from a session and is responsible for identifying the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above method we can see that we have used the class <b>HttpSessionBindingEvent</b> as a argument to the methods. The object is notified by an <b>HttpSessionBindingEvent</b> object</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This class has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getName():</span></b><span style=";font-family:";font-size:9;color:navy;" > It returns the name with which the object is bound or unbound from the session.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getSession():</span></b><span style=";font-family:";font-size:9;color:navy;" > This method returns the session to or from which the object is bound or unbound.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class SessionBindingListenerExample extends HttpServlet {
<br /> public void doGet(HttpServletRequest req, HttpServletResponse res)
<br /> throws ServletException, IOException {
<br /> res.setContentType("text/html");
<br /> PrintWriter out = res.getWriter();
<br /> // Get the current session object, create one if necessary
<br /> HttpSession session = req.getSession();
<br /> // Add a UserName
<br /> session.setAttribute("name",
<br /> new UserName(getServletContext()));
<br /> out.println("This is the example of HttpSessionBindingListener");
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> public class UserName implements HttpSessionBindingListener {
<br /> ServletContext context;
<br /> public UserName(ServletContext context){
<br /> this.context = context;
<br /> }
<br /> public void valueBound(HttpSessionBindingEvent event) {
<br /> context.log("The value bound is " + event.getName());
<br /> }
<br /> public void valueUnbound(HttpSessionBindingEvent event) {
<br /> context.log("The value unbound is " + event.getName());
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1160" type="#_x0000_t75" alt="" style="'width:375.75pt;height:82.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image038.gif" href="http://www.roseindia.net/servlets/Sessio1.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >ServletRequestAttributeListener</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SessionBindingListenerExample.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1163" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1163" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1164" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1164" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/JdbcInsertImage.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1165" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1165" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >This listener is used when we want to know when a attribute has been added in a request, when a attribute has been removed and when it is replaced by another attribute. We can also say that this attribute is used when the developer is interested to be notified when the request attribute changes. Now you may be wondering what is an attribute. An attribute is an object set or you can simply say that it is name/value pair where the name refers to a <b>String</b> and a value refers to the <b>Object. </b></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><i><span style=";font-family:";font-size:9;color:navy;" >javax.servlet.ServletRequestAttributeListener</span></i></b><span style=";font-family:";font-size:9;color:navy;" > interface has following methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeAdded(ServletRequestAttributeEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever a new attribute is added to the servlet request.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeRemoved(ServletRequestAttributeEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute is removed from the servlet request.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">3.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >attributeReplaced(ServletRequestAttributeEvent event):</span></b><span style=";font-family:";font-size:9;color:navy;" > It notifies whenever the attribute gets replaced on the servlet request.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In the above methods you can see that we have used <b>ServletRequestAttributeEvent</b> class as a parameter to the above methods. This class is a event class which is used for notifications when the changes are made to the attributes of <b>ServletRequest</b> in an application.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The class <b>ServletRequestAttributeEvent</b> has two methods:</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">1.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getName() :</span></b><span style=";font-family:";font-size:9;color:navy;" > This method returns the name of the attribute that has been changed on the ServletRequest.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style=";font-family:";font-size:9;" ><span style="">2.<span style=";font-family:";font-size:7;" > </span></span></span><!--[endif]--><b><span style=";font-family:";font-size:9;color:navy;" >getValue():</span></b><span style=";font-family:";font-size:9;color:navy;" > This method will return the value of the attribute that has been added, removed or replaced by other attribute.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >Inserting Image in a database Table</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletRequestAttributeListener.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1168" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1168" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1169" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1169" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/SayHelloToSpain.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1170" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1170" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a case where we want that along with the name of the person and its information, his image should also come with all these things. After going through this tutorial you can better understand the concept of inserting a image in the database table, so go through this example properly. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To get the program working we need to use a <b>doGet()</b> method to write our business logic as it is server side programming so all the processing will be done by the container. First of all make a class named <b>JdbcInsertImage</b>, the name of the class should be such that the person can understand what the program is going to do. This class must extend the <b>HttpServlet</b> class which is an abstract method. Now inside the <b>doGet()</b> method call the method <b>getWriter()</b> of the class <b>PrintWriter</b>. To insert a image from our java program we need to make a connection between our java class and the <b>MySql</b> database which we are using. After the connection establishment we will pass a insertion query for the image in the <b>prepareStatement()</b> method of the <i>Connection</i> object which returns the <i>PreparedStatement</i> object. Note that the data type for the image we have used is <b>mediumblob</b>. It is case sensitive.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >As we have to insert an image file in our database so there is a need to use a <b>File</b> class of the <b>java.io</b> package. In the constructor of the <b>File</b> class pass the path of the file. To read the image file we will use <b>FileInputStream</b> class. To set the image in the database use the method <b>setBinaryStream()</b> of the <i>PreparedStatement</i> interface. If the image will be inserted in the database you will get the message "<i>image has been inserted</i>" otherwise "<i>image is not inserted</i>".</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style=";font-family:";font-size:9;" >import java.sql.*;<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >import java.io.*;<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >import javax.servlet.*;<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >import javax.servlet.http.*;<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >public class JdbcInsertImage extends<span style=""> </span>HttpServlet{<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >public void doGet(HttpServletRequest request, <o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >HttpServletResponse response) throws ServletException, IOException<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >{<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >PrintWriter pw = response.getWriter();<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >String connectionURL = "jdbc:mysql://localhost:3306/roseindia";<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >java.sql.Connection connection=null;<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >try<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >{<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >Class.forName("com.mysql.jdbc.Driver").newInstance();<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >connection = DriverManager.getConnection(connectionURL, <o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >"root", "root");<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >PreparedStatement pst = connection.prepareStatement<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >("insert into image values(?,?)");<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >File file = new File("C:/apache-tomcat-5.5.20/webapps<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >/mywork/grad_sm.gif");<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >FileInputStream fis = new FileInputStream(file);<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >pst.setBinaryStream(1,fis,fis.available());<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >pst.setString(2, "Tim");<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >int i = pst.executeUpdate();<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >if(i!=0)<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >{<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >pw.println("image has been inserted");<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >}<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >else<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >{<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >pw.println("image is not inserted");<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >}<span style=""> </span><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >}<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >catch (Exception e)<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >{<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >System.out.println(e);<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >}<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >}<o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" >}<o:p></o:p></span></pre></td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1171" type="#_x0000_t75" alt="" style="'width:295.5pt;height:38.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image039.gif" href="http://www.roseindia.net/servlets/JdbcIn9.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image039.gif" shapes="_x0000_i1171" border="0" width="394" height="51" /><!--[endif]--><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1172" type="#_x0000_t75" alt="" style="'width:333.75pt;height:78pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image040.gif" href="http://www.roseindia.net/servlets/JdbcIn10.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image040.gif" shapes="_x0000_i1172" border="0" width="445" height="104" /><!--[endif]--><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1173" type="#_x0000_t75" alt="" style="'width:294pt;height:54pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image041.gif" href="http://www.roseindia.net/servlets/JdbcIn11.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >say hello in spanish</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/JdbcInsertImage.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1176" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1176" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1177" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1177" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/accessed-date-in-servlet.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1178" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1178" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to display "<b>hello</b>" in <b>spanish</b> along with the date.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make this program we need to make a class <b>SayHelloToSpain</b>. To main logic of the program will be written inside the <b>doGet()</b> method of the servlet. To print "<b>hello</b>" in servlet <b>setHeader()</b> method of the response object should be "<b>es</b>". Here "<b>es</b>" means the content language is spanish.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br /> import java.io.*;
<br /> import java.text.*;
<br /> import java.util.*;
<br />
<br /> public class SayHelloToSpain extends HttpServlet {
<br /> public void doGet(HttpServletRequest req, HttpServletResponse res)
<br /> throws ServletException, IOException {
<br /> res.setContentType("text/plain");
<br /> PrintWriter out = res.getWriter();
<br /> res.setHeader("Content-Language", "es");
<br /> Locale locale = new Locale("es", "");
<br /> DateFormat df = DateFormat.getDateTimeInstance
<br /> (DateFormat.LONG,DateFormat.LONG,locale);
<br /> df.setTimeZone(TimeZone.getDefault());
<br /> out.println("Hello spain will be written in this way");
<br /> out.println("En Español:");
<br /> out.println("\u00a1Hola Mundo!");
<br /> out.println(df.format(new Date()));
<br /> }
<br /> }<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1179" type="#_x0000_t75" alt="" style="'width:332.25pt;height:114.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image042.gif" href="http://www.roseindia.net/servlets/SayHel4.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >Accessing Date In Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SayHelloToSpain.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1182" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1182" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1183" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1183" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/post-massage-in-servlet.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1184" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1184" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example, we are going to show how we can display a creation date of the session and last accessed date or time and id on our browser. It is very easy to display it on our browser by using the <b>Date</b> class of the <b>java.util</b> package. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >As we know that the our servlet extends the <b>HttpServlet</b> and overrides the <b><i>doGet()</i></b><i> </i>method which it inherits from the HttpServlet class. The server invokes <b>doGet() </b>method whenever web server receives the GET request from the servlet. The <b>doGet()</b> method takes two arguments first is HttpServletRequest object and the second one is HttpServletResponse object and this method throws the ServletException.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >getSession(): </span></b><span style=";font-family:";font-size:9;color:navy;" >getSession() is a method. This is the method that uses HttpServletRequest object. When you call the method with its argument as true, the servlet reference implementation creates a session if necessary. To properly maintain the session, you must call getSession() before any output to response.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >getCreationTime(): </span></b><span style=";font-family:";font-size:9;color:navy;" >getCreationTime() is a method. This is the method that returns the time when this session was created a long integer time.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >getLastAccessedTime(): </span></b><span style=";font-family:";font-size:9;color:navy;" >getLastAccessedTime() is a method. This is the method that returns the last time the client sends request with this session.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >getId(): </span></b><span style=";font-family:";font-size:9;color:navy;" >This is the method that returns a string containing the unique identifier assigned to this session.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Here is the code of this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*; </span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.util.*; </span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*; </span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*; </span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >AccessedDateServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet { </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter(); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >HttpSession session = request.getSession(</span></code><code><b><span style=";font-family:";" >true</span></b></code><code><span style=";font-family:";color:black;" >); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Date create = </span></code><code><b><span style=";font-family:";" >new </span></b></code><code><span style=";font-family:";color:black;" >Date(session.getCreationTime()); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Date accessed = </span></code><code><b><span style=";font-family:";" >new </span></b></code><code><span style=";font-family:";color:black;" >Date(session.getLastAccessedTime()); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"ID " </span></code><code><span style=";font-family:";color:black;" >+ session.getId()); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Create: " </span></code><code><span style=";font-family:";color:black;" >+ create); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Last Accessed: " </span></code><code><span style=";font-family:";color:black;" >+ accessed); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String dataName = request.getParameter(</span></code><code><span style=";font-family:";" >"dataName"</span></code><code><span style=";font-family:";color:black;" >); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(dataName != </span></code><code><b><span style=";font-family:";" >null </span></b></code><code><span style=";font-family:";color:black;" >&& dataName.length() > </span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >) {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String dataValue = request.getParameter(</span></code><code><span style=";font-family:";" >"dataValue"</span></code><code><span style=";font-family:";color:black;" >); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >session.putValue(dataName, dataValue); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String[] valueNames = session.getValueNames(); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(valueNames != </span></code><code><b><span style=";font-family:";" >null </span></b></code><code><span style=";font-family:";color:black;" >&& valueNames.length > </span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >) { </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >for </span></b></code><code><span style=";font-family:";color:black;" >(</span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i = </span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >; i <></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String str = valueNames[i]; </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String str1 = session.getValue(str).toString(); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(str + </span></code><code><span style=";font-family:";" >" = " </span></code><code><span style=";font-family:";color:black;" >+ str1); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >} </span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><code><span style=";font-family:";font-size:9;" ><a href="http://www.roseindia.net/servlets/AccessedDateServlet.java"><b>Download of this program:</b></a></span></code><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><code><b><span style=";font-family:";font-size:9;color:navy;" >XML file for this program:</span></b></code><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 340.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="454"> <tbody><tr style=""> <td style="padding: 0in; width: 339pt;" width="452"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >
<br /> <!--<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> -->
<br />
<br /> <web-app>
<br /> <servlet>
<br /> <servlet-name>amar</servlet-name>
<br /> <servlet-class>AccessedDateServlet</servlet-class>
<br /> </servlet>
<br /> <servlet-mapping>
<br /> <servlet-name>amar</servlet-name>
<br /> <url-pattern>/AccessedDateServlet</url-pattern>
<br /> </servlet-mapping>
<br /> </web-app><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Output of this program is given below.</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 306.75pt;" border="0" cellpadding="0" cellspacing="0" width="409"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1185" type="#_x0000_t75" alt="" style="'width:306.75pt;height:193.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image043.gif" href="http://www.roseindia.net/servlets/accessed.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Post Message In servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/accessed-date-in-servlet.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1188" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1188" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1189" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1189" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/show-parameter-in-servlet.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1190" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1190" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example, we are going to implement posting massage to servlet. In the following program, you will learn how to post massage. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Code Description:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The following program uses <b>getOutputStream()</b> method. This is the method that defines an object to assist a servlet in sending a response to the client . The servlet container creates a ServletResponse object and passes it as an argument to the servlet's service method. ServletOutputStream is a constructor. This constructor provides an output stream for sending data to the client. A ServletOutputStream object is created using response.getOutputStream() method. The servlet extends the HttpServlet and overrides the <b><i>doGet()</i></b> method which is inherited from HttpServlet class. The server invokes <b>doGet()</b> method whenever web server receives the GET request from the servlet.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to make one html in which we post the massage given by user. The controller will check if the username , password and comment entered by the user is blank then servlet will display massage null, if the username, password and comment entered by the user are not blank then servlet<span style=""> </span>will display the massage entered by the user.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Html file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ><title>post servlet</title></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ><h2>Post Massage</h2></span></code>
<br /> <code><span style=";font-family:";color:black;" ><form action="</span"></form></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><code><span style=";font-family:";" >"/amar/PostServlet" </span></code><code><span style=";font-family:";color:black;" >Method=</span></code><code><span style=";font-family:";" >"GET"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><p> Username: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"username" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:black;" ><p> Password: <input type="</span"><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:black;" ><p> Comment: <textarea rows="</span"></code><code><span style="font-family: ">2 </span></code><code><span style="font-family: ">COLS=</span></code><code><span style="font-family: ">50 </span></code><code><span style="font-family: ">height=</span></code><code><span style="font-family: ">"100" </span></code><code><span style="font-family: ">NAME=</span></code><code><span style="font-family: ">"comment"</span></code><code><span style="font-family: ">></textarea></p>
<br /></span></code>
<br /> <code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"submit" </span></code><code><span style=";font-family:";color:black;" >VALUE=</span></code><code><span style=";font-family:";" >"submit"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"reset" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"reset"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><code><b><span style=";font-family:";font-size:9;color:navy;" >Here is the code of this program:</span></b></code><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >PostServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ServletOutputStream out = response.getOutputStream();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try </span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"<title>" </span></code><code><span style="font-family: ">+ </span></code><code><span style="font-family: ">"</title>"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"<h1>" <code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"</span></code></h1>"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String name = request.getParameter(</span></code><code><span style=";font-family:";" >"username" </span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String password = request.getParameter(</span></code><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String comment = request.getParameter( </span></code><code><span style=";font-family:";" >"comment" </span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"Name:" </span></code><code><span style=";font-family:";color:black;" >+ name + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"Password:" </span></code><code><span style=";font-family:";color:black;" >+ password + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"Comment: " </span></code><code><span style=";font-family:";color:black;" >+ comment + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Throwable t ) {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"<p></p><pre>"<code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >t.printStackTrace( </span></code><code><b><span style=";font-family:";" >new </span></b></code><code><span style=";font-family:";color:black;" >PrintStream(out) );</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println (</span></code><code><span style=";font-family:";" >"</span></code></pre><p>"</p></span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println (</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><code><b><span style=";font-family:";font-size:9;color:navy;" ><a href="http://www.roseindia.net/servlets/PostServlet.java">Download of this program:</a></span></b></code><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><code><b><span style=";font-family:";font-size:9;color:navy;" >xml file of this program.</span></b></code><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 308.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="411"> <tbody><tr style=""> <td style="padding: 0in; width: 306.75pt;" width="409"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >
<br /> <!--<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> -->
<br /> <web-app>
<br /> <servlet>
<br /> <servlet-name>amar</servlet-name>
<br /> <servlet-class>PostServlet</servlet-class>
<br /> </servlet>
<br /> <servlet-mapping>
<br /> <servlet-name>amar</servlet-name>
<br /> <url-pattern>/PostServlet</url-pattern>
<br /> </servlet-mapping>
<br /> </web-app><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Output of this program.</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="0" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1191" type="#_x0000_t75" alt="" style="'width:404.25pt;height:316.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image044.gif" href="http://www.roseindia.net/servlets/image4.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 343.45pt;" border="0" cellpadding="0" cellspacing="0" width="458"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1192" type="#_x0000_t75" alt="" style="'width:343.5pt;height:207pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image045.gif" href="http://www.roseindia.net/servlets/image3.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Show Parameter In Servlet</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/post-massage-in-servlet.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1195" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1195" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1196" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1196" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1197" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1197" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this section, you will learn how to send and put all parameter names into the table. The<span style=""> </span>following program uses two methods, which is described below.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Code Description:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Here, in this example, you will also see the use of <b>getParameterNames()</b> method and <b>getParameterValues()</b> method. The logic of the program will be written inside the <b>doGet()</b> method which takes two arguments, first is <b><i>HttpServletRequest</i></b> interface and the second one is the <b><i>HttpServletResponse</i></b> interface and this method can throw <b>ServletException</b>.</span><span style=";font-family:";font-size:9;" > <span style="color:navy;">First, it looks up all the parameter names via the getParameterNames() method of HttpServletRequest. This returns an Enumeration. Next, it loops down the Enumeration in the standard manner, using hasMoreElements() method to determine when to stop and using nextElement to get each entry. Since nextElement returns an Object, it casts the result to a String and passes that to getParameterValues, yielding an array of Strings. If that array is one entry long and contains only an empty string, then the parameter had no values, and the servlet generates an italicized "<b>No Value</b>" entry. The array takes more then one entry long, then the parameter had multiple values and they are displayed in a table list. Otherwise the one main value is just placed into the table. </span><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >getParameterNames():</span></b><span style=";font-family:";font-size:9;" > <span style="color:navy;">getParameterNames() is a method. This is the method that returns the parameter names for the request as an enumeration of string .</span><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" > <b>getParameterValues:</b> getParameterValues() is a method. This is the method that returns the values of the specified parameter for the request as an array of strings or null if the named parameter does not exit.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Html file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><title>Form Post</title></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code><code><span style=";font-family:";" >"#FFFFFF"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><h1 align="</span"><code><span style=";font-family:";" >"center"</span></code><code><span style=";font-family:";color:black;" >>A Sample FORM using POST</span></code></h1></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><form action="</span"></form></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><code><span style=";font-family:";" >"/amar/ShowParameterServlet" </span></code><code><span style=";font-family:";color:black;" >method=</span></code><code><span style=";font-family:";" >"GET"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Item Number:</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"ItemNum"</span></code><code><span style=";font-family:";color:black;" >>
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Quantity: </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"Quantity"</span></code><code><span style=";font-family:";color:black;" >>
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><hr /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >First Name:</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"FirstName"</span></code><code><span style=";font-family:";color:black;" >>
<br /></span></code>
<br />
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Last Name:</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"LastName"</span></code><code><span style=";font-family:";color:black;" >>
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Address:</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><textarea name="</span"></code><code><span style="font-family: ">"address" </span></code><code><span style="font-family: ">ROWS=</span></code><code><span style="font-family: ">3 </span></code><code><span style="font-family: ">COLS=</span></code><code><span style="font-family: ">40</span></code><code><span style="font-family: ">></textarea>
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Credit Card:
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"RADIO" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"CardType" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"Visa"</span></code><code><span style=";font-family:";color:black;" >>Visa
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"RADIO" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"CardType" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"Master Card"</span></code><code><span style=";font-family:";color:black;" >>Master Card
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"RADIO" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"CardType" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"India Express"</span></code><code><span style=";font-family:";color:black;" >>India Express
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Enter the Credit Card Number:</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"CardNum"</span></code><code><span style=";font-family:";color:black;" >>
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Reenter the Credit Card Number:</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"CardNum"</span></code><code><span style=";font-family:";color:black;" >>
<br />
<br /></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><center>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"submit" </span></code><code><span style=";font-family:";color:black;" >VALUE=</span></code><code><span style=";font-family:";" >"Submit "</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"reset" </span></code><code><span style=";font-family:";color:black;" >value= </span></code><code><span style=";font-family:";" >"Reset"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code></center></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><code><b><span style=";font-family:";font-size:9;color:navy;" >Here is the code of this program:</span></b></code><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.util.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ShowParameterServlet </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String title =</span></code><code><span style=";font-family:";" >"Reading all request parameter"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"<title>" </span></code><code><span style="font-family: ">+</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">"<body bgcolor="\">\n" </span></code><code><span style="font-family: ">+</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">"<h1 align="center">" </span></code><code><span style="font-family: ">+ title + </span></code><code><span style="font-family: ">"</h1>\n" </span></code><code><span style="font-family: ">+</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">"<table border="1" align="center">\n" </span></code><code><span style="font-family: ">+</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">"<tr bgcolor="\">\n" </span></code><code><span style="font-family: ">+</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">"<td>Parameter Name</td><td>Parameter Value(s)</td>\n"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">Enumeration Names = request.getParameterNames();</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">while</span></b></code><code><span style="font-family: ">(Names.hasMoreElements()) {</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">String str = (String)Names.nextElement();</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(</span></code><code><span style="font-family: ">"<tr><td>" </span></code><code><span style="font-family: ">+ str + </span></code><code><span style="font-family: ">"</td><td>"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">String[] Values = request.getParameterValues(str);</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">if </span></b></code><code><span style="font-family: ">(Values.length == </span></code><code><span style="font-family: ">1</span></code><code><span style="font-family: ">) {</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">String paramValue = Values[</span></code><code><span style="font-family: ">0</span></code><code><span style="font-family: ">];</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">if </span></b></code><code><span style="font-family: ">(paramValue.length() == </span></code><code><span style="font-family: ">0</span></code><code><span style="font-family: ">)</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.print(</span></code><code><span style="font-family: ">"<i>No Value</i>"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">else</span></b></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.print(paramValue);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">else </span></b></code><code><span style="font-family: ">{</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(</span></code><code><span style="font-family: ">"<ul>"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">for</span></b></code><code><span style="font-family: ">(</span></code><code><b><span style="font-family: ">int </span></b></code><code><span style="font-family: ">i=</span></code><code><span style="font-family: ">0</span></code><code><span style="font-family: ">; i<values.length;></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(</span></code><code><span style="font-family: ">"<li>" </span></code><code><span style="font-family: ">+ Values[i]);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(</span></code><code><span style="font-family: ">"</ul>"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(</span></code><code><span style="font-family: ">"</td></tr></table>\n</body></html>"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: ">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><code><b><span style="font-size: 9pt; font-family: "><a href="http://www.roseindia.net/servlets/ShowParameterServlet.java">Download of this program:</a></span></b></code><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><code><b><span style="font-size: 9pt; font-family: ">xml file for this program:</span></b></code><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 221) none repeat scroll 0% 0%; width: 332.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="443"> <tbody><tr style=""> <td style="padding: 0in; width: 330.75pt;" width="441"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "><?xml version="1.0" encoding="ISO-8859-1"?><br /> <!--<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> --><br /> <br /> <web-app><br /> <servlet><br /> <servlet-name>amar</servlet-name><br /> <servlet-class>ShowParameterServlet</servlet-class><br /> </servlet><br /> <servlet-mapping><br /> <servlet-name>amar</servlet-name><br /> <url-pattern>/ShowParameterServlet</url-pattern><br /> </servlet-mapping><br /> </web-app><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">Output of this program.</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="0" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "><!--[if gte vml 1]><v:shape id="_x0000_i1198" type="#_x0000_t75" alt="" style="'width:327pt;height:225pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image046.gif" href="http://www.roseindia.net/servlets/showparameter1.gif"> </v:shape><![endif]--><!--[if !vml]--><br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 9pt; font-family: "> <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="0" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "><!--[if gte vml 1]><v:shape id="_x0000_i1199" type="#_x0000_t75" alt="" style="'width:441.75pt;height:429pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image047.gif" href="http://www.roseindia.net/servlets/showparameter2.gif"> </v:shape><![endif]--><!--[if !vml]--><br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 9pt; font-family: "> <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="0" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "><!--[if gte vml 1]><v:shape id="_x0000_i1200" type="#_x0000_t75" alt="" style="'width:345.75pt;height:373.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image048.gif" href="http://www.roseindia.net/servlets/showparameter3.gif"> </v:shape><![endif]--><!--[if !vml]--><br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "><o:p> </o:p></span></p> <h1><span style="font-size: 9pt; font-family: ">Inserting Data In Database table using Statement</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style="font-size: 9pt; font-family: "><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/SessionId.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1203" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1203" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1204" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1204" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletFetchingData.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1205" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1205" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">In this program we are going to insert the data in the database from our java program in the table stored in the database. </span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">To accomplish our goal we first have to make a class named as <b>ServletInsertingData,</b> which must extends the abstract <b>HttpServlet</b> class, the name of the class should be such that other person can understand what this program is going to perform. The logic of the program will be written inside the <b>doGet()</b> method that takes two arguments, first is <b><i>HttpServletRequest</i></b> interface and the second one is the <b><i>HttpServletResponse</i></b> interface and this method can throw <b>ServletException.</b></span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">Inside this method call the <b>getWriter() </b>method of the <b>PrintWriter</b> class. We can insert the data in the database only and only if there is a connectivity between our database and the java program. To establish the connection between our database and the java program we first need to call the method <b>forName(),</b> which is static in nature of the class Class. It takes one argument which tells about the database driver we are going to use. Now use the static method <b>getConnection()</b> of the <b>DriverManager</b> class. This method takes three arguments and returns the <i>Connection</i> object. SQL statements are executed and results are returned within the context of a connection. Now your connection has been established. Now use the method <b>createStatement()</b> of the <i>Connection</i> object which will return the <i>Statement</i> object. This object is used for executing a static SQL statement and obtaining the results produced by it. We have to insert a values into the table so we need to write a query for inserting the values into the table. This query we will write inside the <b>executeUpdate()</b> method of the <i>Statement </i>object. This method returns int value. </span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">If the record will get inserted in the table then output will show "record has been inserted" otherwise "sorry! Failure".</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><b><span style="font-size: 9pt; font-family: ">The code of the program is given below:</span></b><span style="font-size: 9pt; font-family: "> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 9pt; font-family: ">import </span></b></code><code><span style="font-size: 9pt; font-family: ">java.io.*;</span></code><span style="font-size: 9pt; font-family: "><br /> <code><b><span style="font-family: ">import </span></b></code><code><span style="font-family: ">java.sql.*;</span></code><br /> <code><b><span style="font-family: ">import </span></b></code><code><span style="font-family: ">javax.servlet.*;</span></code><br /> <code><b><span style="font-family: ">import </span></b></code><code><span style="font-family: ">javax.servlet.http.*;</span></code><br /> <br /> <code><b><span style="font-family: ">public class </span></b></code><code><span style="font-family: ">DataInsertion </span></code><code><b><span style="font-family: ">extends </span></b></code><code><span style="font-family: ">HttpServlet{</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">public void </span></b></code><code><span style="font-family: ">doGet(HttpServletRequest request, HttpServletResponse response)</span></code><code><b><span style="font-family: ">throws </span></b></code><span style="color: black;"><br /> <code><span style="font-family: "> ServletException, IOException{ </span></code></span><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">response.setContentType(</span></code><code><span style="font-family: ">"text/html"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">PrintWriter out = response.getWriter();</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">String url = </span></code><code><span style="font-family: ">"jdbc:mysql://localhost/zulfiqar?user=root&password=admin"</span></code><code><span style="font-family: ">;</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">Connection conn;</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">ResultSet rs;</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">try</span></b></code><code><span style="font-family: ">{</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">Class.forName(</span></code><code><span style="font-family: ">"org.gjt.mm.mysql.Driver"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">conn = DriverManager.getConnection(url);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">Statement statement = conn.createStatement();</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">String query = </span></code><code><span style="font-family: ">"insert into emp_sal values('zulfiqar', 15000)"</span></code><code><span style="font-family: ">;</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">int </span></b></code><code><span style="font-family: ">i = statement.executeUpdate(query);</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">if</span></b></code><code><span style="font-family: ">(i!=</span></code><code><span style="font-family: ">0</span></code><code><span style="font-family: ">){</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">out.println(</span></code><code><span style="font-family: ">"The record has been inserted"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">else</span></b></code><code><span style="font-family: ">{</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">out.println(</span></code><code><span style="font-family: ">"Sorry! Failure"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">rs = statement.executeQuery(</span></code><code><span style="font-family: ">"select * from emp_sal"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">while</span></b></code><code><span style="font-family: ">(rs.next()){</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">out.println(</span></code><code><span style="font-family: ">"<p><table>" </span></code><code><span style="font-family: ">+ rs.getString(</span></code><code><span style="font-family: ">1</span></code><code><span style="font-family: ">) + </span></code><code><span style="font-family: ">" " </span></code><code><span style="font-family: ">+ rs.getInt(</span></code><code><span style="font-family: ">2</span></code><code><span style="font-family: ">) + </span></code><code><span style="font-family: ">"</p></table>"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">rs.close();</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">statement.close();</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">catch </span></b></code><code><span style="font-family: ">(Exception e){</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">System.out.println(e);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: ">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">XML File for this program</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style="font-size: 9pt; font-family: "><?xml version=</span></code><code><span style="font-size: 9pt; font-family: ">"1.0" </span></code><code><span style="font-size: 9pt; font-family: ">encoding=</span></code><code><span style="font-size: 9pt; font-family: ">"ISO-8859-1"</span></code><code><span style="font-size: 9pt; font-family: ">?></span></code><span style="font-size: 9pt; font-family: "><br /> <code><span style="font-family: "><!--<!DOCTYPE web-app</span></code><br /> <code><span style="font-family: "Tahoma","sans-serif"; color: white;"> </span></code><code><span style="font-family: "Tahoma","sans-serif"; color: black;">PUBLIC </span></code><code><span style="font-family: "Tahoma","sans-serif"; color: rgb(42, 0, 255);">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="font-family: "Tahoma","sans-serif"; color: white;"> </span></code><code><span style="font-family: "Tahoma","sans-serif"; color: rgb(42, 0, 255);">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="font-family: "Tahoma","sans-serif"; color: black;">> --></span></code><br /> <br /> <code><span style="font-family: "><web-app></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-name>Hello</servlet-name></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-</span></code><code><b><span style="font-family: ">class</span></b></code><code><span style="font-family: ">>DataInsertion</servlet-</span></code><code><b><span style="font-family: ">class</span></b></code><code><span style="font-family: ">></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "></servlet></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-mapping></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-name>Hello</servlet-name></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><url-pattern>/DataInsertion</url-pattern></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "></servlet-mapping></span></code><br /> <code><span style="font-family: "></web-app></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">Table in the database before Insertion:</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 24%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="24%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: ">mysql> select * from emp_sal;<br /> Empty set (0.02 sec)</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">The output of the program is given below:</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 53%;" border="1" cellpadding="0" width="53%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <br /></td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">Table in the database after Insertion:</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 24%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="24%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 97.14%;" width="97%"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: ">mysql> select * from emp_sal;<br /> +----------+--------+<br /> | EmpName | salary |<br /> +----------+--------+<br /> | zulfiqar | 15000 |<br /> +----------+--------+<br /> 1 row in set (0.02 sec)</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style="font-size: 9pt; font-family: ">Retrieving Data from the table using Statement</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style="font-size: 9pt; font-family: "><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletInsertingData.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1209" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1209" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1210" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1210" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletInsertingDataUsingUsingHtml.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1211" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1211" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">In this program we are going to fetch the data from the database in the table from our java program. </span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">To accomplish our goal we first have to make a class named as <b>ServletFetchingData</b> which must extends the abstract <b>HttpServlet</b> class, the name of the class should be such that the other person can understand what this program is going to perform. The logic of the program will be written inside the <b>doGet()</b> method which takes two arguments, first is <b><i>HttpServletRequest</i></b> interface and the second one is the <b><i>HttpServletResponse</i></b> interface and this method can throw <b>ServletException</b>.</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">Inside this method call the <b>getWriter() </b>method of the <b>PrintWriter</b> class. We can retrieve the data from the database only and only if there is a connectivity between our database and the java program. To establish the connection between our database and the java program we firstly need to call the method <b>forName()</b> which is static in nature of the class <b>ClassLoader</b>. It takes one argument which tells about the database driver we are going to use. Now use the static method <b>getConnection()</b> of the <b>DriverManager</b> class. This method takes three arguments and returns the <i>Connection</i> object. SQL statements are executed and results are returned within the context of a connection. Now your connection has been established. Now use the method <b>createStatement()</b> of the <i>Connection</i> object which will return the <i>Statement</i> object. This object is used for executing a static SQL statement and obtaining the results produced by it. As we need to retrieve the data from the table so we need to write a query to select all the records from the table. This query will be passed in the <b>executeQuery()</b> method of <i>Statement</i> object, which returns the <i>ResultSet</i> object. Now the data will be retrieved by using the <b>getString()</b> method of the <i>ResultSet</i> object.</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><b><span style="font-size: 9pt; font-family: ">The code of the program is given below:</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 9pt; font-family: ">import </span></b></code><code><span style="font-size: 9pt; font-family: ">java.io.*;</span></code><span style="font-size: 9pt; font-family: "><br /> <code><b><span style="font-family: ">import </span></b></code><code><span style="font-family: ">java.sql.*;</span></code><br /> <code><b><span style="font-family: ">import </span></b></code><code><span style="font-family: ">javax.servlet.*;</span></code><br /> <code><b><span style="font-family: ">import </span></b></code><code><span style="font-family: ">javax.servlet.http.*;</span></code><br /> <br /> <code><b><span style="font-family: ">public class </span></b></code><code><span style="font-family: ">ServletFetchingDataFromDatabase1 </span></code><code><b><span style="font-family: ">extends </span></b></code><code><span style="font-family: ">HttpServlet{</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">public void </span></b></code><code><span style="font-family: ">doGet(HttpServletRequest request, HttpServletResponse response) </span></code><code><b><span style="font-family: ">throws </span></b></code><span style="color: black;"><br /> <code><span style="font-family: "> ServletException, IOException{</span></code></span><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">response.setContentType(</span></code><code><span style="font-family: ">"text/html"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">PrintWriter pw = response.getWriter();</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">String connectionURL = </span></code><code><span style="font-family: ">"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style="font-family: ">;</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">Connection connection=</span></code><code><b><span style="font-family: ">null</span></b></code><code><span style="font-family: ">;</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">try</span></b></code><code><span style="font-family: ">{</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">Class.forName(</span></code><code><span style="font-family: ">"org.gjt.mm.mysql.Driver"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">connection = DriverManager.getConnection(connectionURL, </span></code><code><span style="font-family: ">"root"</span></code><code><span style="font-family: ">, </span></code><code><span style="font-family: ">"admin"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">Statement st = connection.createStatement();</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">ResultSet rs = st.executeQuery(</span></code><code><span style="font-family: ">"Select * from emp_sal"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">while</span></b></code><code><span style="font-family: ">(rs.next()){</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(</span></code><code><span style="font-family: ">"EmpName" </span></code><code><span style="font-family: ">+ </span></code><code><span style="font-family: ">" " </span></code><code><span style="font-family: ">+ </span></code><code><span style="font-family: ">"EmpSalary" </span></code><code><span style="font-family: ">+ </span></code><code><span style="font-family: ">"<br />"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(rs.getString(</span></code><code><span style="font-family: ">1</span></code><code><span style="font-family: ">) + </span></code><code><span style="font-family: ">" " </span></code><code><span style="font-family: ">+ rs.getString(</span></code><code><span style="font-family: ">2</span></code><code><span style="font-family: ">) + </span></code><code><span style="font-family: ">"<br />"</span></code><code><span style="font-family: ">);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><b><span style="font-family: ">catch </span></b></code><code><span style="font-family: ">(Exception e){</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">pw.println(e);</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: ">}</span></code><br /> <code><span style="font-family: ">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">XML File for this program:</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style="font-size: 9pt; font-family: "><?xml version=</span></code><code><span style="font-size: 9pt; font-family: ">"1.0" </span></code><code><span style="font-size: 9pt; font-family: ">encoding=</span></code><code><span style="font-size: 9pt; font-family: ">"ISO-8859-1"</span></code><code><span style="font-size: 9pt; font-family: ">?></span></code><span style="font-size: 9pt; font-family: "><br /> <code><span style="font-family: "><!--<!DOCTYPE web-app</span></code><br /> <code><span style="font-family: "Tahoma","sans-serif"; color: white;"> </span></code><code><span style="font-family: "Tahoma","sans-serif"; color: black;">PUBLIC </span></code><code><span style="font-family: "Tahoma","sans-serif"; color: rgb(42, 0, 255);">"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code><br /> <code><span style="font-family: "Tahoma","sans-serif"; color: white;"> </span></code><code><span style="font-family: "Tahoma","sans-serif"; color: rgb(42, 0, 255);">"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style="font-family: "Tahoma","sans-serif"; color: black;">> --></span></code><br /> <br /> <code><span style="font-family: "><web-app></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-name>Hello</servlet-name></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-</span></code><code><b><span style="font-family: ">class</span></b></code><code><span style="font-family: ">>ServletFetchingDataFromDatabase</servlet-</span></code><code><b><span style="font-family: ">class</span></b></code><code><span style="font-family: ">></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "></servlet></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-mapping></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><servlet-name>Hello</servlet-name></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "><url-pattern>/ServletFetchingDataFromDatabase</url-pattern></span></code><br /> <code><span style="font-family: "> </span></code><code><span style="font-family: "></servlet-mapping></span></code><br /> <code><span style="font-family: "></web-app></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">The output of the program is given below:</span></b><span style="font-size: 9pt; font-family: "> <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 60%;" border="1" cellpadding="0" width="60%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "><!--[if gte vml 1]><v:shape id="_x0000_i1212" type="#_x0000_t75" alt="" style="'width:434.25pt;height:146.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image050.gif" href="http://www.roseindia.net/servlets/FetchingData.gif"> </v:shape><![endif]--><!--[if !vml]--><br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 9pt; font-family: ">Table in the database:</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 26%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="26%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 9pt; font-family: ">mysql> select * from emp_sal;<br /> +----------+--------+<br /> | EmpName | salary |<br /> +----------+--------+<br /> | zulfiqar | 15000 |<br /> | vinod | 12000 |<br /> +----------+--------+<br /> 2 rows in set (0.00 sec)</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "><o:p> </o:p></span></p> <h1><span style="font-size: 9pt; font-family: ">Inserting data from the HTML page to the database</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style="font-size: 9pt; font-family: "><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletFetchingData.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1215" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1215" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1216" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1216" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletFetchingDataFromDatabase.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1217" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1217" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">In this program we are going to make program in which we are going to insert the values in the database table from the html form. </span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">To make our program working we need to make one html form in which we will have two fields, one is for the name and the other one is for entering the password. At last we will have the submit form, clicking on which the values will be passed to the server. </span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">The values which we have entered in the Html form will be retrieved by the server side program which we are going to write. To accomplish our goal we first have to make a class named as <b>ServletInsertingDataUsingHtml</b> which must extends the abstract <b>HttpServlet</b> class, the name of the class should be such that the other person can understand what this program is going to perform. The logic of the program will be written inside the <b>doGet()</b> method which takes two arguments, first is <b><i>HttpServletRequest</i></b> interface and the second one is the <b><i>HttpServletResponse</i></b> interface and this method can throw <b>ServletException</b>.</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">Inside this method call the <b>getWriter() </b>method of the <b>PrintWriter</b> class. We can insert the data in the database only and only if there is a connectivity between our database and the java program. To establish the connection between our database and the java program we firstly need to call the method <b>forName()</b> which is static in nature of the class Class. It takes one argument which tells about the database driver we are going to use. Now use the static method <b>getConnection()</b> of the <b>DriverManager</b> class. This method takes three arguments and returns the <i>Connection</i> object. SQL statements are executed and results are returned within the context of a connection. Now your connection has been established. Now use the method <b>prepareStatement()</b> of the <i>Connection</i> object which will return the <i>PreparedStatement</i> object and takes one a query which we want to fire as its input. The values which we have got from the html will be set in the database by using the <b>setString()</b> method of the <i>PreparedStatement</i> object. </span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><span style="font-size: 9pt; font-family: ">If the record will get inserted in the table then output will show "record has been inserted" otherwise "sorry! Failure".</span><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <p><b><span style="font-size: 9pt; font-family: ">The code of the program is given below:</span></b><span style="font-size: 9pt; font-family: "><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style="font-size: 9pt; font-family: "><html></span></code><span style="font-size: 9pt; font-family: "><br /> <br /> <code><span style="font-family: "><head></span></code><br /> <code><span style="font-family: "><title>New Page </span></code><code><span style="font-family: ">1</span></code><code><span style="font-family: "></title></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><form method="</span"></form></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><code><span style=";font-family:";" >"POST" </span></code><code><span style=";font-family:";color:black;" >action=</span></code><code><span style=";font-family:";" >"/InDataByHtml/ServletInsertingDataUsingHtml"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><!--webbot bot=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"SaveResults" </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">U-File=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"fpweb:///_private/form_results.txt"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">S-Format=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"TEXT/CSV" </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">S-Label-Fields=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"TRUE" </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">--></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Enter Name: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><span style="color: rgb(42, 0, 255);">
<br /> <code><span style=";font-family:";" > </span></code></span><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"username" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Enter Password: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"password" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p> </p></span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"submit" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"Submit" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"B1"</span></code><code><span style=";font-family:";color:black;" >></span></code></code></span>
<br /> <code><span style=";font-family:";color:black;" ></span></code></p>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p><p></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" > ServletInsertingDataUsingHtml.java</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.lang.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletInsertingDataUsingHtml </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doPost(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String username = request.getParameter(</span></code><code><span style=";font-family:";" >"username"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String password = request.getParameter(</span></code><code><span style=";font-family:";" >"password"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(username);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(password);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"insert into emp_info values(?,?)"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >,username);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >2</span></code><code><span style=";font-family:";color:black;" >,password);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i = pst.executeUpdate();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if</span></b></code><code><span style=";font-family:";color:black;" >(i!=</span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"
<br />Record has been inserted"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"failed to insert the data"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch </span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletInsertingDataUsingHtml</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletInsertingDataUsingHtml</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 50%;" border="1" cellpadding="0" width="50%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1218" type="#_x0000_t75" alt="" style="'width:373.5pt;height:172.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image051.gif" href="http://www.roseindia.net/servlets/InDataByHtml.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >This is the output of the above input.</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 98.28%;" border="1" cellpadding="0" width="98%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.3%;" width="99%">
<br /></td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Retrieving Data from the table using PreparedStatement</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to fetch the data from the database in the table from our java program using <b>PreparedStatement</b>. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To accomplish our goal we first have to make a class named as <b>ServletFetchingDataFromDatabase</b> which must extends the abstract <b>HttpServlet</b> class, the name of the class should be such that the other person can understand what this program is going to perform. The logic of the program will be written inside the <b>doGet()</b> method which takes two arguments, first is <b><i>HttpServletRequest</i></b> interface and the second one is the <b><i>HttpServletResponse</i></b> interface and this method can throw <b>ServletException</b>.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Inside this method call the <b>getWriter() </b>method of the <b>PrintWriter</b> class. We can retrieve the data from the database only and only if there is a connectivity between our database and the java program. To establish the connection between our database and the java program we firstly need to call the method <b>forName()</b> which is static in nature of the class <b>ClassLoader</b>. It takes one argument which tells about the database driver we are going to use. Now use the static method <b>getConnection()</b> of the <b>DriverManager</b> class. This method takes three arguments and returns the <i>Connection</i> object. SQL statements are executed and results are returned within the context of a connection. Now your connection has been established. Now use the method <b>prepareStatement()</b> of the <i>Connection</i> object which will return the <i>PreparedStatement</i> object and takes a query as its parameter. In this query we will write the task we want to perform. The <i>Resultset</i> object will be retrieved by using the executeQuery() method of the <i>PreparedStatement</i> object. Now the data will be retrieved by using the <b>getString()</b> method of the <i>ResultSet</i> object.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletFetchingDataFromDatabase </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code><code><b><span style=";font-family:";" >throws </span></b></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" > </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection=</span></code><code><b><span style=";font-family:";" >null</span></b></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"Select * from emp_sal"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs = pst.executeQuery();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while</span></b></code><code><span style=";font-family:";color:black;" >(rs.next()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(rs.getString(</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >) +</span></code><code><span style=";font-family:";" >" " </span></code><code><span style=";font-family:";color:black;" >+ rs.getString(</span></code><code><span style=";font-family:";" >2</span></code><code><span style=";font-family:";color:black;" >)+</span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch </span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"hello"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1220" type="#_x0000_t75" alt="" style="'width:434.25pt;height:146.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image053.gif" href="http://www.roseindia.net/servlets/Servle19.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image053.gif" shapes="_x0000_i1220" border="0" width="579" height="195" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 150pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sal;
<br /> +----------+--------+
<br /> | EmpName | salary |
<br /> +----------+--------+
<br /> | zulfiqar | 15000 |
<br /> | vinod | 12000 |
<br /> +----------+--------+
<br /> 2 rows in set (0.00 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Getting Columns Names using Servlets</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where there is a need to know about the name of the columns without touching our database. As we are the programmers so why we need to worry about the database. We want to do the manipulation by sitting on our computer through our program without going into the database. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to exactly the same as we said above. To make this possible we need to make a class named <b>ServletGettingColumnsNames</b>, the name of the program should be such that if in future there is any need to make any change in the program, you can easily understand in which program you have to make a change. Now inside the <b>doGet()</b> method use the <b>getWriter()</b> method of the response object and its returns the <b>PrintWriter</b> object, which helps us to write on the browser. To get a column names from the database there is a need for the connection between the database and the java program. After the establishment of the connection with the database pass a query for retrieving all the records from the database and this will return the <i>PreparedStatement</i> object. To get the column names from the database we firstly need a reference of <i>ResultSetMetaData</i> object and we will get it only when if we have the <i>ResultSet</i> object. To get the object of the <i>ResultSet</i> we will call the method <b>executeQuery()</b> of the <i>PreparedStatement</i> interface. Now we have the object of the ResultSet. By the help of the <i>ResultSet</i> we can get the object of <i>ResultSetMetaData</i>. We will get it by calling the method <b>getMetaData()</b> of the <i>ResultSet</i> interface. The names of the columns will be retrieved by the method <b>getColumnsNames()</b> of the <i>ResultSetMetaData</i> interface. The output will be displayed to you by the <b>PrintWriter</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >javax.servlet.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletGettingColumnsNames </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection=</span></code><code><b><span style=";font-family:";" >null</span></b></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"select * from emp_details"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs = pst.executeQuery();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSetMetaData rsmd = rs.getMetaData();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >noOfColumns = rsmd.getColumnCount();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >//It shows the number of columns</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The number of columns are " </span></code><code><span style=";font-family:";color:black;" >+ noOfColumns + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >//It shows the name of the columns</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The name of the columns are:
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >for</span></b></code><code><span style=";font-family:";color:black;" >(</span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i =</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >; i<=noOfColumns;i++){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String names = rsmd.getColumnName(i);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(names);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >XML File for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletGettingColumnsNames</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletGettingColumnsNames</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 59%;" border="1" cellpadding="0" width="59%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1221" type="#_x0000_t75" alt="" style="'width:436.5pt;height:139.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image054.gif" href="http://www.roseindia.net/servlets/GetColumnNames.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image054.gif" shapes="_x0000_i1221" border="0" width="582" height="186" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 52%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="52%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 98.68%;" width="98%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_details;
<br /> +--------+----------+---------+-----------+----------+-------+---------+--------
<br /> -+
<br /> | userId | Name | surname | address1 | address2 | town | country | zipcode
<br /> |
<br /> +--------+----------+---------+-----------+----------+-------+---------+--------
<br /> -+
<br /> | 73979 | zulfiqar | Ahmed | Moradabad | Delhi | Okhla | India | 110025
<br /> |
<br /> +--------+----------+---------+-----------+----------+-------+---------+--------
<br /> -+
<br /> 1 row in set (0.00 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Getting Number of Columns</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletGettingColumnsNames.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1224" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1224" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1225" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1225" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletGettingNoOfRows.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1226" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1226" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where there is a need to know about the number of columns in the table without touching our database. As we are the programmers so why we should worry about the database. We want to do the manipulation by sitting on our computer through our program without going into the database. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to exactly the same as we said above. To make this possible we need to make a class named <b>ServletGettingNoOfColumns</b>, the name of the program should be such that if in future there is any need to make any change in the program, you can easily understand in which program you have to make a change. As we know that in Servlet the main logic of the program is written inside the <i>service</i> method and in turn the <i>service</i> method calls the <b>doGet()</b> method. Now inside the <b>doGet()</b> method use the <b>getWriter()</b> method of the response object and its returns the <b>PrintWriter</b> object, which helps us to write on the browser. To get the number of columns from the database table there is a need for the connection between the database and the java program. After the establishment of the connection with the database, pass a query for retrieving all the records from the database and this will return the <i>PreparedStatement</i> object. To get the number of columns from the database we firstly need a reference of <i>ResultSetMetaData</i> object and we will get it only when if we have the <i>ResultSet</i> object with us. To get the object of the <i>ResultSet</i> we will call the method <b>executeQuery()</b> of the <i>PreparedStatement</i> interface. Now we have the object of the <i>ResultSet</i>. By the help of the <i>ResultSet</i> we can get the object of <i>ResultSetMetaData</i>. We will get it by calling the method <b>getMetaData()</b> of the <i>ResultSet</i> interface. The number of columns in the databasd table will be retrieved by the method <b>getColumnsCount()</b> of the <i>ResultSetMetaData</i> interface. This method will return the integer type of value. The number of columns will be displayed on the browser by the <b>PrintWriter</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletGettingNoOfColumns </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code><code><b><span style=";font-family:";" >throws</span></b></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" > </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection=</span></code><code><b><span style=";font-family:";" >null</span></b></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"com.mysql.jdbc.Driver"</span></code><code><span style=";font-family:";color:black;" >).newInstance();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"select * from emp_details"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs = pst.executeQuery();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSetMetaData rsmd = rs.getMetaData();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >noOfColumns = rsmd.getColumnCount();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >//It shows the number of columns</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The number of columns are " </span></code><code><span style=";font-family:";color:black;" >+ noOfColumns);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletGettingNoOfColumns</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletGettingNoOfColumns</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" > Table emp_details in the database:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 60%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="60%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_details;
<br /> +--------+----------+---------+-----------+----------+--------+---------+-------
<br /> --+
<br /> | userId | Name | surname | address1 | address2 | town | country | zipcod
<br /> e |
<br /> +--------+----------+---------+-----------+----------+--------+---------+-------
<br /> --+
<br /> | 86372 | Zulfiqar | Ahmed | Moradabad | Rohini | Rohini | Delhi | 110025
<br /> |
<br /> +--------+----------+---------+-----------+----------+--------+---------+-------</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 94.18%;" border="1" cellpadding="0" width="94%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.28%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1227" type="#_x0000_t75" alt="" style="'width:406.5pt;height:107.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image055.gif" href="http://www.roseindia.net/servlets/NoOfColumns.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image055.gif" shapes="_x0000_i1227" border="0" width="542" height="143" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Getting Number of Rows</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where we want to know about the number of rows in the particular database table without touching our database. As we are the programmers so why we should worry about the database complexities. We want to find out the number of rows without going touching our back- end. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to exactly the same as we said above. To make this possible we need to make a class named <b>ServletGettingNoOfRows</b>, the name of the program should be such, if in future there is any need to make any change in the program, you can easily understand in which program you have to make a change. As we know that in <i>Servlet</i> the main logic of the program is written inside the <i>service</i> method and in turn the <i>service</i> method calls the <b>doGet()</b> method. Now inside the <b>doGet()</b> method use the <b>getWriter()</b> method of the response object and its returns the <b>PrintWriter</b> object, which helps us to write on the browser. To get the number of rows from the database table there is a need for the connection between the database and the java program. After the establishment of the connection with the database, fire a query for selecting the number of rows from the database table inside the executeQuery() method of the <i>PreparedStatement</i> object and returns the <i>ResultSet</i> object. Now we have the ResultSet object, by the help of this object we can get the number of rows we have in the database table. The number of rows we have in the database table will be displayed on the browser by the <b>PrintWriter</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletGettingNoOfRows </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code><code><b><span style=";font-family:";" >throws </span></b></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" > </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >rows=</span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >""</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs = pst.executeQuery(</span></code><code><span style=";font-family:";" >"select count(*) from emp_sal"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while </span></b></code><code><span style=";font-family:";color:black;" >(rs.next()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >rows = rs.getInt(</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The number of rows are " </span></code><code><span style=";font-family:";color:black;" >+ rows);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >XML File for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletGettingNoOfRows</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletGettingNoOfRows</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table emp_sal in the database:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 27%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="27%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sal;
<br /> +----------+--------+
<br /> | EmpName | salary |
<br /> +----------+--------+
<br /> | zulfiqar | 15000 |
<br /> | vinod | 12000 |
<br /> +----------+--------+
<br /> 2 rows in set (0.05 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 94.18%;" border="1" cellpadding="0" width="94%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.28%;" width="99%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1228" type="#_x0000_t75" alt="" style="'width:406.5pt;height:108pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image056.gif" href="http://www.roseindia.net/servlets/GetNoOfRows.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image056.gif" shapes="_x0000_i1228" border="0" width="542" height="144" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Deleting Rows From Table</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletGettingNoOfRows.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1231" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1231" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1232" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1232" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletDeletingAllRowsFromTable.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1233" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1233" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where we have entered some wrong data and in later situation it starts giving problem to the organization. Rather than go through with that data its better to delete that data. We can do it very easily through our program, what we need is a simple query. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to exactly the same as we said above. To make this possible we need to make a class named <b>ServletDeletingRowsFromTable</b>, the name of the program should be such, if in future there is any need to make any change in the program, you can easily understand in which program you have to make a change. As we know that in <i>Servlet</i> the main logic of the program is written inside the <i>service</i> method and in turn the <i>service</i> method calls the <b>doGet()</b> method. Now inside the <b>doGet()</b> method use the <b>getWriter()</b> method of the response object and its returns the <b>PrintWriter</b> object, which helps us to write on the browser. To delete the unwanted data from our table there is a need for the connection between the database and the java program. After the establishment of the connection with the database, fire a query for deleting the unwanted row in the database table. This query will be fired inside the <b>prepareStatement()</b> method of the <i>Connection</i> object and returns the <i>PreparedStatement</i> object. If the rows has been deleted from the database table then print the message <i>"row is deleted"</i> otherwise <i>"no rows has been deleted".</i></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >javax.servlet.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletDeletingRowsFromTable </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code><code><b><span style=";font-family:";" >throws</span></b></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" > </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >rows;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > (</span></code></span><code><span style=";font-family:";" >"delete from emp_sal where EmpName = 'vinod'"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i = pst.executeUpdate();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(i==</span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Row has been deleted"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"No rows has been deleted"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletDeletingRowsFromTable</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletDeletingRowsFromTable</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database before deletion:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 26%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="26%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sal;
<br /> +----------+--------+
<br /> | EmpName | salary |
<br /> +----------+--------+
<br /> | zulfiqar | 15000 |
<br /> | vinod | 12000 |
<br /> +----------+--------+
<br /> 2 rows in set (0.00 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 57%;" border="1" cellpadding="0" width="57%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1234" type="#_x0000_t75" alt="" style="'width:415.5pt;height:107.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image057.gif" href="http://www.roseindia.net/servlets/DeleteRows.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image057.gif" shapes="_x0000_i1234" border="0" width="554" height="143" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database after deletion:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 23%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="23%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 97.02%;" width="97%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sal;
<br /> +----------+--------+
<br /> | EmpName | salary |
<br /> +----------+--------+
<br /> | zulfiqar | 15000 |
<br /> +----------+--------+
<br /> 1 row in set (0.05 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Deleting All Rows From the database Table</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletDeletingRowsFromTable.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1237" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1237" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1238" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1238" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletAddingNewColumn.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1239" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1239" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where we have entered some wrong data and in later situation it starts giving problem to an organization or may become useless after sometime . Rather than go through with that data its better to delete that data. We can do it very easily through our program, what we need is a simple query. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >In this example we are going to exactly the same as we said above. To make this possible we need to make a class named <b>ServletDeletingAllRowsFromTable</b>, the name of the program should be such, if in future there is any need to make any change in the program, you can easily understand in which program you have to make a change. As we know that in <i>Servlet</i> the main logic of the program is written inside the <i>service</i> method and in turn the <i>service</i> method calls the <b>doGet()</b> method. Now inside the <b>doGet()</b> method use the <b>getWriter()</b> method of the response object and its returns the <b>PrintWriter</b> object, which helps us to write on the browser. To delete all the rows from our database table there is a need for the connection between the database and the java program. After the establishment of the connection with the database, fire a query for deleting all the rows in the database table. This query will be fired inside the <b>prepareStatement()</b> method of the <i>Connection</i> object and returns the <i>PreparedStatement</i> object. If the rows has been deleted from the database table then print the message <i>"all rows are deleted"</i> otherwise <i>"no rows has been deleted".</i></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletDeletingAllRowsFromTable </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"delete from emp_sal"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i = pst.executeUpdate();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(i==</span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"All rows are deleted"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"no rows has been deleted"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >XML File for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletDeletingAllRowsFromTable</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletDeletingAllRowsFromTable</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database before deletion:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 24%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="24%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sal;
<br /> +----------+--------+
<br /> | EmpName | salary |
<br /> +----------+--------+
<br /> | zulfiqar | 15000 |
<br /> | vinod | 12000 |
<br /> +----------+--------+
<br /> 2 rows in set (0.00 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 60%;" border="1" cellpadding="0" width="60%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1240" type="#_x0000_t75" alt="" style="'width:427.5pt;height:107.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image058.gif" href="http://www.roseindia.net/servlets/DeleteAllRows.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image058.gif" shapes="_x0000_i1240" border="0" width="570" height="143" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database after deletion:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 24%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="24%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 97.14%;" width="97%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sal;
<br /> Empty set (0.02 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >How to add a column in a table</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletDeletingAllRowsFromTable.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1243" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1243" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1244" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1244" border="0" width="96" height="19" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletDeletingTable.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1245" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1245" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where the requirement of the client gets changed and you have asked to modify the structure of the table. In reality it is the work of the database administrator but as a Java programmer you should know how you can modify the structure of the table. The problem is that we have to add a new column to our database by using the java program. There is no need to get panic. What we simply need is to use a <b>query</b> for adding a new column in the database table. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To get the desired result firstly we need to make a connection with our database. After connection has been established pass the query in the <b>prepareStatement()</b> for adding new column in the database. This method will return the <b>PreparedStatement</b> object. By the object of the <b>PreparedStatement </b>we will call the <b>executeUpdate()</b> which will tell the status of the table.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the example is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletAddingNewColumn </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code><code><b><span style=";font-family:";" >throws </span></b></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" > </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement</span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > (</span></code></span><code><span style=";font-family:";" >"alter table emp_details add column sal int(5)"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i = pst.executeUpdate();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(i==</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Column has been added"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"No column has been added"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletAddingNewColumn</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletAddingNewColumn</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p><span style=";font-family:";font-size:9;color:navy;" >How to delete a table in mysql</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span> <p style="text-align: center;" align="center"><span style=";font-family:";font-size:9;" ><script type="text/javascript"> <!-- google_ad_client = "pub-0714075272818912"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "000080"; google_color_text = "000080"; google_color_url = "000080"; //--> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script><a href="http://www.roseindia.net/servlets/ServletAddingNewColumn.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1249" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/images/previous.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1249" border="0" width="13" height="13" /><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/index.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1250" type="#_x0000_t75" alt="" style="'width:1in;height:14.25pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/images/bt_home.gif"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span></a> <a href="http://www.roseindia.net/servlets/ServletChangingColumnName.shtml"><span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1251" type="#_x0000_t75" alt="" style="'width:9.75pt;height:9.75pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/images/next.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1251" border="0" width="13" height="13" /><!--[endif]--></span></a><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >Consider a situation where we need to delete a table from a database. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To delete a table from the database firstly we need to make a connection with the database. When the connection has been established pass a query for deleting a table inside the <b>prepareStatement()</b> method and it will return the <b>PreparedStatement</b> object. Now call the method <b>executeUpdate() </b>of the <b><i>PreparedStatement</i></b> interface which will helps us to know the status of the program.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >javax.servlet.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletDeletingTable </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response) </span></code><code><b><span style=";font-family:";" >throws</span></b></code><b><span style="color: rgb(127, 0, 85);">
<br /> <code><span style=";font-family:";" > </span></code></span></b><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"drop table emp_sal"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i = pst.executeUpdate();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(i==</span></code><code><span style=";font-family:";" >0</span></code><code><span style=";font-family:";color:black;" >){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Table has been deleted"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >else</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"Table has not been deleted"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >XML File for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletDeletingTable</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletDeletingTable</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database before deletion:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 31%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="31%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sa
<br /> +----------+--------+
<br /> | EmpName | salary |
<br /> +----------+--------+
<br /> | zulfiqar | 15000 |
<br /> | vinod | 12000 |
<br /> +----------+--------+
<br /> 2 rows in set (0.00 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 49%;" border="1" cellpadding="0" width="49%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1252" type="#_x0000_t75" alt="" style="'width:375.75pt;height:105pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image060.gif" href="http://www.roseindia.net/servlets/DeleteTable.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Table in the database after deletion:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 44%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="44%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 98.44%;" width="98%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_sal;
<br /> ERROR 1146 (42S02): Table 'zulfiqar.emp_sal' doesn't exist</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Changing column name</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >We make a table for storing some type of data. Table keeps the data in the form of rows and columns. Column indicates the field while row indicate the data of the field. Now consider a scenario where we have a table and it consists some data and a situation arises where there is a need to change the name of the column. As this is not the work of the programmer to change the name of the field, but as a programmer we should be aware how we can change the name of the column. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The name of the column of the column will be changed by using the simple query. But before going into it we should see what are the initial steps to get the desired results. First of all make a database connection with your program. When the connection has been established pass a query for changing the column name in the <b>preparedStatement()</b>. This will return the <b>PreparedStatement</b> object.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >javax.servlet.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletChangingColumnName </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >,</span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"alter table emp_details </span></code><span style="color: rgb(42, 0, 255);">
<br /> </span> <code><span style=";font-family:";" >change firstname Name varchar(10)"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >i = pst.executeUpdate();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The name of the column has been changed"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The exception is " </span></code><code><span style=";font-family:";color:black;" >+ e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletChangingColumnName</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletChangingColumnName</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The table in the database before changing of column name:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 54%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="54%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_details;
<br /> +--------+----------+---------+-----------+----------+-------+-----------
<br /> | userId | Name | surname | address1 | address2 | town | country | zipcode
<br /> +--------+----------+---------+-----------+----------+-------+-----------
<br /> | 73979 | zulfiqar | Ahmed | Moradabad | Delhi | Okhla | India | 110025
<br /> +--------+----------+---------+-----------+----------+-------+-----------
<br /> 1 row in set (0.00 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 51%;" border="1" cellpadding="0" width="51%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1253" type="#_x0000_t75" alt="" style="'width:370.5pt;height:105pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image061.gif" href="http://www.roseindia.net/servlets/ChangingColumnNames.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The table in the database after changing the column name:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 45%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="45%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 98.48%;" width="98%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_details;
<br /> +--------+-----------+---------+-----------+----------+-------+-----------
<br /> | userId | firstname | surname | address1 | address2 | town | country | zipcode
<br /> +--------+-----------+---------+-----------+----------+-------+-----------
<br /> | 73979 | zulfiqar | Ahmed | Moradabad | Delhi | Okhla | India | 110025
<br /> +--------+-----------+---------+-----------+----------+-------+-----------
<br /> 1 row in set (0.03 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >insert into statement in sql using servlets</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this tutorial we are going to learn how we can insert a value from a html form in the table stored in the database. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >For inserting the values in the database table it is required to have a table in which we are going to insert the values. Now make one jsp page or html page where we will insert the values. In this program we have made one simple enquiry form which will get stored in the database table and when the data gets entered into the database then you will get a message. Make one submit button for inserting the values into the database. Firstly this values will go to the controller and retrieved the variables enter in the form by the method <b>getParameter()</b> method of the request object. Pass a query to insert the values retrieved from the html form. To set the values into the database use <b>setString()</b> method. To retrieve the values from the database use <b>getString()</b> method of the <b>PreparedStatement</b> object.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><span style=";font-family:";font-size:9;" >
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ><meta equiv="</span"></span></code><code><span style=";font-family:";" >"Content-Language" </span></code><code><span style=";font-family:";color:black;" >content=</span></code><code><span style=";font-family:";" >"en-us"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><meta equiv="</span"></span></code><code><span style=";font-family:";" >"Content-Type" </span></code><code><span style=";font-family:";color:black;" >content=</span></code><code><span style=";font-family:";" >"text/html; charset=windows-1252"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><meta name="</span"></span></code><code><span style=";font-family:";" >"GENERATOR" </span></code><code><span style=";font-family:";color:black;" >content=</span></code><code><span style=";font-family:";" >"Microsoft FrontPage 4.0"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><meta name="</span"></span></code><code><span style=";font-family:";" >"ProgId" </span></code><code><span style=";font-family:";color:black;" >content=</span></code><code><span style=";font-family:";" >"FrontPage.Editor.Document"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:black;" ><title>New Page </span></code><code><span style="font-family: ">1</span></code><code><span style="font-family: "></title></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><form method="</span"></form></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><span style=";font-family:";color:black;" ></span><code><span style=";font-family:";" >"POST" </span></code><code><span style=";font-family:";color:black;" >action=</span></code><code><span style=";font-family:";" >"/sqlStatServlet/ServletUserEnquiryForm"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><!--webbot bot=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"SaveResults" </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">U-File=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"fpweb:///_private/form_results.txt"</span></code><br /> <code><span style="Tahoma","sans-serif"; font-family:"color:white;"> </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">S-Format=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"TEXT/CSV" </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">S-Label-Fields=</span></code><code><span style="Tahoma","sans-serif"; color: rgb(42, 0, 255);font-family:"">"TRUE" </span></code><code><span style="Tahoma","sans-serif"; font-family:"color:black;">--></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>User Id: </p></span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > <input type="</span"></span></code></span><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"userId" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></code></span>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>First Name: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"firstname" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Surname: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"surname" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Address1: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"address1" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Address2: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"address2" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Town: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><span style="color: rgb(42, 0, 255);">
<br /> <code><span style=";font-family:";" > </span></code></span><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"town" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>City: </p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"country" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >><p></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p>Zip code: <input type="</span"><code><span style=";font-family:";" >"text" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"zipcode" </span></code><code><span style=";font-family:";color:black;" >size=</span></code><code><span style=";font-family:";" >"20"</span></code><code><span style=";font-family:";color:black;" >></span></code></p></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><p> </p></span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><input type="</span"></span></code><code><span style=";font-family:";" >"submit" </span></code><code><span style=";font-family:";color:black;" >value=</span></code><code><span style=";font-family:";" >"Submit" </span></code><code><span style=";font-family:";color:black;" >name=</span></code><code><span style=";font-family:";" >"B1"</span></code><code><span style=";font-family:";color:black;" >><p></p></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code></p>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p><p></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >ServletUserEnquiryForm.java</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.io.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.sql.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletUserEnquiryForm </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >init(ServletConfig config) </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >super</span></b></code><code><span style=";font-family:";color:black;" >.init(config);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >/**Process the HTTP Get request*/</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doPost(HttpServletRequest req, HttpServletResponse res) </span></code><span style="color:black;">
<br /> <code><span style=";font-family:";" > </span></code></span><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection=</span></code><code><b><span style=";font-family:";" >null</span></b></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >res.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter out = res.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >//get the variables entered in the form</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String uId = req.getParameter(</span></code><code><span style=";font-family:";" >"userId"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String fname = req.getParameter(</span></code><code><span style=";font-family:";" >"firstname"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String sname = req.getParameter(</span></code><code><span style=";font-family:";" >"surname"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String address1 = req.getParameter(</span></code><code><span style=";font-family:";" >"address1"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String address2 = req.getParameter(</span></code><code><span style=";font-family:";" >"address2"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String town = req.getParameter(</span></code><code><span style=";font-family:";" >"town"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String county = req.getParameter(</span></code><code><span style=";font-family:";" >"country"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String zipcode = req.getParameter(</span></code><code><span style=";font-family:";" >"zipcode"</span></code><code><span style=";font-family:";color:black;" >); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try </span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >// Load the database driver</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >// Get a Connection to the database</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >); </span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >//Add the data into the database</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String sql = </span></code><code><span style=";font-family:";" >"insert into emp_details values (?,?,?,?,?,?,?,?)"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(sql);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >1</span></code><code><span style=";font-family:";color:black;" >, uId);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >2</span></code><code><span style=";font-family:";color:black;" >, fname);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >3</span></code><code><span style=";font-family:";color:black;" >, sname);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >4</span></code><code><span style=";font-family:";color:black;" >, address1);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >5</span></code><code><span style=";font-family:";color:black;" >, address2);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >6</span></code><code><span style=";font-family:";color:black;" >, town);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >7</span></code><code><span style=";font-family:";color:black;" >, county);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.setString(</span></code><code><span style=";font-family:";" >8</span></code><code><span style=";font-family:";color:black;" >, zipcode);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >int </span></b></code><code><span style=";font-family:";color:black;" >numRowsChanged = pst.executeUpdate();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >// show that the new account has been created</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >" Hello : "</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >" '"</span></code><code><span style=";font-family:";color:black;" >+fname+</span></code><code><span style=";font-family:";" >"'"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pst.close();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(ClassNotFoundException e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"Couldn't load database driver: " </span></code><code><span style=";font-family:";color:black;" >+ e.getMessage());</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch</span></b></code><code><span style=";font-family:";color:black;" >(SQLException e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(</span></code><code><span style=";font-family:";" >"SQLException caught: " </span></code><code><span style=";font-family:";color:black;" >+ e.getMessage());</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch </span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(e);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >finally </span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >// Always close the database connection.</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try </span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >if </span></b></code><code><span style=";font-family:";color:black;" >(connection != </span></code><code><b><span style=";font-family:";" >null</span></b></code><code><span style=";font-family:";color:black;" >) connection.close();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch </span></b></code><code><span style=";font-family:";color:black;" >(SQLException ignored){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >out.println(ignored);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletUserEnquiryForm</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletUserEnquiryForm</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >Login.html form for the data input:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 54%;" border="1" cellpadding="0" width="54%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" ><!--[if gte vml 1]><v:shape id="_x0000_i1254" type="#_x0000_t75" alt="" style="'width:373.5pt;height:346.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image062.gif" href="http://www.roseindia.net/servlets/SqlStatServlet.gif"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the input data:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 92.46%;" border="1" cellpadding="0" width="92%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.26%;" width="99%">
<br /></td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >join tables mysql</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to join the two table by using the servlets and the result will be displayed in the browser.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To join the tables firstly it is important to make a connection between the java class and the database. In our program we are using the <b>MySql</b> database. To join the table it is important to have those tables in our database. First of all make a class named <b>ServletJoiningTables</b>. The name of the class should be such that it becomes clear that what the program is going to do. The logic of the program will be written inside the <b>doGet()</b> method which takes two arguments <b>HttpServletRequest</b> and <b>HttpServletResponse</b>. call the method <b>getWriter()</b> of the <b>PrintWriter</b> class, which is responsible for writing the contents on the browser. Our priority is to join the two tables so pass a query in <b>prepareStatement()</b> method which will return the <b>PreparedStatement</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The result will be displayed to you by the object of the <b>PrintWriter</b> class. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.sql.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletJoiningTables </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"SELECT *FROM "</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"emp_details"</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >" </span></code><span style="color: rgb(42, 0, 255);">
<br /> <code><span style=";font-family:";" > NATURAL JOIN "</span></code></span><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"Emp_sal"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs = pst.executeQuery();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"UserId" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"Name" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"Salary"</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while</span></b></code><code><span style=";font-family:";color:black;" >(rs.next()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String id = rs.getString(</span></code><code><span style=";font-family:";" >"userId"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String name = rs.getString(</span></code><code><span style=";font-family:";" >"Name"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String sal = rs.getString(</span></code><code><span style=";font-family:";" >"salary"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(id + </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ name + </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ sal + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch </span></b></code><code><span style=";font-family:";color:black;" >(Exception e){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The statement is not executed"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletJoiningTables</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletJoiningTables</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >Tables emp_details and emp_sal in the database:</span></b><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: black none repeat scroll 0% 0%; width: 64%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" width="64%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 100%;" width="100%"> <p class="MsoNormal"><span style=";font-family:";font-size:9;color:white;" >mysql> select * from emp_details;
<br /> +--------+----------+---------+-----------+----------+-------+---------+--------
<br /> -+
<br /> | userId | Name | surname | address1 | address2 | town | country | zipcode
<br /> |
<br /> +--------+----------+---------+-----------+----------+-------+---------+--------
<br /> -+
<br /> | 73979 | zulfiqar | Ahmed | Moradabad | Delhi | Okhla | India | 110025
<br /> |
<br /> +--------+----------+---------+-----------+----------+-------+---------+--------
<br /> -+
<br /> 1 row in set (0.00 sec)
<br />
<br /> mysql> select * from emp_sal;
<br /> +----------+--------+
<br /> | EmpName | salary |
<br /> +----------+--------+
<br /> | zulfiqar | 15000 |
<br /> | vinod | 12000 |
<br /> +----------+--------+
<br /> 2 rows in set (0.00 sec)</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;color:navy;" >Here we are getting data from the two tables in the database by combining them.</span><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 91.28%;" border="1" cellpadding="0" width="91%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.24%;" width="99%">
<br /></td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Natural Left Join</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to join the two table by using the servlets and the result will be displayed in the browser. This join will be natural left join. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To join the tables firstly it is important to make a connection between the java class and the database. In our program we are using the <b>MySql</b> database. To join the table in a natural left join manner it is important to have those tables in our database. First of all make a class named <b>ServletNaturalJoiningTables</b>. The name of the class should be such that it becomes clear that what the program is going to do. The logic of the program will be written inside the <b>doGet()</b> method which takes two arguments <b>HttpServletRequest</b> and <b>HttpServletResponse</b>. call the method <b>getWriter()</b> of the <b>PrintWriter</b> class, which is responsible for writing the contents on the browser. Our priority is to join the two tables so pass a query in <b>prepareStatement()</b> method which will return the <b>PreparedStatement</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The result will be displayed to you by the object of the <b>PrintWriter</b> class. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.sql.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletNaturalJoiningTables </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"org.gjt.mm.mysql.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"SELECT * FROM "</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"emp_details"</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"</span></code><span style="color: rgb(42, 0, 255);">
<br /> <code><span style=";font-family:";" > NATURAL LEFT JOIN "</span></code></span><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"emp_sal"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs = pst.executeQuery();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"UserId" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"\t" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"Firstname" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"\t" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"Salary"</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while</span></b></code><code><span style=";font-family:";color:black;" >(rs.next()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String id = rs.getString(</span></code><code><span style=";font-family:";" >"userId"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String name = rs.getString(</span></code><code><span style=";font-family:";" >"Name"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String sal = rs.getString(</span></code><code><span style=";font-family:";" >"salary"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(id + </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ name + </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ sal + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch </span></b></code><code><span style=";font-family:";color:black;" >(Exception e) {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The statement is not executed"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletNaturalJoiningTables</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletNaturalJoiningTables</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 97.24%;" border="1" cellpadding="0" width="97%"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 99.3%;" width="99%">
<br /></td> </tr> </tbody></table> <h1><span style=";font-family:";font-size:9;color:navy;" >Natural Right Join</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to join the two table by using the servlets and the result will be displayed in the browser. This join will be natural right join. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To join the tables firstly it is important to make a connection between the java class and the database. In our program we are using the <b>MySql</b> database. To join the table in a natural right join manner, it is important to have those tables in our database. First of all make a class named <b>ServletNaturalRightJoiningTables</b>. The name of the class should be such that it becomes clear that what the program is going to do. The logic of the program will be written inside the <b>doGet()</b> method which takes two arguments <b>HttpServletRequest</b> and <b>HttpServletResponse</b>. call the method <b>getWriter()</b> of the <b>PrintWriter</b> class, which is responsible for writing the contents on the browser. Our priority is to join the two tables so pass a query in <b>prepareStatement()</b> method which will return the <b>PreparedStatement</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The result will be displayed to you by the object of the <b>PrintWriter</b> class. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style=";font-family:";font-size:9;" >import </span></b></code><code><span style=";font-family:";font-size:9;color:black;" >java.sql.*;</span></code><span style=";font-family:";font-size:9;" >
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >java.io.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.*;</span></code>
<br /> <code><b><span style=";font-family:";" >import </span></b></code><code><span style=";font-family:";color:black;" >javax.servlet.http.*;</span></code>
<br />
<br /> <code><b><span style=";font-family:";" >public class </span></b></code><code><span style=";font-family:";color:black;" >ServletNaturalRightJoiningTables </span></code><code><b><span style=";font-family:";" >extends </span></b></code><code><span style=";font-family:";color:black;" >HttpServlet{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >public void </span></b></code><code><span style=";font-family:";color:black;" >doGet(HttpServletRequest request, HttpServletResponse response)</span></code><b><span style="color: rgb(127, 0, 85);">
<br /> </span></b><code><span style=";font-family:";color:black;" > </span></code><code><b><span style=";font-family:";" >throws </span></b></code><code><span style=";font-family:";color:black;" >ServletException, IOException{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >response.setContentType(</span></code><code><span style=";font-family:";" >"text/html"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PrintWriter pw = response.getWriter();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String connectionURL = </span></code><code><span style=";font-family:";" >"jdbc:mysql://localhost/zulfiqar"</span></code><code><span style=";font-family:";color:black;" >;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Connection connection;</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >try</span></b></code><code><span style=";font-family:";color:black;" >{</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >Class.forName(</span></code><code><span style=";font-family:";" >"com.mysql.jdbc.Driver"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >connection = DriverManager.getConnection(connectionURL, </span></code><code><span style=";font-family:";" >"root"</span></code><code><span style=";font-family:";color:black;" >, </span></code><code><span style=";font-family:";" >"admin"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PreparedStatement pst = connection.prepareStatement(</span></code><code><span style=";font-family:";" >"SELECT *FROM "</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"emp_details"</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"</span></code><span style="color: rgb(42, 0, 255);">
<br /> <code><span style=";font-family:";" > NATURAL RIGHT JOIN "</span></code></span><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"emp_sal"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >ResultSet rs = pst.executeQuery();</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"userId" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"\t" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"Firstname" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"\t" </span></code><code><span style=";font-family:";color:black;" >+ </span></code><code><span style=";font-family:";" >"salary"</span></code><code><span style=";font-family:";color:black;" >+</span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >while</span></b></code><code><span style=";font-family:";color:black;" >(rs.next()){</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String id = rs.getString(</span></code><code><span style=";font-family:";" >"userId"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String name = rs.getString(</span></code><code><span style=";font-family:";" >"Name"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >String sal = rs.getString(</span></code><code><span style=";font-family:";" >"salary"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(id + </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ name + </span></code><code><span style=";font-family:";" >"\t\t" </span></code><code><span style=";font-family:";color:black;" >+ sal + </span></code><code><span style=";font-family:";" >"
<br />"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><b><span style=";font-family:";" >catch </span></b></code><code><span style=";font-family:";color:black;" >(Exception e) {</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >pw.println(</span></code><code><span style=";font-family:";" >"The statement is not executed"</span></code><code><span style=";font-family:";color:black;" >);</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >}</span></code>
<br /> <code><span style=";font-family:";color:black;" >}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >web.xml file for this program:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><span style=";font-family:";font-size:9;color:black;" ></span></code><code><span style=";font-family:";font-size:9;" >"1.0" </span></code><code><span style=";font-family:";font-size:9;color:black;" >encoding=</span></code><code><span style=";font-family:";font-size:9;" >"ISO-8859-1"</span></code><code><span style=";font-family:";font-size:9;color:black;" >?></span></code><span style=";font-family:";font-size:9;" >
<br /> <code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" >PUBLIC </span></code><code><span style=";font-family:";" >"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"</span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";" >"http://java.sun.com/dtd/web-app_2_3.dtd"</span></code><code><span style=";font-family:";color:black;" >></span></code>
<br />
<br /> <code><span style=";font-family:";color:black;" ><web-app></web-app></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet></servlet></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-></servlet-></span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >>ServletNaturalRightJoiningTables</span></code><code><b><span style=";font-family:";" >class</span></b></code><code><span style=";font-family:";color:black;" >></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-mapping></servlet-mapping></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><servlet-name>Zulfiqar</servlet-name></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ><url-pattern>/ServletNaturalRightJoiningTables</url-pattern></span></code>
<br /> <code><span style=";font-family:";color:white;" > </span></code><code><span style=";font-family:";color:black;" ></span></code>
<br /> <code><span style=";font-family:";color:black;" ></span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p>
<br /><h1><span style=";font-family:";font-size:9;color:navy;" >GET and POST Method of HTTP</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><b><span style=";font-family:";font-size:9;color:navy;" >GET</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The Get is one the simplest Http method. Its main job is to ask the server for the resource. If the resource is available then then it will given back to the user on your browser. That resource may be a HTML page, a sound file, a picture file (JPEG) etc. We can say that get method is for getting something from the server. It doesn't mean that you can't send parameters to the server. But the total amount of characters in a GET is really limited. In get method the data we send get appended to the URL so whatever you will send will be seen by other user so can say that it is not even secure. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >POST</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >The Post method is more powerful request. By using Post we can request as well as send some data to the server. We use post method when we have to send a big chunk of data to the server, like when we have to send a long enquiry form then we can send it by using the post method. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >There are few more rarely used http methods including HEAD, PUT, TRACE, DELETE, OPTIONS and CONNECT.</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <h1><span style=";font-family:";font-size:9;color:navy;" >Select Color</span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></h1> <p><span style=";font-family:";font-size:9;color:navy;" >In this program we are going to selected the various color and on the basis of the selection the output will be displayed to the user. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >To make this program firstly we need to make one html page. Inside the page we will have one select option in which we will have our colors. We will also have a submit, clicking on which the values we have entered will be transferred to the server. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;color:navy;" >On the server we will create a session. The values which we have entered in the html form will be retrieved by the <b>getParameterValues()</b> of the <b>request</b> object. It returns the array of String. We will check the condition if there is any session available or not. If yes then we will set the attribute by using the <b>setAttribute() </b>method of the <b>HttpSession </b>object. The attribute we have set will be retrieved by the getAttribute method of the <b>HttpSession</b> object in the next page and the value will be displayed on the browser by the <b>PrintWriter</b> object. </span><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><b><span style=";font-family:";font-size:9;color:navy;" >The code of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><meta equiv="Content-Type" content="text/html; charset=ISO-8859-1"><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><title>Select the list of colors</title><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><span style=""> </span><form action="/ServletProject/ColorPage"><o:p></o:p></form></span><span style=";font-family:";font-size:9;" ></span><span style=";font-family:";font-size:9;" ></span><span style=";font-family:";font-size:9;" ></span><pre><span style=";font-family:";font-size:9;" ><span style=""> </span><select name="colors" size="5"> <option>Green</option> <option>Red</option> <option>Yellow</option> <option>Blue</option> <option>Black</option> </select><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><span style=""> </span><input name="submit" type="submit"><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><span style=""> </span></span><o:p></o:p></pre></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre><pre><span style=";font-family:";font-size:9;" ><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> /**
<br /> * Servlet implementation class for Servlet: ColorPage
<br /> *
<br /> */
<br /> public class ColorPage extends javax.servlet.http.HttpServlet implements
<br /> javax.servlet.Servlet {
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#HttpServlet()
<br /> */
<br /> public ColorPage() {
<br /> super();
<br /> }
<br />
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#doGet
<br /> (HttpServletRequest request, HttpServletResponse response)
<br /> */
<br /> protected void doGet(HttpServletRequest request, HttpServletResponse response)
<br /> throws ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> response.setContentType("text/html");
<br /> PrintWriter pw = response.getWriter();
<br /> HttpSession session = request.getSession();
<br /> String colors[] = request.getParameterValues("colors");
<br /> if(session!=null)
<br /> {
<br /> session.setAttribute("color",colors);
<br /> session.setMaxInactiveInterval(60);
<br /> }
<br /> pw.println("");
<br /> for(int i = 0; i<colors.length; the="" selected="" colors="" are="">
<br />");
<br /> }
<br /> pw.println("</colors.length;></span></p><form action=" /ServletProject/GetColors"><span style=";font-family:";font-size:9;" >");
<br /> pw.println("<input name=" submit)" type=" submit">");
<br /> pw.println("</span></form><span style=";font-family:";font-size:9;" >");
<br /> }
<br />
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
<br /> HttpServletResponse response)
<br /> */
<br /> protected void doPost(HttpServletRequest request, HttpServletResponse response)
<br /> throws ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> }
<br /> }<o:p></o:p></span><p></p> </td> </tr> </tbody></table> <p><span style=";font-family:";font-size:9;" > <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style=";font-family:";font-size:9;" >import java.io.*;
<br /> import javax.servlet.*;
<br /> import javax.servlet.http.*;
<br />
<br /> /**
<br /> * Servlet implementation class for Servlet: GetColors
<br /> *
<br /> */
<br /> public class GetColors extends HttpServlet {
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#HttpServlet()
<br /> */
<br /> public GetColors() {
<br /> super();
<br /> }
<br />
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#doGet(
<br /> HttpServletRequest request, HttpServletResponse response)
<br /> */
<br /> protected void doGet(HttpServletRequest request, HttpServletResponse response)
<br /> throws ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> response.setContentType("text/html");
<br /> PrintWriter pw = response.getWriter();
<br /> HttpSession session = request.getSession(false);
<br /> if(session == null)
<br /> {
<br /> pw.println("No session is available");
<br /> pw.println("We are creating a session for you. Creating.....");
<br /> session = request.getSession();
<br /> }
<br /> else
<br /> {
<br /> String getColors[] = (String[])session.getAttribute("color");
<br /> pw.println("");
<br /> for(int i= 0; i<getcolors.length;i++) the="" selected="" colors="" are="">
<br />");
<br /> }
<br /> pw.println("");
<br /> }
<br /> }
<br />
<br /> /* (non-Java-doc)
<br /> * @see javax.servlet.http.HttpServlet#doPost(
<br /> HttpServletRequest request, HttpServletResponse response)
<br /> */
<br /> protected void doPost(HttpServletRequest request, HttpServletResponse response)
<br /> throws ServletException, IOException {
<br /> // TODO Auto-generated method stub
<br /> }
<br /> }<o:p></o:p></getcolors.length;i++)></span></p> </td> </tr> </tbody></table> <p><b><span style=";font-family:";font-size:9;color:navy;" >The output of the program is given below:</span></b><span style=";font-family:";font-size:9;" ><o:p></o:p></span></p><span style=";font-family:";font-size:9;" > <!--[if gte vml 1]><v:shape id="_x0000_i1260" type="#_x0000_t75" alt="" style="'width:265.5pt;height:102pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image068.gif" href="http://www.roseindia.net/servlets/Select2.gif"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--><o:p></o:p></span><span style=";font-family:";font-size:9;" ><o:p></o:p></span> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-19773386812416605302009-01-02T02:02:00.000-08:002009-01-02T02:03:20.235-08:00Eclipse Tutorial <meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="0" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h3 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 3 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:3; font-size:13.5pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} p {mso-style-noshow:yes; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading3Char {mso-style-name:"Heading 3 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 3"; mso-ansi-font-size:13.5pt; mso-bidi-font-size:13.5pt; mso-fareast-language:EN-US; font-weight:bold;} p.HTMLBody, li.HTMLBody, div.HTMLBody {mso-style-name:"HTML Body"; mso-style-unhide:no; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; mso-layout-grid-align:none; text-autospace:none; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman"; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:.5in 1.0in .5in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:463353728; mso-list-type:hybrid; mso-list-template-ids:-1319089930 1487206650 1264202868 -1036485696 -561374918 1333660624 -1499417798 1480206346 1791554354 -2084425632;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l0:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l0:level3 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Wingdings;} @list l0:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l0:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l0:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l0:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l0:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l0:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1 {mso-list-id:468787270; mso-list-type:hybrid; mso-list-template-ids:-1565782316 1045874694 461246116 336217594 -752026374 -1282480678 1566847654 2019193508 2140065066 1991440470;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1:level2 {mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in;} @list l1:level3 {mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l1:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l1:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l1:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} @list l2 {mso-list-id:1009596764; mso-list-type:hybrid; mso-list-template-ids:-1729063966 -1010668084 -1975744576 1453517384 1561754180 582265286 -1307689558 357084446 -145196094 987371868;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2:level2 {mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in;} @list l2:level3 {mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in;} @list l2:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l2:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l2:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l2:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l2:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l2:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} @list l3 {mso-list-id:1554389302; mso-list-type:hybrid; mso-list-template-ids:-636317234 485281774 1691647452 -142173600 -642875136 1241930916 -1794497260 -729523276 -1777064900 2094683204;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l3:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l3:level3 {mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in;} @list l3:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l3:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l3:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l3:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l3:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l3:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} @list l4 {mso-list-id:1672833567; mso-list-type:hybrid; mso-list-template-ids:-435498154 262046732 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l4:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol;} @list l4:level2 {mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in;} @list l4:level3 {mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in;} @list l4:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l4:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l4:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l4:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l4:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l4:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} @list l5 {mso-list-id:1871646953; mso-list-type:hybrid; mso-list-template-ids:581880718 262046732 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol;} @list l5:level2 {mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in;} @list l5:level3 {mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in;} @list l5:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l5:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l5:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l5:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l5:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l5:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} @list l6 {mso-list-id:1923490254; mso-list-type:hybrid; mso-list-template-ids:52595278 1543790718 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l6:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.3in; mso-level-number-position:left; margin-left:.3in; text-indent:-.3in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l6:level2 {mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in;} @list l6:level3 {mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in;} @list l6:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l6:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l6:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l6:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l6:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l6:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} @list l7 {mso-list-id:2050572701; mso-list-type:hybrid; mso-list-template-ids:-323818956 1350229438 1543790718 -1038867814 -680258280 -2113341360 -590151802 1150564006 -801448940 -1870751152;} @list l7:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l7:level2 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:1.05in; mso-level-number-position:left; margin-left:1.05in; text-indent:-.3in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l7:level3 {mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in;} @list l7:level4 {mso-level-tab-stop:2.0in; mso-level-number-position:left; text-indent:-.25in;} @list l7:level5 {mso-level-tab-stop:2.5in; mso-level-number-position:left; text-indent:-.25in;} @list l7:level6 {mso-level-tab-stop:3.0in; mso-level-number-position:left; text-indent:-.25in;} @list l7:level7 {mso-level-tab-stop:3.5in; mso-level-number-position:left; text-indent:-.25in;} @list l7:level8 {mso-level-tab-stop:4.0in; mso-level-number-position:left; text-indent:-.25in;} @list l7:level9 {mso-level-tab-stop:4.5in; mso-level-number-position:left; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults ext="edit" spidmax="1038"> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout ext="edit"> <o:idmap ext="edit" data="1"> </o:shapelayout></xml><![endif]--> <p class="MsoNormal"><b><span style="font-size: 16pt;">
<br /><o:p></o:p></span></b></p> <h3><span style="font-size: 12pt;">Implement and Run a Welcome Program<o:p></o:p></span></h3> <ul type="disc"><li class="MsoNormal" style="">Click the Eclipse Icon <!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:formulas> <v:path extrusionok="f" gradientshapeok="t" connecttype="rect"> <o:lock ext="edit" aspectratio="t"> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style="'width:21pt;"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.wmz" title="" cropbottom="31208f" cropleft="21487f" cropright="6446f"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--> (this will create a new folder named <span style="font-family: "Arial","sans-serif";">workspace</span> on your h: Drive where you will be storing your Java projects).</li><li class="MsoNormal" style="">Eclipse will start and offer a Weclome page which you should close.</li><li class="MsoNormal" style=""><!--[if gte vml 1]><v:line id="_x0000_s1037" style="'position:absolute;left:0;text-align:left;flip:x;" from="14.4pt,8.45pt" to="203.4pt,49.05pt" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> </v:line><![endif]--><!--[if !vml]--><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1031" style="'position:absolute;left:0;text-align:left;margin-left:262.35pt;" coordsize="1080,1080" path="m1080,c1080,,540,540,,1080e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap side="left"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1030" style="'position:absolute;left:0;text-align:left;margin-left:28.35pt;" coordsize="1080,1080" path="m1080,c1080,,540,540,,1080e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap side="left"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->Create a new project by clicking on <b>File > New > Project</b></li></ul> <p class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" style="'width:402pt;height:240pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image006.png" title="" cropbottom="36910f" cropright="29705f"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--></p> <ul type="disc"><li class="MsoNormal" style="">Make sure <span style="font-family: "Arial","sans-serif";">Java</span> Project is selected, and then click <span style="font-family: "Arial","sans-serif";">Next</span> </li><li class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_s1026" style="'position:absolute;left:0;text-align:left;" coordsize="4680,1710" path="m4680,c3720,585,2760,1170,1980,1440,1200,1710,600,1665,,1620e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap anchorx="page"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->Name your project with a name indicating a project that will contain all labs this semester: <span style="font-family: "Arial","sans-serif";">1_Zac_Doe_Jane</span></li></ul> <p class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" style="'width:320.25pt;height:332.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image009.png" title=""> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--></p> <ul type="disc"><li class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_s1033" style="'position:absolute;left:0;text-align:left;" coordsize="180,2520" path="m180,c105,1050,30,2100,,2520e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap side="left"> </v:shape><![endif]--><!--[if !vml]--><span style="position: absolute; z-index: 251659264; left: 0px; margin-left: 235px; margin-top: 23px; width: 38px; height: 150px;"></span><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1032" style="'position:absolute;left:0;text-align:left;margin-left:91.35pt;" coordsize="1980,1800" path="m1980,c1980,,990,900,,1800e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap side="left"> </v:shape><![endif]--><!--[if !vml]--><span style="position: absolute; z-index: 251658240; left: 0px; margin-left: 116px; margin-top: 23px; width: 109px; height: 116px;"></span><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1034" style="'position:absolute;left:0;text-align:left;margin-left:10.35pt;" coordsize="2880,1200" path="m2880,c2040,480,1200,960,720,1080,240,1200,120,960,,720e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap side="left"> </v:shape><![endif]--><!--[if !vml]--><span style="position: absolute; z-index: 251660288; left: 0px; margin-left: 7px; margin-top: 11px; width: 170px; height: 88px;"></span><!--[endif]-->Create a class with <b style="">File > <span style="">New > Class</span></b></li></ul> <p class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" style="'width:289.5pt;height:319.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.png" title="" cropbottom="25286f" cropright="38196f"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--></p> <p class="MsoNormal" style="margin-left: 0.3in; text-indent: -0.3in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1035" style="'position:absolute;left:0;text-align:left;margin-left:55.35pt;" coordsize="1170,3660" path="m1170,60v,-30,,-60,-180,360c810,840,180,2040,90,2580,,3120,225,3390,450,3660e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap side="left" anchorx="page"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->After <span style="font-family: "Arial","sans-serif";">Name:</span> type the name of the class you want to create. For project 1, the first class you create will be called <b>Welcome</b>. After you type that in, click <b>Finish </b><span style="">(at bottom)</span>. </p> <p class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" style="'width:305.25pt;height:334.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image017.png" title=""> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--></p> <ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="color: green;"><span style="color: windowtext;">Select your </span><span style="font-family: "Arial","sans-serif"; color: windowtext;">Welcome.java</span><span style="color: windowtext;"> file, delete the following comments, but leave the class heading and the main method stub</span><span style="font-size: 10pt; font-family: "Courier New";"><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 10pt; font-family: "Courier New"; color: green;"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: green;">/*<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: green;"><span style=""> </span>* Created on Jan 17, 2005<o:p></o:p></span></p> <p class="HTMLBody" style=""><span style="color: green;"><span style=""> </span>*<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: green;"><span style=""> </span>* </span><span style="font-size: 10pt; font-family: "Courier New"; color: teal;">TODO </span><span style="font-size: 10pt; font-family: "Courier New"; color: green;">To change the template for this generated file go to<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: green;"><span style=""> </span>* Window - Preferences - Java - Code Style - Code Templates<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: green;"><span style=""> </span>*/</span><span style="font-size: 10pt; font-family: "Courier New"; color: green;"><o:p></o:p></span></p> <p class="HTMLBody" style=""><span style=""><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 51, 102);">/**</span><span style="font-size: 10pt; font-family: "Courier New"; color: teal;"><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 51, 102);"><span style=""> </span>*</span><span style="font-size: 10pt; font-family: "Courier New"; color: teal;"> @author </span><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 51, 102);">mercer<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 51, 102);"><span style=""> </span>*<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 51, 102);"><span style=""> </span>* TODO To change the template for this generated type comment go to<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 51, 102);"><span style=""> </span>* Window - Preferences - Java - Code Style - Code Templates<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style="">Select your <span style="font-family: "Arial","sans-serif";">Welcome.java</span> file and type in the following code as it is shown below (for now ignore the green comments at the top of the file). As you type, you may encounter squiggly red lines under portions of your code. This is the compiler telling you that you <span style="">may</span> have an error. To be sure, type the entire line as shown below. For help, look at the messages in the Tasks view under your program (or let the mouse hover over the error).</li></ul> <p style="margin-left: -0.5in;"><span style="color: black;"> <span style=""> </span> <!--[if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" style="'width:449.25pt;height:382.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image019.png" title="" cropleft="12456f"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span></p> <ul type="disc"><li class="MsoNormal" style="">Once everything is typed in, save the file by going to <b>File > Save </b>(or <b>Ctrl-S </b>for short). Saving the file compiles the code into a class file and updates the error messages. Fix any errors you may have before you go on. </li><li class="MsoNormal" style=""><!--[if gte vml 1]><v:shape id="_x0000_s1028" style="'position:absolute;left:0;text-align:left;" coordsize="180,1620" path="m,c,,90,810,180,1620e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap anchorx="page"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1029" style="'position:absolute;left:0;text-align:left;margin-left:190.35pt;" coordsize="180,1620" path="m,c,,90,810,180,1620e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap anchorx="page"> </v:shape><![endif]--><!--[if !vml]--><span style="position: absolute; z-index: 251655168; left: 0px; margin-left: 247px; margin-top: 17px; width: 32px; height: 129px;"></span><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1027" style="'position:absolute;left:0;text-align:left;margin-left:37.35pt;" coordsize="720,540" path="m,c,,360,270,720,540e" filled="f" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <v:path arrowok="t"> <w:wrap anchorx="page"> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->Next, go to <b>Run >Run As > Java Application</b></li></ul> <p><span style="color: black;"><!--[if gte vml 1]><v:shape id="_x0000_i1031" type="#_x0000_t75" style="'width:263.25pt;height:122.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image024.png" title="" cropbottom="45629f" cropleft="16604f" cropright="16773f"> </v:shape><![endif]--><!--[if !vml]-->
<br /><!--[endif]--></span></p> <ul type="disc"><li class="MsoNormal" style="">At the bottom of the screen in the Console box, you should see some output that says </li></ul> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: 0.5in;"><!--[if gte vml 1]><v:line id="_x0000_s1036" style="'position:absolute;" from="271.35pt,8.85pt" to="289.35pt,26.85pt" strokecolor="fuchsia" strokeweight="1.25pt"> <v:stroke dashstyle="1 1" endarrow="classic"> <w:wrap anchorx="page"> </v:line><![endif]--><!--[if !vml]--><span style="position: absolute; z-index: 251662336; left: 0px; margin-left: 360px; margin-top: 6px; width: 31px; height: 31px;"></span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; font-family: "Courier New"; color: blue; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style=""> </span>Welcome. What is your name? </span></p> <ul type="disc"><li class="MsoNormal" style="">Click on the console window to the right of this prompt </li><li class="MsoNormal" style="">Type in your name and press the enter key </li><ul type="circle"><li class="MsoNormal" style="">if you can't input anything, try clicking on the line below the prompt as you probably typed <span style="font-size: 10pt; font-family: "Courier New";">println </span>rather than <span style="font-size: 10pt; font-family: "Courier New";">print</span>. The program should respond with <span style="font-size: 10pt; font-family: "Courier New";">Hi </span><i><span style="font-size: 10pt;">your name</span></i><span style="font-size: 10pt; font-family: "Courier New";">. I hope you are doing well!</span> If your program doesn't seem to be behaving properly, go back and make sure that you entered the code correctly and try it again. </li></ul><li class="MsoNormal" style="">The dialog should look like this:</li></ul> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: 0.5in;"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; font-family: "Courier New"; color: blue; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">Welcome. What is your name? </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; font-family: "Courier New"; color: rgb(0, 200, 125); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">Jane</span><span style="font-size: 10pt; font-family: "Courier New";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: 0.5in;"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; font-family: "Courier New"; color: blue; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">Hi Jane! I hope you are doing well.</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><o:p> </o:p></p> <p class="MsoNormal" style=""><o:p> </o:p></p> <p class="MsoNormal" style=""><o:p> </o:p></p> <p class="MsoNormal" style="margin-left: 0.5in; text-indent: 0.5in;"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-82832128083853747042009-01-02T01:58:00.000-08:002009-01-02T02:01:52.335-08:00GETTING STARTED WITH ECLIPSE<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="0" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:1627400839 -2147483648 8 0 66047 0;} @font-face {font-family:"Arial Narrow"; panose-1:2 11 6 6 2 2 2 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 2048 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; mso-bidi-font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman"; mso-fareast-language:EN-US;} p.MsoHeader, li.MsoHeader, div.MsoHeader {mso-style-unhide:no; mso-style-link:"Header Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; mso-bidi-font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman"; mso-fareast-language:EN-US;} p.MsoBodyText, li.MsoBodyText, div.MsoBodyText {mso-style-unhide:no; mso-style-link:"Body Text Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; mso-hyphenate:none; tab-stops:-.5in; font-size:11.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; letter-spacing:-.15pt; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} span.BodyTextChar {mso-style-name:"Body Text Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Body Text"; mso-ansi-font-size:11.0pt; letter-spacing:-.15pt; mso-fareast-language:EN-US;} span.HeaderChar {mso-style-name:"Header Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Header; mso-ansi-font-size:12.0pt; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:.75in .5in .75in .75in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1; mso-endnote-numbering-style:arabic;} /* List Definitions */ @list l0 {mso-list-id:376469823; mso-list-type:hybrid; mso-list-template-ids:1896250258 -1420776270 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; mso-ansi-font-size:8.0pt; font-family:Symbol;} @list l1 {mso-list-id:442697649; mso-list-type:hybrid; mso-list-template-ids:138319528 770053564 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; mso-ansi-font-size:8.0pt; font-family:Symbol;} @list l1:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:.75in; mso-level-number-position:left; margin-left:.75in; text-indent:-.25in; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l2 {mso-list-id:700323034; mso-list-type:hybrid; mso-list-template-ids:1503699550 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol;} @list l3 {mso-list-id:1403722847; mso-list-type:hybrid; mso-list-template-ids:1222266554 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">OBTAINING AND INSTALLING ECLIPSE FOR YOUR HOME PC:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Since Eclipse is installed in the lab, obtaining it for your home PC is recommended, but not required.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">I couldn't find an official listing of Eclipse's system requirements. The following specifications are cobbled together from various sites that use Eclipse:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">256 MB RAM minimum (512 MB RAM recommended)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">400 MB hard disk space minimum<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Pentium III/600 MHz <span style=""> </span>or higher (1000 MHz recommended)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Microsoft Windows 2000 Professional or Windows XP<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoBodyText">If your home PC meets the system requirements and you'd like Eclipse for home usage, then read the rest of this section. Otherwise, jump to the next section.</p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">Eclipse is an Integrated Development Environment (IDE) that allows you to enter, compile, and run programs. The programs can be written in one of many different languages. In order to make a particular language work in Eclipse, the language's compiler must be installed. The compiler installation is separate from Eclipse's installation. To install Sun's Java compiler, go to this Web site:</p> <p class="MsoBodyText"><a href="http://java.sun.com/j2se/1.5.0/download.jsp">http://java.sun.com/j2se/1.5.0/download.jsp</a></p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">On that Web site, you'll see information on Sun's J2SE SDK (Java 2 Standard Edition Software Development Kit) compiler package. Feel free to read about all the download links and download the ones you want, but the only one you'll really need is the JDK 5.0 Update 3 link. Click that link. <span style="">Using the web site's prompts as a guide, you may have to follow a series of additional links in order to find the SDK download link that matches your particular operating system. If you're given the option of an offline download or an online download, either one will work, but I think the online one is less confusing. Download the SDK. After the download completes, install the SDK as directed by the web site's documentation.<o:p></o:p></span></p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">Important:</p> <p class="MsoBodyText" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->If your computer already has an older version of Java installed on it, that's not good enough. Many programs use code that requires JDK 5.0. So install JDK 5.0.</p> <p class="MsoBodyText" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->You must install the Java compiler <u>before</u> installing Eclipse. By installing in that order, the compiler commands will be automatically added to the Eclipse IDE.</p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">To obtain Eclipse, go to this Web site:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><a href="http://www.eclipse.org/downloads">http://www.eclipse.org/downloads</a><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoBodyText">Click on the <span style="font-family: "Tahoma","sans-serif";">Eclipse SDK 3.1</span> link (for Windows) and follow the instructions. Be aware that the download is rather large, so if you use a dial-up modem, it may take several hours.</p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">After the download is done, use Windows Explorer to find the downloaded file. Double click the file and follow the installation instructions.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoBodyText">After the download is done, use Windows Explorer to find the downloaded file. Since the downloaded file is in zip format, you'll need WinZip to unzip the files. If you don't know about WinZip, go to <a href="http://www.winzip.com/">www.winzip.com</a>.</p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">After WinZip is installed, double click the Eclipse download file to unzip it. When WinZip prompts you for the location of the extracted files, select your hard disk's root folder (e.g., <span style="font-family: "Courier New";">c:\</span>). WinZip will then automatically create an <span style="font-family: "Courier New";">eclipse</span> folder in your root folder and store Eclipse's files and subfolders in the <span style="font-family: "Courier New";">eclipse</span> folder.</p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">Aside:</p> <p class="MsoBodyText">Eclipse has a hard time with spaces in folder names. That's why you should refrain from installing Eclipse in the traditional installation folder, <span style="font-family: "Courier New";">Program Files</span>.</p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">After unzipping Eclipse's files, open a Windows Explorer window and look for the <span style="font-family: "Courier New";">eclipse.exe</span> file in your <span style="font-family: "Courier New";">c:\eclipse</span> folder. To start Eclipse, you'll need to use the <span style="font-family: "Courier New";">eclipse.exe</span> file in conjunction with the Java SDK's <span style="font-family: "Courier New";">javaw</span> file. More specifically, you'll need to execute this command:</p> <p class="MsoBodyText"><span style="font-size: 9pt; font-family: "Courier New";">C:\eclipse\eclipse.exe -vm "c:\Program Files\Java\jdk1.5.0_03\bin\javaw" -vmargs -Xmx256M<o:p></o:p></span></p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">Explanation:</p> <p class="MsoBodyText" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->The <span style="font-size: 9pt; font-family: "Courier New";">–vm "</span><span style="font-size: 9pt;"> </span><span style="font-size: 9pt; font-family: "Courier New";">c:\Program Files\Java\jdk1.5.0_03\bin\javaw"</span> option specifies the virtual machine (javaw is the virtual machine file). The quotes are necessary because of the space in the <span style="font-family: "Courier New";">Program Files</span> folder name.</p> <p class="MsoBodyText" style="margin-left: 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->The <span style="font-size: 9pt; font-family: "Courier New";">–vmargs –Xmx256M</span> option increases Eclipse's memory allocation (which improves Eclipse's speed).</p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">It's legal to execute the above command from a command prompt, but that's rather cumbersome. The better solution is to add the command to your desktop and to your <span style="font-family: "Tahoma","sans-serif";">Start / Programs</span> menu. Here's how to do that….</p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">In Windows Explorer, right click on the <span style="font-family: "Courier New";">eclipse.exe</span> file and select <span style="font-family: "Tahoma","sans-serif";">Create Shortcut</span> from the pop-up menu. Drag the newly created shortcut file to your desktop. Right click on your newly created desktop icon. Select <span style="font-family: "Tahoma","sans-serif";">Properties</span> from the pop-up menu. In the properties window, click on the <span style="font-family: "Tahoma","sans-serif";">General</span> tab. In the top box, overlay the given name with <span style="font-family: "Courier New";">Eclipse</span>. Click on the <span style="font-family: "Tahoma","sans-serif";">Shortcut</span> tab. In the <span style="font-family: "Tahoma","sans-serif";">Target</span> box, enter this:</p> <p class="MsoBodyText"><span style="font-size: 9pt; font-family: "Courier New";">c:\eclipse\eclipse.exe -vm "c:\Program Files\Java\jdk1.5.0_03\bin\javaw" -vmargs -Xmx256M<o:p></o:p></span></p> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoBodyText">Click <span style="font-family: "Tahoma","sans-serif";">OK</span> to close the properties window.</p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Right click on your Eclipse desktop icon and select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Copy</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> from the pop-up menu. In Windows Explorer, find the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">C:\Documents and Settings\All Users\Start Menu\Programs</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder. Right click on that folder and select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Paste</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> from the pop-up menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">SAVING FILES:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 6pt 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Modern integrated development environments (IDEs) have trouble compiling files on diskettes. That's because modern IDE's typically require lots of extra auxiliary memory space to do their work. Thus, do not attempt to compile your programs while they are on a diskette. If you're on your home PC, I assume that you'll want to use your PC's hard disk. If you're at the school's lab, do <u>not</u> use the hard disks! Instead, use a USB flash drive storage device.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 6pt 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If you want to buy a flash drive and use it on your home PC, make sure that your PC has a USB port. Most PC's (including our lab PC's) do have USB ports. If you can't find your computer's USB port, ask someone for help.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 6pt 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">To buy a flash drive, go to a computer store, Wal-mart, or shop online. This web site has decent prices:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 6pt 0.25in;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><a href="http://shop.store.yahoo.com/digi4me/newusbflasdi.html">http://shop.store.yahoo.com/digi4me/newusbflasdi.html</a><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 6pt 0.25in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 8pt; font-family: Symbol; letter-spacing: -0.15pt;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Typically, to install your USB flash drive, you simply have to plug your flash drive cable into your USB port. To copy to and from your USB flash drive, open Windows Explorer and drag files with your mouse. Typically, to remove your USB flash drive, you simply have to click an unplug icon in your system tray and then unplug your flash drive from your USB port. See your USB flash drive's product packaging for details.<o:p></o:p></span></p> <span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">
<br /> </span> <p class="MsoBodyText"><o:p> </o:p></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">ECLIPSE TUTORIAL:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoBodyText">When working on homework assignments, use Eclipse to enter, debug, and run your programs. If you forget how to do something in Eclipse, it is up to you to <u>carefully reread this Eclipse tutorial</u> and figure out how to do things. To reduce the number of rereads, go through this tutorial slowly and try to remember what you're doing.</p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">This tutorial uses x: to refer to the drive that you're saving your work on. In the lab, x: should be replaced by the USB drive (assuming that you're using a USB flash drive storage device). At home, x: should be replaced by the USB drive or the hard drive, whichever you prefer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Whenever you are asked to do an action (left column below) that you've already done before, I will refrain from providing the supplemental information (right column below). If you don't remember the details of how to do something, look for it earlier in the tutorial. I expect you to have to look up a lot of previously covered material. This is my attempt to force you to start memorizing how to do things.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <table class="MsoNormalTable" style="margin-left: -15.15pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"> <thead> <tr style="page-break-inside: avoid; height: 28.25pt;"> <td style="padding: 0in 5.75pt; width: 144.7pt; height: 28.25pt;" valign="top" width="193"> <p class="MsoNormal" style=""><u><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Actions</span></u><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt; height: 28.25pt;" valign="top" width="521"> <p class="MsoNormal" style=""><u><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Supplemental Information</span></u><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> </td> </tr> </thead> <tbody><tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Start Eclipse.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click on the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Start</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Programs</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Eclipse</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Create a workspace.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Selecting Eclipse (above) should cause a </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Workspace Launcher</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> dialog to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Workspace</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, enter </span><i style=""><span style="font-size: 11pt; letter-spacing: -0.15pt;">x:\219pgms</span></i><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Since this is the first time you've specified </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">x:\219pgms</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> in the workspace box, you'll be creating a new workspace – the 219pgms workspace. The 219pgms workspace is contained in the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">219pgms</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder. If the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">219pgms</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder doesn't exist, Eclipse will create it for you automatically.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Make sure the "Use this as a default and do not ask again" box is <u>un</u>checked.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click OK.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Clicking OK should cause Eclipse to create the 219pgms workspace and load a </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Welcome</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Go to the workbench.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">It's not required, but feel free to explore the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Welcome</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> screen's links.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">The workbench is the area where you'll do all your work – where you'll enter, debug, and run code. To close the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Welcome</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> screen and go to the workbench, click on the curved arrow in the top-right corner.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If there was no prompt for workspace.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If you ever load Eclipse and the Workspace Launcher dialog doesn't appear, that means someone checked the "Use this as a default and do not ask again" box. That's a bad thing (particularly in the lab) because then all users are taken to the same workspace location and that location might not be appropriate for everyone. To correct this problem, perform these steps after getting to the Eclipse workbench:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Window</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the container tree at the left of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, expand the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">General</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container by pressing its associated </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">+</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Startup and Shutdown</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Make sure the "Prompt for workspace on startup" box is checked.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click OK.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Coding-style preferences <span style=""> </span>- background information.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">You'll now set Eclipse's coding-style preferences so they match the ICS Department's coding-style conventions.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If you're in the lab, you should import the ICS Department's preferences file. If you're at your home PC, you should set your preferences manually. We’ll discuss both scenarios below.…<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">How to set coding-style preferences when you're in the lab.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If you're at your home PC, read this section, but don't perform the operations. If you're in the lab, perform these operations:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">As described above, open the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the container tree at the left of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, expand the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container and then the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Code Style</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Formatter</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Import…</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button in the top-right corner of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Import Profile</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, search for and select the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">icsDeptProfile.xml</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file in the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">x:\eclipse</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Open</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Finish</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">OK</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">How to set coding-style preferences and create a coding-style profile when you're at your home PC.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If you're in the lab, read this section, but don't perform the operations. If you're on your home PC, perform these operations:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Open the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the container tree at the left of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, expand the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container and then the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Code Style</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Formatter</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Select a profile</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, make sure that </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java Conventions</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> is selected.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Show…</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Show Profile</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Show Profile</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Indentation</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> tab.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Tab policy</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Spaces only</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Indentation size</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, enter 2.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Tab size</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, enter 2.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Make sure that the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Align fields in columns</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box is unchecked.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Make sure all the other boxes are checked.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Braces</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> tab at the top of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Show Profile</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">For all the boxes except the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">array initializer</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, make sure that </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">next line</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> is selected.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">For the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">array initializer</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, make sure that </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">same line</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> is selected.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">The rest of the code-style profile closely matches the ICS Department's coding-style conventions, so there's no need for any more preference adjustments.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">OK</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">When prompted for a profile name, enter </span><i style=""><span style="font-size: 11pt; letter-spacing: -0.15pt;">ICS Department</span></i><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">How to export coding-style preferences when you're at your home PC.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif";">I recommend that you put all of your homework into the same workspace. That way you can share your workspace's coding-style preferences. Nonetheless, there will probably come a time when you'll want to create a new workspace. When you do so, I recommend that you export your original workspace's coding-style preferences to an external file and then import that file into your new workspace. Here's how to export:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Open the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the container tree at the left of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, expand the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container and then the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Code Style</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Formatter</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Export…</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button in the top-right corner of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause an </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Export Profile</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">File name</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, enter </span><i style=""><span style="font-size: 11pt; letter-spacing: -0.15pt;">x:\eclipse\icsDeptProfile</span></i><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> and click </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Save</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">. Note that a .xml extension is appended to the filename by default.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Close the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If you'd like to test that your export worked, shut down Eclipse, open up a new workspace, and attempt to import the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">icsDeptProfile.xml</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif";"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Disable serialVersionUID warning.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">This step disables an annoying compiler warning that's generated for GUI programs. GUI programs typically use the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Component</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> class and the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Component</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> class implements the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Serializable</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> interface. The </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Serializable</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> interface encourages programmers to declare a serialVersionUID variable so that serialization can work properly. Serialization is an advanced topic that I'd prefer to skip for now. There's no need for you to be bothered with the annoying serialVersionUID warning. So disable the warning…<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Open the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the container tree at the left of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, expand the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container and then expand its </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Compiler</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Errors/Wannigs</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Errors/Warnings</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame, expand the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Potential programming problems section</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Serializable class without serialVersionUID</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Ignore</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Close the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Disabling the serialVersionUID warning only applies to your current workspace. If you use a different workspace, you'll need to perform this step again. This disabling step is not part of your preferences profile (and it therefore cannot be exported and imported).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Set compiler compliance level.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">This step also only applies to your current workspace, so if you use a different workspace, you'll need to perform this step again.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In checking for syntax errors, Eclipse uses the JDK 1.4 compiler by default. Thus, if you use Java 5.0 code (such as a System.out.printf statement), it will lead to a compile error. To change Eclipse's compiler to JDK 5.0, do the following:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Open the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the container tree at the left of the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, expand the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container and then select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Compiler</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the Compiler compliance level box, select 5.0.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Close the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Preferences</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">What is a project?<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">A project is an entity that helps to organize all the files in a particular program. A project's settings are stored in a </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">.project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file. The </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">.project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file is contained in the project's folder.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">How to organize your projects.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">I recommend that you use one workspace to store all your CS 219 projects. In this tutorial, you've already created a 219pgms workspace and you will create a tutorial project within that workspace. The 219pgms workspace uses a </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">219pgms</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder. The tutorial project will use a </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">tutorial</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder which is a subfolder of </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">219pgms</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">. For your homework assignments, I recommend that you create </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">hw1</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">, </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">hw2</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">, etc. projects within the 219pgms workspace.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Create a project.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">File</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">New.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Project…</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> from the pop-up sub-menu.</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">New Project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">New Project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java Project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click on the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Next</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Project name</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, enter </span><i style=""><span style="font-size: 11pt; letter-spacing: -0.15pt;">tutorial</span></i><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Next</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Finish</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button.<o:p></o:p></span></p> <p class="MsoNormal" style=""><o:p> </o:p></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Verify project creation.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Go to Windows Explorer and locate the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">x:\219pgms\tutorial</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder. Verify the existence of the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">.project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file within the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">tutorial</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder. If you don't see the tutorial folder, try selecting Refresh from the View menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Create a source-code file.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Package Explorer</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame on the left side of the workbench, right click on the tutorial project.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">New</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> from the pop-up menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">File</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> from the pop-up sub-menu.</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">New File</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">New File</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> window, select the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">tutorial</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">File name</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> box, enter </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Finish</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button.<o:p></o:p></span></p> <p class="MsoBodyText" style="">That should cause an empty <span style="font-family: "Courier New";">Hello.java</span> frame to appear in the workbench.</p> <p class="MsoBodyText" style=""><o:p> </o:p></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Enter this text:<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Enter this text in </span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">the </span><span style="font-size: 11pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif";"> frame</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> such that <your> is replaced with your actual name.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">/****************************************<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* Hello.java<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* <your><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* This program says "hello" to the world.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">****************************************/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">public class Hello<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">{<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>public static void main(String[] args)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>System.out.println("Hello world!");<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>} // end main<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">} // end class Hello<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Understand the code.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">The top section is known as the prologue section. It provides documentation for human readers. The compiler ignores everything between the opening <b style="">/*</b> and the closing <b style="">*/</b>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> methods should be enclosed in a class that is </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">public</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> and whose name matches the name of the enclosing file. For example, the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method above is enclosed in a </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">public</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> class named </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">. The class must be named </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> since the enclosing file is named </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Save the source file.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click on the save icon (the save icon looks like a diskette).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Compile your program.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Build Automatically</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option is checked, click it (so that it becomes unchecked). Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Build All</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option or the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Build Project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If necessary, fix compile errors.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Find your program in the Package Explorer pane. <o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">At the left of your Eclipse window, you should see a "Package Explorer" pane that contains your workspace's project folders. If the package explorer pane is not shown, open it as follows:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Arial Narrow","sans-serif"; letter-spacing: -0.15pt;">Windows</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Arial Narrow","sans-serif"; letter-spacing: -0.15pt;">Show View</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select the </span><span style="font-size: 11pt; font-family: "Arial Narrow","sans-serif"; letter-spacing: -0.15pt;">Package Explorer</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the Package Explorer pane, look for the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">tutorial</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container and expand it by pressing its associated +.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">tutorial</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container, look for the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">(default package)</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> container and expand it.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Look for your </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file inside the default package container.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Run the program.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Right click on the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a pop-up menu to appear, and within that menu, select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Run As</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java Application</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> in the pop-up submenu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a progress-bar dialog box to appear (if you've got a fast computer, you might not be able to see it). The progress bar indicates that a </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method is being searched for. The default place to find the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method is in the workbench's current class (i.e., the class that's currently displayed). For the current case, the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method is found in the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> class.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">After the progress-bar dialog box disappears, the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> tab should appear in the bottom of the workbench window.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click on the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> tab.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello world!</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> to appear in the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If necessary, fix runtime errors.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Create a second program.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">To create a new program, you can of course enter it from scratch as you did for the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> program. As a shortcut, this time we'll copy from an existing program and edit the copy.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Package Explorer</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame on the left side of the workbench, right click on the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the pop-up menu, select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Copy</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Right click on the tutorial project.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the pop-up menu, select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Paste</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Name Conflict</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> dialog to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">In the new name box, enter </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> (no need to enter the .java extension).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">OK</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause a </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file to appear in the tutorial project.<o:p></o:p></span></p> <p class="MsoBodyText" style=""><o:p> </o:p></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Open the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Double click on the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Edit the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Edit the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> file so that it contains this:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">/****************************************************<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* Countdown.java<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* <your><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">*<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* This program prints a countdown from a user-entered<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">* starting position.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">****************************************************/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">import java.util.Scanner;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">public class Countdown<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">{<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>public static void main(String[] args)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>int startPos;<span style=""> </span>// starting position for countdown<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>Scanner stdIn = new Scanner(System.in);<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>System.out.print("Enter countdown starting position: ");<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span></span><span style="font-size: 9pt; letter-spacing: -0.15pt;" lang="DA">startPos = stdIn.nextInt();<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;" lang="DA"><span style=""> </span>for (int i=startPos; i>0;)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;" lang="DA"><span style=""> </span></span><span style="font-size: 9pt; letter-spacing: -0.15pt;">{<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>System.out.println(i + "...");<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>System.out.println("Lift off!");<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;"><span style=""> </span>} // end main<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">} // end class Countdown</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Save the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> source file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Compile your program.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Note that the build commands compile more than just the one file that's displayed in the source-code frame. The </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Build All</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> command compiles all the files in your workspace and the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Build Project</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> command compiles all the files within your project. At this point, there's only one project in your workspace, so both build commands compile the same files - </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Hello.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> and <span style=""> </span></span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown.java</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If necessary, fix compile errors.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Run the program.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Run</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Run As</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Java Application</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> in the pop-up submenu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause the computer to look for a </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method. This time, since the workbench's current class is the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> class, the computer finds and uses the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> class's </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Open the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">You should see a prompt to enter the countdown starting position. Before entering your input value, you'll need to move the cursor to the right of the prompt within the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame. Since the prompt string includes a space after the colon, click at least one space to the right of the colon. Enter </span><i style=""><span style="font-size: 11pt; letter-spacing: -0.15pt;">30</span></i><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">After pressing enter, your </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame should be filled with multiple lines of </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">30...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Why is your </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame filled with multiple lines of </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">30...</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> ?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Terminate the program.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Your program is repeatedly printing the line </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">30...</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That's an example of an <i style="">infinite loop</i>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Note the red button at the upper-right corner of your </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame. The red button allows the user to terminate a program that's currently running. (Makes sense, right? Red for stop.)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">To stop the infinite loop, click the red button.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">As the program terminates, the red button should become non-red.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Find the error.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">An infinite loop is an example of a run-time error.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Run-time errors are often more difficult to debug than compile errors because you do not have the benefit of a compiler-generated error message.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Can you figure out the error?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Do not continue until you attempt to find the error.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Fix the error and recompile.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That's right, the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">for</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> loop heading is missing its third component.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Replace the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">for</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> loop heading with this line:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;" lang="DA">for (i=startPos; i>0; i--)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;" lang="DA"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Recompile.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Run the program using the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Run</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> icon.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">When you ran your program above, you had to wait for the computer to find the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method. After the computer finds the </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method the first time, if you want to run the same </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">main</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> method, you can do so using this shortcut….<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Look at the top of the workbench for a green-circle icon with a white triangular arrow inside it.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Hover your mouse over the icon.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause the message </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Run Countdown</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> to pop up.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the icon in order to run your </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">Countdown</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> program.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">You should be prompted to enter the countdown starting position.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Enter </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">30</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Your </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame should display this:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">Enter countdown starting position: 30<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">30 ...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">29 ...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><28><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">1 ...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; letter-spacing: -0.15pt;">Lift off!<o:p></o:p></span></p> <p class="MsoNormal" style="margin-top: 12pt;"><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Note that you'll probably need to scroll up and down to see the entire output.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If necessary, fix errors.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Print the output.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Use your mouse to select the output (in the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Console</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> frame).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Press C<span style="">trl+c</span> to copy the selected text.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Your output is now copied to your computer's buffer. You'll next need to paste it into a text editor so you can print it from there. Use the NotePad text editor, not Word or WordPad. NotePad is the preferred text editor because NotePad uses monospace font. Monospace font is good because that's what your actual program output uses.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">To open NotePad, click on the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Start</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> button. Then select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Programs</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> / </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Accessories</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> / </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">NotePad</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">.</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> That should cause a NotePad window to appear.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">To paste the previously copied text into NotePad, press Ctrl+v. To print the contents of NotePad, click on the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">File</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu and select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Print …</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Exit from Eclipse.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">X</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> in the top-right corner or select </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Exit</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> from the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">File</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> menu.<o:p></o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Start Eclipse<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">This time when you start Eclipse, the </span><span style="font-size: 11pt; font-family: "Tahoma","sans-serif"; letter-spacing: -0.15pt;">Workspace Launcher</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> dialog should display </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">x:\219pgms</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> as the suggested workspace.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Click OK.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">That should cause Eclipse to load your 219pgms workspace and your tutorial project.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">If the workspace launcher doesn't work.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Eclipse is open source and fairly new. Thus, there are bugs. I've found that I'm occasionally unable to reload a workspace. If that happens, use Windows Explorer to delete the workspace's </span><span style="font-size: 11pt; letter-spacing: -0.15pt;">.metadata</span><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"> folder. Then (re)create your workspace as described above.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0in 5.75pt; width: 144.7pt;" valign="top" width="193"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;">Exit from Eclipse.<o:p></o:p></span></p> </td> <td style="padding: 0in 5.75pt; width: 390.9pt;" valign="top" width="521"> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal" style=""><span style="font-size: 11pt; font-family: "Times New Roman","serif"; letter-spacing: -0.15pt;"><o:p> </o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-15147405650804428272009-01-02T01:54:00.000-08:002009-01-02T01:58:01.659-08:00JavaServer Pages (JSP ) v2.0 Syntax Reference <meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="0" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="0" name="footer"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Code"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:1627400839 -2147483648 8 0 66047 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h1 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 1 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:1; font-size:24.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} h2 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 2 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:2; font-size:14.0pt; font-family:"Arial","sans-serif"; mso-fareast-language:EN-US; font-weight:bold; font-style:italic;} h3 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 3 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:3; font-size:13.0pt; font-family:"Arial","sans-serif"; mso-fareast-language:EN-US; font-weight:bold;} h4 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 4 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:4; font-size:14.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold;} h5 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 5 Char"; mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:5; font-size:13.0pt; font-family:"Times New Roman","serif"; mso-fareast-language:EN-US; font-weight:bold; font-style:italic;} p.MsoHeader, li.MsoHeader, div.MsoHeader {mso-style-unhide:no; mso-style-link:"Header Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} p.MsoFooter, li.MsoFooter, div.MsoFooter {mso-style-unhide:no; mso-style-link:"Footer Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} code {mso-style-unhide:no; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 1"; mso-ansi-font-size:24.0pt; mso-bidi-font-size:24.0pt; mso-font-kerning:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.Heading2Char {mso-style-name:"Heading 2 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 2"; mso-ansi-font-size:14.0pt; mso-bidi-font-size:14.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-fareast-language:EN-US; font-weight:bold; font-style:italic;} span.Heading3Char {mso-style-name:"Heading 3 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 3"; mso-ansi-font-size:13.0pt; mso-bidi-font-size:13.0pt; font-family:"Arial","sans-serif"; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-fareast-language:EN-US; font-weight:bold;} span.Heading4Char {mso-style-name:"Heading 4 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 4"; mso-ansi-font-size:14.0pt; mso-bidi-font-size:14.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.Heading5Char {mso-style-name:"Heading 5 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 5"; mso-ansi-font-size:13.0pt; mso-bidi-font-size:13.0pt; mso-fareast-language:EN-US; font-weight:bold; font-style:italic;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} span.HeaderChar {mso-style-name:"Header Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Header; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; mso-fareast-language:EN-US;} span.FooterChar {mso-style-name:"Footer Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Footer; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:21.0pt 1.25in .75in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:12197474; mso-list-template-ids:-1483202866;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:169804263; mso-list-template-ids:1086651700;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:183597179; mso-list-template-ids:-1828033018;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l3 {mso-list-id:243495043; mso-list-template-ids:1299591046;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l4 {mso-list-id:255410043; mso-list-template-ids:90221036;} @list l4:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l5 {mso-list-id:278924942; mso-list-template-ids:823712710;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l6 {mso-list-id:290327596; mso-list-template-ids:913593542;} @list l6:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l7 {mso-list-id:290673220; mso-list-template-ids:1966086064;} @list l7:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l8 {mso-list-id:328367852; mso-list-template-ids:-204696466;} @list l8:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l9 {mso-list-id:343476266; mso-list-template-ids:-1004875252;} @list l9:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l10 {mso-list-id:344864189; mso-list-template-ids:-1234688422;} @list l10:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l11 {mso-list-id:394013849; mso-list-template-ids:1634220130;} @list l11:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l12 {mso-list-id:399182591; mso-list-template-ids:-6886226;} @list l12:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l13 {mso-list-id:444885196; mso-list-template-ids:1882752532;} @list l13:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l14 {mso-list-id:445537620; mso-list-template-ids:769672854;} @list l14:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l15 {mso-list-id:479690418; mso-list-template-ids:-1628387118;} @list l15:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l16 {mso-list-id:496503139; mso-list-template-ids:-1778078460;} @list l16:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l17 {mso-list-id:526337862; mso-list-template-ids:350392618;} @list l17:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l18 {mso-list-id:534998464; mso-list-template-ids:-2145253596;} @list l18:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l19 {mso-list-id:621352455; mso-list-template-ids:-2122277358;} @list l19:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l20 {mso-list-id:645354634; mso-list-template-ids:-355272250;} @list l20:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l21 {mso-list-id:646012765; mso-list-template-ids:1621511118;} @list l21:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l22 {mso-list-id:653142816; mso-list-template-ids:1471184398;} @list l22:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l23 {mso-list-id:675618817; mso-list-template-ids:253106446;} @list l23:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l24 {mso-list-id:788737987; mso-list-template-ids:26145156;} @list l24:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l25 {mso-list-id:802771989; mso-list-template-ids:-1022605018;} @list l25:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l25:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l26 {mso-list-id:807279638; mso-list-template-ids:1605007262;} @list l26:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l27 {mso-list-id:811139753; mso-list-template-ids:-1746479556;} @list l27:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l28 {mso-list-id:832263096; mso-list-template-ids:-376295602;} @list l28:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l29 {mso-list-id:877938094; mso-list-template-ids:-1193127154;} @list l29:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l30 {mso-list-id:885065931; mso-list-template-ids:176567282;} @list l30:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l31 {mso-list-id:886911704; mso-list-template-ids:-1447679700;} @list l31:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l32 {mso-list-id:893156181; mso-list-template-ids:1819546138;} @list l32:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l33 {mso-list-id:911626727; mso-list-template-ids:-1719881380;} @list l33:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l34 {mso-list-id:957182011; mso-list-template-ids:-905128810;} @list l34:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l35 {mso-list-id:969480023; mso-list-template-ids:910594566;} @list l35:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l36 {mso-list-id:989283328; mso-list-template-ids:-641947028;} @list l36:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l37 {mso-list-id:1003824134; mso-list-template-ids:-2141316712;} @list l37:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l38 {mso-list-id:1010909306; mso-list-template-ids:-2103249762;} @list l38:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l39 {mso-list-id:1035081717; mso-list-template-ids:-1453144610;} @list l39:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l40 {mso-list-id:1067609092; mso-list-template-ids:627370760;} @list l40:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l41 {mso-list-id:1197153928; mso-list-template-ids:414907688;} @list l41:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l42 {mso-list-id:1204901357; mso-list-template-ids:2135447310;} @list l42:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l43 {mso-list-id:1212577960; mso-list-template-ids:1414449584;} @list l43:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l44 {mso-list-id:1225722596; mso-list-template-ids:-516758648;} @list l44:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l45 {mso-list-id:1235168719; mso-list-template-ids:1164595588;} @list l45:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l46 {mso-list-id:1241327626; mso-list-template-ids:1719024688;} @list l46:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l47 {mso-list-id:1269311605; mso-list-template-ids:-1985058284;} @list l47:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l48 {mso-list-id:1276331240; mso-list-template-ids:1676544210;} @list l48:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l49 {mso-list-id:1322662062; mso-list-template-ids:1646945456;} @list l49:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l50 {mso-list-id:1326931577; mso-list-template-ids:1241683782;} @list l50:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l51 {mso-list-id:1340159980; mso-list-template-ids:944824648;} @list l51:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l52 {mso-list-id:1350984595; mso-list-template-ids:-1760662154;} @list l52:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l53 {mso-list-id:1357078855; mso-list-template-ids:2002702486;} @list l53:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l54 {mso-list-id:1401097173; mso-list-template-ids:1081409498;} @list l54:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l55 {mso-list-id:1429503232; mso-list-template-ids:-1945061186;} @list l55:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l56 {mso-list-id:1461149607; mso-list-template-ids:-892422582;} @list l56:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l57 {mso-list-id:1479684071; mso-list-template-ids:-1108025344;} @list l57:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l58 {mso-list-id:1488671455; mso-list-template-ids:346214816;} @list l58:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l59 {mso-list-id:1489901404; mso-list-template-ids:-1653046320;} @list l59:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l60 {mso-list-id:1535658725; mso-list-template-ids:-66950920;} @list l60:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l61 {mso-list-id:1554586116; mso-list-template-ids:1584181648;} @list l61:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l62 {mso-list-id:1601453488; mso-list-template-ids:-1377287020;} @list l62:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l63 {mso-list-id:1640726517; mso-list-template-ids:-2104619432;} @list l63:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l64 {mso-list-id:1689679493; mso-list-template-ids:1006266604;} @list l64:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l65 {mso-list-id:1709531626; mso-list-template-ids:598003658;} @list l65:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l66 {mso-list-id:1780906110; mso-list-template-ids:-2047969582;} @list l66:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l66:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l67 {mso-list-id:1797605792; mso-list-template-ids:2117884678;} @list l67:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l68 {mso-list-id:1818455334; mso-list-template-ids:493778238;} @list l68:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l69 {mso-list-id:1820145882; mso-list-template-ids:1925616584;} @list l69:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l69:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l70 {mso-list-id:1824275224; mso-list-template-ids:-1733278214;} @list l70:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l71 {mso-list-id:1847478359; mso-list-template-ids:-625830612;} @list l71:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l72 {mso-list-id:1863396848; mso-list-template-ids:-505269768;} @list l72:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l73 {mso-list-id:1908109622; mso-list-template-ids:264906446;} @list l73:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l74 {mso-list-id:1933121851; mso-list-template-ids:724959620;} @list l74:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l75 {mso-list-id:1935554518; mso-list-template-ids:-1743855418;} @list l75:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l76 {mso-list-id:1987854872; mso-list-template-ids:-1319234876;} @list l76:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l77 {mso-list-id:2045398860; mso-list-template-ids:-1224431008;} @list l77:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l78 {mso-list-id:2073116718; mso-list-template-ids:-1470046722;} @list l78:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l79 {mso-list-id:2082091564; mso-list-template-ids:-13981840;} @list l79:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l80 {mso-list-id:2086145586; mso-list-template-ids:-1490543492;} @list l80:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l81 {mso-list-id:2099054534; mso-list-template-ids:-348776298;} @list l81:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l82 {mso-list-id:2104372492; mso-list-template-ids:-447057450;} @list l82:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l83 {mso-list-id:2108456935; mso-list-template-ids:533395046;} @list l83:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l84 {mso-list-id:2119442705; mso-list-template-ids:-1716241344;} @list l84:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l85 {mso-list-id:2125228099; mso-list-template-ids:1224648998;} @list l85:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l85:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l85:level3 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:1.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Wingdings;} @list l86 {mso-list-id:2137142337; mso-list-template-ids:-888482442;} @list l86:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <h1 style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">CONTENTS<o:p></o:p></span></h1> <div align="center"> <table class="MsoNormalTable" style="background: rgb(198, 231, 222) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0"> <tbody><tr style=""> <td style="padding: 3.75pt;"> <p><a name="1010753"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Core Syntax <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1010755"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Description <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002571"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref203.html#1004313">Comment</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002573"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Documents the JSP page but is not inserted into the response. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002578"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref204.html#10983">Declaration</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002580"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Declares a variable or method valid in the scripting language used in the page. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002585"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref205.html#1004353">Expression</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002587"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Contains an expression valid in the scripting language used in the page. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002592"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996">Scriptlet</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002594"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Contains a code fragment valid in the scripting language used in the page. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1013066"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010522">EL Expression</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1013068"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Contains an expression in the JSP Expression Language (EL). See Expression Language section below for the syntax. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1011062"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Directives <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1011064"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Description <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003396"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref208.html#997991">Attribute Directive</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003398"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Declares an attribute of the custom tag defined in the tag file. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002606"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref209.html#1003408">Include Directive</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002608"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Includes a resource of text or code when the JSP page is translated. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002613"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2010.html#15653">Page Directive</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002615"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Defines attributes that apply to an entire JSP page. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003392"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2011.html#8780">Tag Directive</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1004184"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Similar to the page directive in a JSP page, but applies to tag files instead of JSP pages. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002620"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2012.html#1003416">Taglib Directive</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002622"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Defines a tag library and prefix for the custom tags used in the JSP page. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003380"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2013.html#15694">Variable Directive</a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003382"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Defines an expression language variable exposed by the tag to the calling page. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1011075"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Standard Actions <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1011077"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Description <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003453"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2014.html#1003424"><jsp:attribute></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003455"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Used as a substitute for attributes of standard or custom actions. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003449"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2015.html#1006731"><jsp:body></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003451"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Explicitly defines an element body. This tag is required if the enclosing element contains any jsp:attribute tags. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003794"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2016.html#1003696"><jsp:element></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003796"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Dynamically generates an XML element <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003445"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2017.html#1003341"><jsp:dobody></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003447"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Evaluates the body of the tag used by the calling page to invoke this tag file. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002627"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2018.html#1003349"><jsp:forward></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002629"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Forwards a request to an HTML file, JSP page, or servlet. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002634"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2019.html#8820"><jsp:getproperty></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002636"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Inserts the value of a bean property into the response. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002641"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2020.html#8828"><jsp:include></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002643"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Includes a static resource or the result from another web component <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1004165"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2021.html#8837"><jsp:invoke></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1010378"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Evaluates a fragment attribute. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1010387"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2022.html#1004130"><jsp:output></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1010391"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Specifies the XML declaration or the document type declaration in the request output of a JSP document or a tag file that is in XML syntax. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002648"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2023.html#1004158"><jsp:plugin></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002650"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Causes the execution of an applet or bean. The applet or bean executes in the specified plugin. If the plugin is not available, the client displays a dialog to initiate the download of the plugin software. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003369"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2024.html#1003283"><jsp:root></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003371"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Defines standard elements and namespace attributes of tag libraries. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002655"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#8856"><jsp:setproperty></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002657"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Sets a bean property value or values. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1003376"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2026.html#1003322"><jsp:text></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1003378"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Encloses template data. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p><a name="1002662"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2027.html#8865"><jsp:usebean></a> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p><a name="1002664"></a><span style="font-size: 9pt; font-family: "Tahoma","sans-serif";">Instantiates or references a bean with a specific name and scope. <o:p></o:p></span></p> </td> </tr> </tbody></table> </div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Preface<o:p></o:p></span></h2> <p><a name="1002716"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">All tags are case sensitive. A pair of single quotes is equivalent to a pair of double quotes. Spaces are not allowed between an equals sign and an attribute value. <o:p></o:p></span></p> <p><a name="1002679"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The elements in a JSP page can be expressed in JSP syntax or XML syntax. The following rules apply: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1002674"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP and XML syntax cannot be mixed within a page. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1002675"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A page in one syntax can include or forward to a page in the other syntax.<o:p></o:p></span></li></ul> <h3><a name="1002694"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Quoting Conventions<o:p></o:p></span></h3> <p><a name="1002712"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following outlines quoting conventions for JSP pages expressed in JSP syntax. <o:p></o:p></span></p> <h4><a name="1002697"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Scripting Elements<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1002700"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">%> by %\> <o:p></o:p></span></li></ul> <h4><a name="1011089"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">EL Expressions<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1011093"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">a literal ${ by '${' <o:p></o:p></span></li></ul> <h4><a name="1002701"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Template Text<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1002702"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><% by <\% <a name="1011097"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Only when the EL is enabled for a page, a literal $ by \$. This is used for quoting EL expressions. <o:p></o:p></span></li></ul> <h4><a name="1002703"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1002704"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">' as \'. This is required within a single quote-delimited attribute value. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1002705"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" as \". This is required within a double quote-delimited attribute value.<a name="1002706"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">\ as \\<a name="1002707"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">%> as %\><a name="1002708"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><% as <\%<a name="1002709"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">' and " can be used to indicate single and double quotes.<o:p></o:p></span></li></ul> <h3><a name="1002548"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Typographic Conventions <o:p></o:p></span></h3> <table class="MsoNormalTable" style="" border="1" cellpadding="0"> <tbody><tr style=""> <td style="padding: 3pt;"> <p><a name="1002743"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">code</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> = fixed <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1002745"></a><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">bold</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> = default <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1002747"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">italics = user-defined <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1002749"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">| = or <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3pt;"> <p><a name="1002751"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">[ ] = optional <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1002753"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">{ } = required choice <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1002755"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">... = list of items <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1002757"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">+ = can repeat <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3pt;"> <p><a name="1008336"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">' ' = literal <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1008338"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">() = grouped together <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1008340"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">^ = anything other than <o:p></o:p></span></p> </td> <td style="padding: 3pt;"> <p><a name="1008342"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">- = a range <o:p></o:p></span></p> </td> </tr> </tbody></table> <h3 style="margin: 0in 0in 0.0001pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; display: none;"><o:p> </o:p></span></h3> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> </td> </tr> </tbody></table> <h3><a name="8764"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Notes<o:p></o:p></span></h3> <p><a name="1004319"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Some action elements have attributes whose value can be computed at request time. In JSP syntax, the format of such a value is the same as a JSP expression: <%= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %>. In XML syntax, the format of the value is %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %. When using the JSP expression language (EL), the format of the value in either syntax is ${ <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> }. <o:p></o:p></span></p> <p><a name="1004321"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">EL expressions can be quoted by adding a backslash to the front of the expression when the expression language is enabled. This prevents the expression from being evaluated. Example: <code><span style="font-family: "Tahoma","sans-serif";">\${x+y}</span></code> will display as <code><span style="font-family: "Tahoma","sans-serif";">${x+y}</span></code>. <o:p></o:p></span></p> <p><a name="1004323"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">All elements in XML syntax can contain an xmlns attribute that complies with the XML namespaces spec. This attribute is used to declare tag libraries and other namespaces. Within the start tag of an element, its syntax is <code><span style="font-family: "Tahoma","sans-serif";">[xmlns:taglibprefix="URI"]+</span></code>. <o:p></o:p></span></p> <p><a name="1004325"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">All JSP standard actions and custom actions can contain a jsp:attribute standard element as a substitute for any of its attributes. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> syntax is <code><span style="font-family: "Tahoma","sans-serif";"><jsp:attribute name=""></code><em><span style="font-family: "Tahoma","sans-serif";">attributeName</span></em><code><span style="font-family: "Tahoma","sans-serif";">" [ trim="</span></code>true<code><span style="font-family: "Tahoma","sans-serif";"> | false" ] /></span></code> <o:p></o:p></span></p> <p><a name="1004326"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If an action contains any jsp:attribute elements and the action also has a body, it must use the <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> tag to represent the body. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> syntax is <code><span style="font-family: "Tahoma","sans-serif";"><jsp:body> </span></code><em><span style="font-family: "Tahoma","sans-serif";">any elements or text</span></em><code><span style="font-family: "Tahoma","sans-serif";"> </jsp:body></span></code> <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Comment<o:p></o:p></span></h2> <p><a name="8769"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Documents the JSP page but is not inserted into the response. <o:p></o:p></span></p> <h4><a name="8910"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><%--</span></code><span style="font-family: "Tahoma","sans-serif";"> <em><span style="font-family: "Tahoma","sans-serif";">comment</span></em> <code><span style="font-family: "Tahoma","sans-serif";">--%><o:p></o:p></span></code></span></pre> <h4><a name="997748"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <p><a name="997752"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!-- <em><span style="font-family: "Tahoma","sans-serif";">comment</span></em> <code><span style="font-family: "Tahoma","sans-serif";">--></span></code> <o:p></o:p></span></p> <h4><a name="8919"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Example<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ page language="java" %><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><head><title>A Comment Test</title></head><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><body><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><h2>A Test of Comments</h2><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%-- This comment will not be included in the response --%><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></body><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></html><o:p></o:p></span></pre> <h4><a name="16572"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="8918"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A comment marks text or lines that the JSP container should ignore. A comment is useful when you want to comment out part of your JSP page. The JSP container does not process anything within the <code><span style="font-family: "Tahoma","sans-serif";"><%--</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">--%></span></code> characters or within the <code><span style="font-family: "Tahoma","sans-serif";"><!--</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">--></span></code> characters. A comment is not inserted into the response. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Declaration<o:p></o:p></span></h2> <p><a name="10984"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Declares a variable or method valid in the scripting language used in the JSP page. <o:p></o:p></span></p> <h4><a name="10985"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%! declaration; [ declaration; ]+ ... %><o:p></o:p></span></pre> <p><a name="1011107"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:declaration><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <i>code fragment</i> [ declaration; ]+ ...<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:declaration<o:p></o:p></span></pre> <h4><a name="997753"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:declaration><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <i>code fragment</i> [ declaration; ]+ ...<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:declaration<o:p></o:p></span></pre> <h4><a name="10987"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%! int i = 0; %><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%! int a, b, c; %><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%! Circle a = new Circle(2.0); %><o:p></o:p></span></pre> <h4><a name="10989"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="16594"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A declaration declares one or more variables or methods that you can use in Java<!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:formulas> <v:path extrusionok="f" gradientshapeok="t" connecttype="rect"> <o:lock ext="edit" aspectratio="t"> </v:shapetype><v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style="'width:12pt;"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif" href="http://java.sun.com/products/jsp/syntax/2.0/images/tm.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image001.gif" shapes="_x0000_i1027" border="0" width="16" height="16" /><!--[endif]--> code later in the JSP page. You must declare the variable or method <em><span style="font-family: "Tahoma","sans-serif";">before</span></em> you use it in the JSP page. <o:p></o:p></span></p> <p><a name="15971"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can declare any number of variables or methods within one declaration element, as long as you end each declaration with a semicolon. The declaration must be valid in the Java programming language. <o:p></o:p></span></p> <p><a name="18761"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">When you write a declaration in a JSP page, remember these rules: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="16640"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You must end the declaration with a semicolon (the same rule as for a <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996">Scriptlet</a>, but the opposite of an <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref205.html#1004353">Expression</a>). <a name="16645"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can already use variables or methods that are declared in packages imported by the page directive, without declaring them in a declaration element. <o:p></o:p></span></li></ul> <p><a name="15972"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A declaration has translation unit scope, so it is valid in the JSP page and any of its static include files. A static include file becomes part of the source of the JSP page and is any file included with an include directive or a static resource included with a <code><span style="font-family: "Tahoma","sans-serif";"><jsp:include></span></code> element. The scope of a declaration does not include dynamic resources included with <code><span style="font-family: "Tahoma","sans-serif";"><jsp:include></span></code>. <o:p></o:p></span></p> <h4><a name="10991"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="10992"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996">Scriptlet</a> <a name="10993"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref205.html#1004353">Expression</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Expression<o:p></o:p></span></h2> <p><a name="11259"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Contains an expression valid in the scripting language used in the JSP page. <o:p></o:p></span></p> <h4><a name="11260"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><%= </span></code><i><span style="font-family: "Tahoma","sans-serif";">expression</span></i><code><span style="font-family: "Tahoma","sans-serif";"> %><o:p></o:p></span></code></pre> <p><a name="1011142"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:expression><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <i>expression</i><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:expression><o:p></o:p></span></pre> <h4><a name="997948"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:expression><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <i>expression</i><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:expression><o:p></o:p></span></pre> <h4><a name="11262"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";">The map file has <span style="color:blue;"><%= map.size() %></span> entries.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Good guess, but nope. Try <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><b><jsp:expression>numguess.getHint()</jsp:expression></b>.<o:p></o:p></span></pre> <h4><a name="11264"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="15961"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">An expression element contains a scripting language expression that is evaluated, converted to a <code><span style="font-family: "Tahoma","sans-serif";">String</span></code>, and inserted into the response where the expression appears in the JSP page. Because the value of an expression is converted to a <code><span style="font-family: "Tahoma","sans-serif";">String</span></code>, you can use an expression within a line of text, whether or not it is tagged with HTML, in a JSP page. <o:p></o:p></span></p> <p><a name="16344"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The expression element can contain any expression that is a valid page scripting language. When the Java programming language is the scripting language you do not use a semicolon to end the expression. However, the same expression within a scriptlet requires the semicolon; see <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996">Scriptlet</a>). <o:p></o:p></span></p> <p><a name="11281"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can sometimes use expressions as attribute values in JSP elements (see the <a href="http://java.sun.com/products/jsp/syntax/2.0/card20.pdf">JavaServer Pages<span style="text-decoration: none;"><!--[if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" alt="" style="'width:12pt;height:12pt'" button="t"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.gif" href="http://java.sun.com/products/jsp/syntax/2.0/images/tm.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image001.gif" shapes="_x0000_i1029" border="0" width="16" height="16" /><!--[endif]--></span> Syntax Card</a>). An expression can be complex and composed of more than one part or expression. The parts of an expression are evaluated in left-to-right order. <o:p></o:p></span></p> <h4><a name="11268"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="11272"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref204.html#10983">Declaration</a> <a name="11276"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996">Scriptlet</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Scriptlet<o:p></o:p></span></h2> <p><a name="10997"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Contains a code fragment valid in the page scripting language. <o:p></o:p></span></p> <h4><a name="10998"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><% </span></code><i><span style="font-family: "Tahoma","sans-serif";">code fragment</span></i><code><span style="font-family: "Tahoma","sans-serif";"> %><o:p></o:p></span></code></pre> <p><a name="1011157"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:scriptlet><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <i>code fragment</i><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:scriptlet><o:p></o:p></span></pre> <h4><a name="997969"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:scriptlet><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <i>code fragment</i><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:scriptlet><o:p></o:p></span></pre> <h4><a name="16389"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> String name = null;<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> if (request.getParameter("name") == null) {<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">%><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ include file="error.html" %><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> } else {<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> foo.setName(request.getParameter("name"));<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> if (foo.getName().equalsIgnoreCase("integra"))<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> name = "acura";<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> if (name.equalsIgnoreCase( "acura" )) {<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">%><o:p></o:p></span></pre> <h4><a name="11059"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="15996"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A scriptlet can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language. <o:p></o:p></span></p> <p><a name="16710"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Within a scriptlet, you can do any of the following: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="16712"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Declare variables or methods to use later in the JSP page (see also <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref204.html#10983">Declaration</a>). <a name="16717"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Write expressions valid in the page scripting language (see also <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref205.html#1004353">Expression</a>). <a name="16721"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Use any of the implicit objects or any object declared with a <code><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean></span></code> element. <a name="16722"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Write any other statement valid in the scripting language used in the JSP page. <o:p></o:p></span></li></ul> <p><a name="16711"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Any text, HTML tags, or JSP elements you write must be <em><span style="font-family: "Tahoma","sans-serif";">outside</span></em> the scriptlet. <o:p></o:p></span></p> <p><a name="11056"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Scriptlets are executed at request time, when the JSP container processes the request. If the scriptlet produces output, the output is stored in the <code><span style="font-family: "Tahoma","sans-serif";">out</span></code> object. <o:p></o:p></span></p> <h4><a name="11007"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="11011"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref204.html#10983">Declaration</a> <a name="1003275"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref205.html#1004353">Expression</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">EL Expression<o:p></o:p></span></h2> <p><a name="1010523"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Contains an expression in the JSP Expression Language (EL). It allows easy access to application data stored in JavaBeans components. <o:p></o:p></span></p> <h4><a name="1010524"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Syntax (JSP and XML)<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";">${Expression}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Expression = {(ChoiceExpression | (Expression BinaryOp Expression)<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> (UnaryOp Expression) | Value }<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">ChoiceExpression = Expression ? Expression : Expression<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">BinaryOp (JSP syntax) = and | && | or | || | '+' | '-' | * | / | did <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> | % | mod | > | gt | < | lt | >= | ge | <= |<span style=""> </span><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> le | == | eq | != | ne<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">BinaryOp (XML syntax) = and | && | or | || | '+' | '-' | * | / | div <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> | % | mod | gt |<span style=""> </span>lt | ge |<span style=""> </span>le | == | eq | ne<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">UnaryOp = {'-' | ! | not | empty }<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Value = {ValuePrefix | (Value ValueSuffix) }<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">ValuePrefix = {Literal | '('Expression')' | ImplicitObject | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> Java language identifier | FuncInvocation }<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">ValueSuffix = { . Identifier | '['Expression']'}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">FuncInvocation = [Identifier :]Identifier '('[Expression [',' <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> Expression]+ ]')'<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Literal = {true|false} | (0-9)+ | FloatingPtLiteral | StringLiteral <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> | null<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">FloatingPtLiteral = [0-9]+ . (0-9)+ [Exponent] | (0-9)+ [Exponent]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Exponent = {e | E} ['+' | -] (0-9)+<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">StringLiteral = {'[^(' | \) | \' | \\]+' | "[^(" | \) | \" | \\]+"}<o:p></o:p></span></pre> <h4><a name="1010539"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1010540"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following three examples show tag attributes using EL expressions to access values stored in JavaBeans components. <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010548">TABLE 1</a> shows how some example EL expressions evaluate. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><a:tag value="${x+y}"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><a:tag value="${first} ${last}"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><a:tag>${x+y}</a:tag><o:p></o:p></span></pre><pre style="text-align: center;"><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre> <div align="center"> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td colspan="2" style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><a name="1010548"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Expression language examples<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">TABLE 1 </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p style="text-align: center;" align="center"><a name="1010552"></a><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">EL Expression <o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p style="text-align: center;" align="center"><a name="1010554"></a><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Result <o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010556"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${1 > (4/2)}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010558"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010560"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${4.0 >= 3}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010562"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010564"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${100.0 == 100}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010566"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010568"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${(10*10) ne 100}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010570"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010572"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${'a' < 'b'}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010574"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010576"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${'hip' gt 'hit'}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010578"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010580"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${4 > 3}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010582"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010584"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${1.2E4 + 1.4}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010586"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">12001.4 <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010588"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${3 div 4}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010590"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">0.75 <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010592"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${10 mod 4}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010594"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">2 <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010596"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${!empty param.Add}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010598"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">True if the request parameter named <code><span style="font-family: "Tahoma","sans-serif";">Add</span></code> is null or an empty string <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010600"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${pageContext.request.contextPath}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010602"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The context path <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010604"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${sessionScope.cart.numberOfItems}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010606"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of the <code><span style="font-family: "Tahoma","sans-serif";">numberOfItems</span></code> property of the session-scoped attribute named <code><span style="font-family: "Tahoma","sans-serif";">cart</span></code> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010608"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${param['mycom.productId']}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010610"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of the request parameter named <code><span style="font-family: "Tahoma","sans-serif";">mycom.productId</span></code> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010612"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${header["host"]}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010614"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The host <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010616"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${departments[deptName]}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010618"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of the entry named <code><span style="font-family: "Tahoma","sans-serif";">deptName</span></code> in the <code><span style="font-family: "Tahoma","sans-serif";">departments</span></code> map <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="1010620"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">${requestScope['javax.servlet.forward.servlet_path']}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="1010622"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of the request-scoped attribute named <code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.forwardservlet_path</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> </div> <pre style="text-align: center;"><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre style="text-align: center;"><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre> <div align="center"> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> </td> </tr> </tbody></table> </div> <pre style="text-align: center;"><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre> <h4><a name="1010623"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1010624"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A primary feature of JSP technology version 2.0 is its support for an expression language (EL). An expression language makes it possible to easily access application data stored in JavaBeans components. For example, the JSP expression language allows a page author to access a bean using simple syntax such as <code><span style="font-family: "Tahoma","sans-serif";">${name}</span></code> for a simple variable or <code><span style="font-family: "Tahoma","sans-serif";">${name.foo.bar}</span></code> for a nested property. <o:p></o:p></span></p> <p><a name="1010625"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">test</span></code> attribute of the following conditional tag is supplied with an EL expression that compares the number of items in the session-scoped bean named <code><span style="font-family: "Tahoma","sans-serif";">cart</span></code> with 0: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><c:if test=""> 0}"> <o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></c:if> <o:p></o:p></span></pre> <p><a name="1010629"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP expression evaluator is responsible for handling EL expressions, which are enclosed by the <code><span style="font-family: "Tahoma","sans-serif";">${ }</span></code> characters and can include literals. Here's an example: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><c:if test="${bean1.a < 3}"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></c:if> <o:p></o:p></span></pre> <p><a name="1010633"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Any value that does not begin with <code><span style="font-family: "Tahoma","sans-serif";">${</span></code> is treated as a literal and is parsed to the expected type using the <code><span style="font-family: "Tahoma","sans-serif";">PropertyEditor</span></code> for the type: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><c:if test="true"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></c:if> <o:p></o:p></span></pre> <p><a name="1010637"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Literal values that contain the <code><span style="font-family: "Tahoma","sans-serif";">${</span></code> characters must be escaped as follows: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><mytags:example attr1="an expression is ${'${'}true}"> <o:p></o:p></span></pre> <p><a name="1010639"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">EL expressions can be used: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010640"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In static text <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010641"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In any standard or custom tag attribute that can accept an expression<o:p></o:p></span></li></ul> <p><a name="1010642"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of an expression in static text is computed and inserted into the current output. If the static text appears in a tag body, note that an expression will not be evaluated if the body is declared to be tagdependent. <o:p></o:p></span></p> <p><a name="1010643"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">There are three ways to set a tag attribute value: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010644"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">With a single expression construct: <code><span style="font-family: "Tahoma","sans-serif";"><some:tag value="${expr}"> </span></code>The expression is evaluated and the result is coerced to the attribute's expected type. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010645"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">With one or more expressions separated or surrounded by text: <code><span style="font-family: "Tahoma","sans-serif";"><some:tag value="some${expr}${expr}text${expr}"> </span></code>The expressions are evaluated from left to right. Each expression is coerced to a String and then concatenated with any intervening text. The resulting String is then coerced to the attribute's expected type.<a name="1010646"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">With text only: <code><span style="font-family: "Tahoma","sans-serif";"><some:tag value="sometext"> </span></code>In this case, the attribute's String value is coerced to the attribute's expected type.<o:p></o:p></span></li></ul> <p><a name="1010647"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Expressions used to set attribute values are evaluated in the context of an expected type. If the result of the expression evaluation does not match the expected type exactly, a type conversion will be performed. For example, the expression <code><span style="font-family: "Tahoma","sans-serif";">${1.2E4}</span></code> provided as the value of an attribute of type float will result in the following conversion: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";">Float.valueOf("1.2E4").floatValue() <o:p></o:p></span></pre> <p><a name="1010649"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See section JSP2.8 of the JSP 2.0 specification for the complete type conversion rules. <o:p></o:p></span></p> <h5><a name="1010650"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Variables<o:p></o:p></span></h5> <p><a name="1010651"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Web container evaluates a variable that appears in an expression by looking up its value according to the behavior of <code><span style="font-family: "Tahoma","sans-serif";">PageContext.findAttribute(String)</span></code>. For example, when evaluating the expression <code><span style="font-family: "Tahoma","sans-serif";">${product}</span></code>, the container will look for <code><span style="font-family: "Tahoma","sans-serif";">product</span></code> in the page, request, session, and application scopes and will return its value. If <code><span style="font-family: "Tahoma","sans-serif";">product</span></code> is not found, null is returned. A variable that matches one of the implicit objects described in <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010662">Implicit Objects</a> will return that implicit object instead of the variable's value. <o:p></o:p></span></p> <p><a name="1010655"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Properties of variables are accessed using the . operator and can be nested arbitrarily. <o:p></o:p></span></p> <p><a name="1013047"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP expression language unifies the treatment of the <code><span style="font-family: "Tahoma","sans-serif";">.</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">[]</span></code> operators. <code><span style="font-family: "Tahoma","sans-serif";">expr-a.identifier-b</span></code> is equivalent to <code><span style="font-family: "Tahoma","sans-serif";">expr-a["identifier-b"]</span></code>; that is, the identifier <code><span style="font-family: "Tahoma","sans-serif";">identifier-b</span></code> is used to construct a literal whose value is the identifier, and then the <code><span style="font-family: "Tahoma","sans-serif";">[]</span></code>operator is used with that value. <o:p></o:p></span></p> <p><a name="1010657"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To evaluate <code><span style="font-family: "Tahoma","sans-serif";">expr-a[expr-b]</span></code>, evaluate <code><span style="font-family: "Tahoma","sans-serif";">expr-a</span></code> into <code><span style="font-family: "Tahoma","sans-serif";">value-a</span></code> and evaluate <code><span style="font-family: "Tahoma","sans-serif";">expr-b</span></code> into <code><span style="font-family: "Tahoma","sans-serif";">value-b</span></code>. If either <code><span style="font-family: "Tahoma","sans-serif";">value-a</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">value-b</span></code> is null, return <code><span style="font-family: "Tahoma","sans-serif";">null</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010658"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If <code><span style="font-family: "Tahoma","sans-serif";">value-a</span></code> is a <code><span style="font-family: "Tahoma","sans-serif";">Map</span></code>, return <code><span style="font-family: "Tahoma","sans-serif";">value-a.get(value-b)</span></code>. If <code><span style="font-family: "Tahoma","sans-serif";">!value-a.containsKey(value-b)</span></code>, then return <code><span style="font-family: "Tahoma","sans-serif";">null</span></code>. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010659"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If <code><span style="font-family: "Tahoma","sans-serif";">value-a</span></code> is a <code><span style="font-family: "Tahoma","sans-serif";">List</span></code> or array, coerce <code><span style="font-family: "Tahoma","sans-serif";">value-b</span></code> to <code><span style="font-family: "Tahoma","sans-serif";">int</span></code> and return <code><span style="font-family: "Tahoma","sans-serif";">value-a.get(value-b)</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">Array.get(value-a, value-b)</span></code>, as appropriate. If the coercion couldn't be performed, an error is returned. If the call returns an <code><span style="font-family: "Tahoma","sans-serif";">IndexOutOfBoundsException</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">null</span></code> is returned. If the call returns another exception, an error is returned.<a name="1010660"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If <code><span style="font-family: "Tahoma","sans-serif";">value-a</span></code> is a JavaBeans object, coerce <code><span style="font-family: "Tahoma","sans-serif";">value-b</span></code> to <code><span style="font-family: "Tahoma","sans-serif";">String</span></code>. If <code><span style="font-family: "Tahoma","sans-serif";">value-b</span></code> is a readable property of <code><span style="font-family: "Tahoma","sans-serif";">value-a</span></code>, then return the result of a <code><span style="font-family: "Tahoma","sans-serif";">get</span></code> call. If the <code><span style="font-family: "Tahoma","sans-serif";">get</span></code> method throws an exception, an error is returned.<o:p></o:p></span></li></ul> <h5><a name="1010662"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Implicit Objects<o:p></o:p></span></h5> <p><a name="1010663"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP expression language defines a set of implicit objects: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010664"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">pageContext</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: The context for the JSP page. Provides access to various objects including: <o:p></o:p></span></li><ul type="circle"><li class="MsoNormal" style=""><a name="1010665"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">servletContext</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: The context for the JSP page's servlet and any Web components contained in the same application. <a name="1010666"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">session</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: The session object for the client. <a name="1010667"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">request</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: The request triggering the execution of the JSP page. <a name="1010668"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">response</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: The response returned by the JSP page. <o:p></o:p></span></li></ul></ul> <p><a name="1010669"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In addition, several implicit objects are available that allow easy access to the following objects: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010670"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">param</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps a request parameter name to a single value <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010671"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">paramValues</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps a request parameter name to an array of values<a name="1010672"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">header</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps a request header name to a single value<a name="1010673"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">headerValues</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps a request header name to an array of values<a name="1010674"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">cookie</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps a cookie name to a single cookie<a name="1010675"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">initParam</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps a context initialization parameter name to a single value<o:p></o:p></span></li></ul> <p><a name="1010676"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Finally, there are objects that allow access to the various scoped variables. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010677"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">pageScope</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps page-scoped variable names to their values <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010678"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">requestScope</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps request-scoped variable names to their values<a name="1010679"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">sessionScope</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps session-scoped variable names to their values<a name="1010680"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">applicationScope</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Maps application-scoped variable names to their values<o:p></o:p></span></li></ul> <p><a name="1010681"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">When an expression references one of these objects by name, the appropriate object is returned instead of the corresponding attribute. For example, <code><span style="font-family: "Tahoma","sans-serif";">${pageContext}</span></code> returns the <code><span style="font-family: "Tahoma","sans-serif";">PageContext</span></code> object, even if there is an existing <code><span style="font-family: "Tahoma","sans-serif";">pageContext</span></code> attribute containing some other value. <o:p></o:p></span></p> <h5><a name="1010682"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Literals<o:p></o:p></span></h5> <p><a name="1010683"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP expression language defines the following literals: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010684"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Boolean: <code><span style="font-family: "Tahoma","sans-serif";">true</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">false</span></code> <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010685"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Integer: as in the Java programming language<a name="1010686"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Floating point: as in the Java programming language<a name="1010687"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">String: with single and double quotes; " is escaped as \", ' is escaped as \', and \ is escaped as \\.<a name="1010688"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Null: <code><span style="font-family: "Tahoma","sans-serif";">null</span></code><o:p></o:p></span></li></ul> <h5><a name="1010689"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Operators<o:p></o:p></span></h5> <p><a name="1010690"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In addition to the <code><span style="font-family: "Tahoma","sans-serif";">.</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">[]</span></code> operators discussed in Variables, the JSP expression language provides the following operators: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010691"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Arithmetic: <code><span style="font-family: "Tahoma","sans-serif";">-</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">-</span></code> (binary), <code><span style="font-family: "Tahoma","sans-serif";">*</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">/</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">div</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">%</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">mod</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">-</span></code> (unary) <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010692"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Logical: <code><span style="font-family: "Tahoma","sans-serif";">and</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">&&</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">or</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">||,</span></code> <code><span style="font-family: "Tahoma","sans-serif";">not</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">!</span></code><a name="1010693"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Relational: <code><span style="font-family: "Tahoma","sans-serif";">==</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">eq</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">!=</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">ne</span></code>, <code><span style="font-family: "Tahoma","sans-serif";"><</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">lt</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">></span></code>, <code><span style="font-family: "Tahoma","sans-serif";">gt</span></code>, <code><span style="font-family: "Tahoma","sans-serif";"><=</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">ge</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">>=</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">le</span></code>. Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.<a name="1010694"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Empty: The <code><span style="font-family: "Tahoma","sans-serif";">empty</span></code> operator is a prefix operation that can be used to determine whether a value is <code><span style="font-family: "Tahoma","sans-serif";">null</span></code> or empty.<a name="1010695"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Conditional: <code><span style="font-family: "Tahoma","sans-serif";">A ? B : C</span></code>. Evaluate <code><span style="font-family: "Tahoma","sans-serif";">B</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">C</span></code>, depending on the result of the evaluation of <code><span style="font-family: "Tahoma","sans-serif";">A</span></code>.<o:p></o:p></span></li></ul> <p><a name="1010696"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The precedence of operators highest to lowest, left to right is as follows: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1010697"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">[]</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">.</span></code> <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1010698"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">()</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> - Used to change the precedence of operators.<a name="1010699"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">-</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> (unary) <code><span style="font-family: "Tahoma","sans-serif";">not</span></code> <code><span style="font-family: "Tahoma","sans-serif";">!</span></code> <code><span style="font-family: "Tahoma","sans-serif";">empty</span></code><a name="1010700"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">*</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">/</span></code> <code><span style="font-family: "Tahoma","sans-serif";">div</span></code> <code><span style="font-family: "Tahoma","sans-serif";">%</span></code> <code><span style="font-family: "Tahoma","sans-serif";">mod</span></code><a name="1010701"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">+</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">-</span></code> (binary)<a name="1010702"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">></span></code> <code><span style="font-family: "Tahoma","sans-serif";"><=</span></code> <code><span style="font-family: "Tahoma","sans-serif";">>=</span></code> <code><span style="font-family: "Tahoma","sans-serif";">lt</span></code> <code><span style="font-family: "Tahoma","sans-serif";">gt</span></code> <code><span style="font-family: "Tahoma","sans-serif";">le</span></code> <code><span style="font-family: "Tahoma","sans-serif";">ge</span></code><a name="1010703"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">==</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">!=</span></code> <code><span style="font-family: "Tahoma","sans-serif";">eq</span></code> <code><span style="font-family: "Tahoma","sans-serif";">ne</span></code><a name="1010704"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">&&</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">and</span></code><a name="1010705"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">||</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">or</span></code><a name="1010706"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">?</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">:</span></code><o:p></o:p></span></li></ul> <h5><a name="1010707"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Reserved Words<o:p></o:p></span></h5> <p><a name="1010708"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following words are reserved for the JSP expression language and should not be used as identifiers. <o:p></o:p></span></p> <p><a name="1010709"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">and</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">eq</span></code> <code><span style="font-family: "Tahoma","sans-serif";">gt</span></code> <code><span style="font-family: "Tahoma","sans-serif";">true</span></code> <code><span style="font-family: "Tahoma","sans-serif";">instanceof</span></code> <o:p></o:p></span></p> <p><a name="1010710"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">or</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">ne</span></code> <code><span style="font-family: "Tahoma","sans-serif";">le</span></code> <code><span style="font-family: "Tahoma","sans-serif";">false</span></code> <code><span style="font-family: "Tahoma","sans-serif";">empty</span></code> <o:p></o:p></span></p> <p><a name="1010711"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">not</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">lt</span></code> <code><span style="font-family: "Tahoma","sans-serif";">ge</span></code> <code><span style="font-family: "Tahoma","sans-serif";">null</span></code> <code><span style="font-family: "Tahoma","sans-serif";">div</span></code> <code><span style="font-family: "Tahoma","sans-serif";">mod</span></code> <o:p></o:p></span></p> <p><a name="1010712"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Note that many of these words are not in the language now, but they may be in the future, so you should avoid using them. <o:p></o:p></span></p> <h5><a name="1010713"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Functions<o:p></o:p></span></h5> <p><a name="1010714"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP expression language allows you to define a function that can be invoked in an expression. Functions are defined using the same mechanisms as custom tags. <o:p></o:p></span></p> <p><a name="1010715"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Functions can appear in static text and tag attribute values. <o:p></o:p></span></p> <p><a name="1010716"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To use a function in a JSP page, you use a <code><span style="font-family: "Tahoma","sans-serif";">taglib</span></code> directive to import the tag library containing the function. Then you preface the function invocation with the prefix declared in the directive. <o:p></o:p></span></p> <p><a name="1010717"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">For example, the following example page imports the /functions library and invokes the function <code><span style="font-family: "Tahoma","sans-serif";">equals</span></code> in an expression: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ taglib prefix="f" uri="/functions"%><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><c:when<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>test="${f:equals(selectedLocaleString,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>localeString)}" > <o:p></o:p></span></pre> <p><a name="1010723"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To define a function you program it as a public static method in a public class. The <code><span style="font-family: "Tahoma","sans-serif";">mypkg.MyLocales</span></code> class example below defines a function that tests the equality of two Strings as follows: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";">package mypkg;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">public class MyLocales {<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>public static boolean equals( String l1, String l2 ) {<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>return l1.equals(l2);<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">} <o:p></o:p></span></pre> <p><a name="1010731"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Then you map the function name as used in the EL expression to the defining class and function signature in a TLD. The following <code><span style="font-family: "Tahoma","sans-serif";">functions.tld</span></code> file maps the equals function to the class containing the implementation of the function equals and the signature of the function: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><function><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><name>equals</name><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><function-class>mypkg.MyLocales</function-class><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><function-signature>boolean equals( java.lang.String,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>java.lang.String )</function-signature><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></function> <o:p></o:p></span></pre> <p><a name="1010738"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A tag library can have only one function element that has any given name element. <o:p></o:p></span></p> <h4><a name="1010739"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1010743"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref204.html#10983">Declaration</a> <a name="1010747"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996">Scriptlet</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attribute Directive<o:p></o:p></span></h2> <p><a name="1006884"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Declares attributes of custom actions defined in tag files. Used in tag files only. <o:p></o:p></span></p> <h4><a name="1003535"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ attribute<span style=""> </span>name="<i>attribute-name</i>"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ required="true | <strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ fragment="true | <strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ rtexprvalue="<strong><span style="font-family: "Tahoma","sans-serif";">true</span></strong> | false" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ type="java.lang.String | <i>a non-primitive type</i>"]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ description="<i>text</i>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">%><o:p></o:p></span></pre> <p><a name="1011171"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.attribute><o:p></o:p></span></pre> <p><a name="1011176"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">where <em><span style="font-family: "Tahoma","sans-serif";">attributeDirectiveAttrList</span></em> is the same as the list for JSP syntax <o:p></o:p></span></p> <h4><a name="1003537"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.attribute><o:p></o:p></span></pre> <p><a name="1004228"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">where <em><span style="font-family: "Tahoma","sans-serif";">attributeDirectiveAttrList</span></em> is the same as the list for JSP syntax <o:p></o:p></span></p> <h4><a name="1003539"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1003540"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Duke's Bookstore example includes a custom tag, called <code><span style="font-family: "Tahoma","sans-serif";">shipDate</span></code>, that is defined in a tag file, <code><span style="font-family: "Tahoma","sans-serif";">shipDate.tag</span></code>. The tag file includes an attribute directive that declares the <code><span style="font-family: "Tahoma","sans-serif";">shipDate</span></code> tag's attribute, shipping: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ attribute name="shipping" required="true" %><o:p></o:p></span></pre> <p><a name="1004255"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here is an example of the <code><span style="font-family: "Tahoma","sans-serif";">shipDate</span></code> tag used in the <code><span style="font-family: "Tahoma","sans-serif";">bookreceipt.jsp</span></code> page: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><sc:shipdate shipping="${param.shipping}"> <o:p></o:p></span></pre> <h4><a name="1003541"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1003542"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">attribute</span></code> directive allows the declaration of attributes for custom tags in tag files. This is analogous to the attribute element of a TLD file. <o:p></o:p></span></p> <h4><a name="1003543"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1004648"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name = "</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">attribute-name</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005420"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The unique name of the attribute being declared. A translation error results if more than one <code><span style="font-family: "Tahoma","sans-serif";">attribute</span></code> directive appears in the same translation unit with the same name. A translation error results if there is an <code><span style="font-family: "Tahoma","sans-serif";">attribute</span></code> directive with a <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute equal to the value of the <code><span style="font-family: "Tahoma","sans-serif";">name-given</span></code> attribute of a <code><span style="font-family: "Tahoma","sans-serif";">variable</span></code> directive or the <code><span style="font-family: "Tahoma","sans-serif";">dynamic-attributes</span></code> attribute of a <code><span style="font-family: "Tahoma","sans-serif";">tag</span></code> directive in this translation unit. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1004655"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">required="true | </span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005453"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether this attribute is required (true) or optional (false). Defaults to false if not specified. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1004657"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">fragment="true | </span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005476"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether this attribute is a fragment to be evaluated by the tag handler (<code><span style="font-family: "Tahoma","sans-serif";">true</span></code>) or a normal attribute to be evaluated by the container prior to being passed to the tag handler. If this attribute is <code><span style="font-family: "Tahoma","sans-serif";">true</span></code>: <o:p></o:p></span></p> <ul type="disc"><ul type="circle"><li class="MsoNormal" style=""><a name="1005477"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You do not specify the <code><span style="font-family: "Tahoma","sans-serif";">rtexprvalue</span></code> attribute. The container fixes the <code><span style="font-family: "Tahoma","sans-serif";">rtexprvalue</span></code> attribute at <code><span style="font-family: "Tahoma","sans-serif";">true</span></code>. <a name="1005468"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You do not specify the <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> attribute. The container fixes the <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> attribute at <code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.jsp.tagext.JspFragment</span></code>. <o:p></o:p></span></li></ul></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1005482"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defaults to <code><span style="font-family: "Tahoma","sans-serif";">false</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1004666"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">rtexprvalue="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | false"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005516"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether the attribute's value may be dynamically calculated at runtime by a scriptlet expression. Unlike the corresponding TLD element, this attribute defaults to true. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1004669"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">type="java.lang.String | </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">a non-primitive type</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005520"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The runtime type of the attribute's value. Defaults to <code><span style="font-family: "Tahoma","sans-serif";">java.lang.String</span></code> if not specified. It is a translation error to specify a primitive type. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1004672"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">description="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">text</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005524"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description of the attribute. Defaults to no description. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Include Directive<o:p></o:p></span></h2> <p><a name="8777"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Includes a static file in a JSP page, parsing the file's JSP elements. <o:p></o:p></span></p> <h4><a name="8778"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><%@ include file="</span></code><em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-family: "Tahoma","sans-serif";">" %><o:p></o:p></span></code></pre> <p><a name="1011186"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.include file=""><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em>" /><o:p></o:p></span></pre> <h4><a name="998075"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.include file=""><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em>" /><o:p></o:p></span></pre> <h4><a name="16745"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";">include.jsp:<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><head><title>An Include Test</title></head><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><body bgcolor="white"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style="color:blue;"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">The current date and time are<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ include file="date.jsp" %><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></span><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></body><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></html><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">date.jsp:<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ page import="java.util.*" %><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%= (new java.util.Date() ).toLocaleString() %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Displays in the page:<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">The current date and time are<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Aug 30, 1999 2:38:40<o:p></o:p></span></pre> <h4><a name="16747"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="10550"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">An include directive inserts a file of text or code in a JSP page at translation time, when the JSP page is compiled. When you use the include directive, the include process is <em><span style="font-family: "Tahoma","sans-serif";">static</span></em>. A static include means that the text of the included file is added to the JSP page. The included file can be a JSP page, HTML file, XML document, or text file. If the included file is a JSP page, its JSP elements are translated and included (along with any other text) in the JSP page. Once the included file is translated and included, the translation process resumes with the next line of the including JSP page. <o:p></o:p></span></p> <p><a name="16847"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The included file can be an HTML file, a JSP page, a text file, XML document, or a code file written in the Java programming language. Be careful that the included file does not contain <code><span style="font-family: "Tahoma","sans-serif";"><html></span></code>, <code><span style="font-family: "Tahoma","sans-serif";"></html></span></code>, <code><span style="font-family: "Tahoma","sans-serif";"><body></span></code>, or <code><span style="font-family: "Tahoma","sans-serif";"></body></span></code> tags. Because the entire content of the included file is added to the including JSP page, these tags would conflict with the same tags in the including JSP page, causing an error. <o:p></o:p></span></p> <p><a name="10671"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Some of the behaviors of the include directive depend on the particular JSP container you are using, for example: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="16820"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The included file might be open and available to all requests, or it might have security restrictions. <a name="16822"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP page might be recompiled if the included file changes. <o:p></o:p></span></li></ul> <h4><a name="10538"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="16836"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">file="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="16113"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The pathname to the included file, which is always a relative URL. A relative URL is just the path segment of an URL, without a protocol, port, or domain name, like this: <o:p></o:p></span></p> <pre style="margin-left: 0.5in;"><span style="font-family: "Tahoma","sans-serif";">"error.jsp"<span style=""> </span><o:p></o:p></span></pre><pre style="margin-left: 0.5in;"><span style="font-family: "Tahoma","sans-serif";">"/templates/onlinestore.html"<span style=""> </span><o:p></o:p></span></pre><pre style="margin-left: 0.5in;"><span style="font-family: "Tahoma","sans-serif";">"/beans/calendar.jsp"<o:p></o:p></span></pre> <p style="margin-left: 0.5in;"><a name="10584"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the relative URL starts with <code><span style="font-family: "Tahoma","sans-serif";">/</span></code>, the path is relative to the JSP application's context, which is a <code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.ServletContext</span></code> object that is in turn stored in the <code><span style="font-family: "Tahoma","sans-serif";">application</span></code> object. If the relative URL starts with a directory or file name, the path is relative to the JSP page. <o:p></o:p></span></p> <h4><a name="10636"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tip<o:p></o:p></span></h4> <p><a name="10637"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If you are including a text file and do not want the text to be displayed in the JSP page, place the text in a comment element. <o:p></o:p></span></p> <h4><a name="8975"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="8979"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2020.html#8828"><jsp:include></a> <a name="8999"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2018.html#1003349"><jsp:forward></a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Page Directive<o:p></o:p></span></h2> <p><a name="15654"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines attributes that apply to an entire JSP page. <o:p></o:p></span></p> <h4><a name="15655"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><%@ page<span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> [ language="</span></code><strong><span style="font-family: "Tahoma","sans-serif";">java</span></strong><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ extends="</span></code><em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ import="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em> | <em><span style="font-family: "Tahoma","sans-serif";">package.*</span></em><code><span style="font-family: "Tahoma","sans-serif";">}, ..."</span></code> ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ session="</span></code><strong><span style="font-family: "Tahoma","sans-serif";">true</span></strong><code><span style="font-family: "Tahoma","sans-serif";">|false" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ buffer="none|</span></code><strong><span style="font-family: "Tahoma","sans-serif";">8kb</span></strong>|<em><span style="font-family: "Tahoma","sans-serif";">sizekb</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ autoFlush="</span></code><strong><span style="font-family: "Tahoma","sans-serif";">true</span></strong><code><span style="font-family: "Tahoma","sans-serif";">|false" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ isThreadSafe="</span></code><strong><span style="font-family: "Tahoma","sans-serif";">true</span></strong><code><span style="font-family: "Tahoma","sans-serif";">|false" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ info="</span></code><em><span style="font-family: "Tahoma","sans-serif";">text</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ errorPage="</span></code><em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ contentType="</span></code><em><span style="font-family: "Tahoma","sans-serif";">mimeType</span></em><code><span style="font-family: "Tahoma","sans-serif";"> [ ; charset=</span></code><em><span style="font-family: "Tahoma","sans-serif";">characterSet</span></em><code><span style="font-family: "Tahoma","sans-serif";"> ]" |<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <strong><span style="font-family: "Tahoma","sans-serif";">"text/html ; charset=ISO-8859-1"</span></strong><code><span style="font-family: "Tahoma","sans-serif";"> ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ isErrorPage="true|</span></code><strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ pageEncoding="characterSet | <strong><span style="font-family: "Tahoma","sans-serif";">ISO-8859-1</span></strong>" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ isELIgnored="true|<strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong>"]<span style=""> </span><o:p></o:p></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";">%><o:p></o:p></span></code></pre> <p><a name="1011198"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.page> <o:p></o:p></span></pre> <p><a name="1011202"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">where <em><span style="font-family: "Tahoma","sans-serif";">pageDirectiveAttrList</span></em> is the same as the list in the JSP syntax. <o:p></o:p></span></p> <h4><a name="998125"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.page> <o:p></o:p></span></pre> <p><a name="998137"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">where <em><span style="font-family: "Tahoma","sans-serif";">pageDirectiveAttrList</span></em> is the same as the list in the JSP syntax. <o:p></o:p></span></p> <h4><a name="16398"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ page import="java.util.*, java.lang.*" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ page buffer="5kb" autoFlush="false" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.page errorpage="error.jsp"><o:p></o:p></span></pre> <h4><a name="15659"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="15660"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The page directive applies to an entire JSP page and any of its <em><span style="font-family: "Tahoma","sans-serif";">static include files</span></em>, which together are called a <em><span style="font-family: "Tahoma","sans-serif";">translation unit</span></em>. A static include file is a file whose content becomes part of the calling JSP page. The page directive does not apply to any dynamic resources; see <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2020.html#8828"><jsp:include></a> for more information. <o:p></o:p></span></p> <p><a name="15661"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can use the page directive more than once in a translation unit, but you can only use each attribute, except <code><span style="font-family: "Tahoma","sans-serif";">import</span></code>, once. Because the <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> attribute is similar to the <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> statement in the Java programming language, you can use a page directive with <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> more than once in a JSP page or translation unit. <o:p></o:p></span></p> <p><a name="18646"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">No matter where you position the page directive in a JSP page or included files, it applies to the entire translation unit. However, it is often good programming style to place it at the top of the JSP page. <o:p></o:p></span></p> <h4><a name="15662"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="15663"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">language="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" <a name="15664"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The scripting language used in scriptlets, declarations, and expressions in the JSP page and any included files. In v2.0, the only allowed value is <code><span style="font-family: "Tahoma","sans-serif";">java</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15665"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">extends="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="15666"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The fully qualified name of the superclass of the Java class this JSP page will be compiled to. Use this attribute cautiously, as it can limit the JSP container's ability to provide a specialized superclass that improves the quality of the compiled class. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="16862"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">import="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.*</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">}, ..."</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="15668"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A comma-separated list of Java packages that the JSP page should import. The packages (and their classes) are available to scriptlets, expressions, and declarations within the JSP page. If you want to import more than one package, you can specify a comma-separated list after <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> or you can use <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> more than once in a JSP page. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18695"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following packages are implicitly imported, so you don't need to specify them with the <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> attribute: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18699"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.*</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1003082"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">javax.servlet.*</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1003083"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">javax.servlet.jsp.*</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1003084"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">javax.servlet.http.*</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1003085"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You must place the <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> attribute before the element that calls the imported class. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15669"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">session="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">|false" <a name="16906"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether the client must join an HTTP session in order to use the JSP page. If the value is <code><span style="font-family: "Tahoma","sans-serif";">true</span></code>, the <code><span style="font-family: "Tahoma","sans-serif";">session</span></code> object refers to the current or new session. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18502"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the value is <code><span style="font-family: "Tahoma","sans-serif";">false</span></code>, you cannot use the <code><span style="font-family: "Tahoma","sans-serif";">session</span></code> object or a <code><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean></span></code> element with <code><span style="font-family: "Tahoma","sans-serif";">scope=session</span></code> in the JSP page. Either of these usages would cause a translation-time error. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18492"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The default value is <code><span style="font-family: "Tahoma","sans-serif";">true</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15671"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">buffer="none|</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">8kb</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">|<em><span style="font-family: "Tahoma","sans-serif";">sizekb</span></em><code><span style="font-family: "Tahoma","sans-serif";">"</span></code> <a name="15672"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The buffer size in kilobytes used by the <code><span style="font-family: "Tahoma","sans-serif";">out</span></code> object to handle output sent from the compiled JSP page to the client web browser. The default value is <code><span style="font-family: "Tahoma","sans-serif";">8kb</span></code>. If you specify a buffer size, the output is buffered with at least the size you specified. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15673"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">autoFlush="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">|false" <a name="15674"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether the buffered output should be flushed automatically when the buffer is full. If set to <code><span style="font-family: "Tahoma","sans-serif";">true</span></code> (the default value), the buffer will be flushed. If set to <code><span style="font-family: "Tahoma","sans-serif";">false</span></code>, an exception will be raised when the buffer overflows. You cannot set <code><span style="font-family: "Tahoma","sans-serif";">autoFlush</span></code> to <code><span style="font-family: "Tahoma","sans-serif";">false</span></code> when <code><span style="font-family: "Tahoma","sans-serif";">buffer</span></code> is set to <code><span style="font-family: "Tahoma","sans-serif";">none</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15675"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">isThreadSafe="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">|false" <a name="15676"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether thread safety is implemented in the JSP page. The default value is <code><span style="font-family: "Tahoma","sans-serif";">true</span></code>, which means that the JSP container can send multiple, concurrent client requests to the JSP page. You must write code in the JSP page to synchronize the multiple client threads. If you use <code><span style="font-family: "Tahoma","sans-serif";">false</span></code>, the JSP container sends client requests one at a time to the JSP page. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15677"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">info="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">text</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="15678"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A text string that is incorporated verbatim into the compiled JSP page. You can later retrieve the string with the <code><span style="font-family: "Tahoma","sans-serif";">Servlet.getServletInfo()</span></code> method. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15679"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">errorPage="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="15680"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A pathname to a JSP page that this JSP page sends exceptions to. If the pathname begins with a <code><span style="font-family: "Tahoma","sans-serif";">/</span></code>, the path is relative to the JSP application's document root directory and is resolved by the web server. If not, the pathname is relative to the current JSP page. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15681"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">isErrorPage="true|</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" <a name="15682"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether the JSP page displays an error page. If set to <code><span style="font-family: "Tahoma","sans-serif";">true</span></code>, you can use the <code><span style="font-family: "Tahoma","sans-serif";">exception</span></code> object in the JSP page. If set to <code><span style="font-family: "Tahoma","sans-serif";">false</span></code> (the default value), you cannot use the <code><span style="font-family: "Tahoma","sans-serif";">exception</span></code> object in the JSP page. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15683"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">contentType="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">mimeType</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> [; charset=</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">characterSet</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> ]" |</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1003086"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> "</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">text/html;charset=ISO-8859-1</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="15684"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The MIME type and character encoding the JSP page uses for the response. You can use any MIME type or character set that are valid for the JSP container. The default MIME type is <code><span style="font-family: "Tahoma","sans-serif";">text/html</span></code>, and the default character set is <code><span style="font-family: "Tahoma","sans-serif";">ISO-8859-1</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1001361"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">pageEncoding="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">characterSet</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | </span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ISO-8859-1</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1001369"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The character encoding the JSP page uses for the response. The default character set is <code><span style="font-family: "Tahoma","sans-serif";">ISO-8859-1</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1011216"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">isElIgnored="true | </span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false<code><span style="font-family: "Tahoma","sans-serif";">"</span></code>
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1011231"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines whether EL expressions are ignored or evaluated for this page and translation unit. If true, EL expressions (of the form <code><span style="font-family: "Tahoma","sans-serif";">${...}</span></code>) are ignored by the container. If false, EL expressions (of the form <code><span style="font-family: "Tahoma","sans-serif";">${...}</span></code>) are evaluated when they appear in template text or action attributes. The default value varies depending on the version of the Web application deployment descriptor. The default mode for JSP pages delivered using a Servlet 2.3 or earlier descriptor is to ignore EL expressions. The default mode for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL expressions. <o:p></o:p></span></p> <h4><a name="18865"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tip<o:p></o:p></span></h4> <p><a name="18866"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If you need to include a long list of packages or classes in more than one JSP page, you can create a separate JSP page with a page directive that contains the import list and include that file in the main JSP page. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag Directive<o:p></o:p></span></h2> <p><a name="1005822"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Used for declaring custom tag properties. <o:p></o:p></span></p> <h4><a name="1003506"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ tag<span style=""> </span><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ display-name="<strong><span style="font-family: "Tahoma","sans-serif";">name of the tag file</span></strong> | <em><span style="font-family: "Tahoma","sans-serif";">display-name</span></em>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ body-content="<strong><span style="font-family: "Tahoma","sans-serif";">scriptless</span></strong>|tagdependent|empty" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ dynamic-attributes="<em><span style="font-family: "Tahoma","sans-serif";">page-scoped attribute</span></em>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ small-icon="<em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ large-icon="<em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ description="<em><span style="font-family: "Tahoma","sans-serif";">text</span></em>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ example="<em><span style="font-family: "Tahoma","sans-serif";">text</span></em>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ language="<strong><span style="font-family: "Tahoma","sans-serif";">java</span></strong>" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ import="{<em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em> | <em><span style="font-family: "Tahoma","sans-serif";">package.*</span></em>} , ... " ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ pageEncoding="{<em><span style="font-family: "Tahoma","sans-serif";">characterSet</span></em> | <strong><span style="font-family: "Tahoma","sans-serif";">ISO-8859-1</span></strong>}" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[ isELIgnored="true|<strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong>" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">%><o:p></o:p></span></pre> <p><a name="1011264"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.tag><span style="font-family: "Tahoma","sans-serif";">tagDirectiveAttrList</span></em> /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">where <em><span style="font-family: "Tahoma","sans-serif";">tagDirectiveAttrList</span></em> is the same as the attribute list in the JSP syntax.<o:p></o:p></span></pre> <h4><a name="1003508"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.tag><o:p></o:p></span></pre> <p><a name="1004306"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">where <em><span style="font-family: "Tahoma","sans-serif";">tagDirectiveAttrList</span></em> is the same as the attribute list in the JSP syntax. <o:p></o:p></span></p> <h4><a name="1006889"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1006895"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This tag accepts an arbitrary number of attributes whose values are colors and outputs a bulleted list of the attributes colored according to the values: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><colored:colored color1="red" color2="yellow" color3="blue"><o:p></o:p></span></pre> <p><a name="1006893"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following code implements the preceding tag. An arbitrary number of attributes whose values are colors are stored in a <code><span style="font-family: "Tahoma","sans-serif";">Map</span></code> named by the <code><span style="font-family: "Tahoma","sans-serif";">dynamic-attributes</span></code> attribute of the tag directive. The JSTL <code><span style="font-family: "Tahoma","sans-serif";">forEach</span></code> tag is used to iterate through the <code><span style="font-family: "Tahoma","sans-serif";">Map</span></code> and the attribute keys and colored attribute values are printed in a bulleted list. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ tag dynamic-attributes="colorMap"%><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><ul><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><c:foreach var="color" begin="0" items="${colorMap}"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><li>${color.key} = <span style="color:${color.value};">${color.value}</<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">font><li><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></c:forEach><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></ul><o:p></o:p></span></pre> <h4><a name="1003512"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1011042"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The tag directive is similar to the page directive in a JSP page, but applies to tag files instead of JSP pages. As with the page directive, a translation unit can contain more than one instance of the tag directive. All the attributes apply to the complete translation unit. However, there can be only one occurrence of any attribute or value defined by this directive in a given translation unit. With the exception of the <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> attribute, multiple attribute or value (re)definitions result in a translation error. <o:p></o:p></span></p> <h4><a name="1011043"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1005161"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">display-name="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name of the tag file</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">display-name</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005544"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A short name that is intended to be displayed by tools. Defaults to the name of the tag file, without the <code><span style="font-family: "Tahoma","sans-serif";">.tag</span></code> extension. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005164"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">body-content="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scriptless</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">|tagdependent|empty"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005548"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Provides information on the content of the body of this tag. Can be either <code><span style="font-family: "Tahoma","sans-serif";">empty</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">tagdependent</span></code>, or <code><span style="font-family: "Tahoma","sans-serif";">scriptless</span></code>. A translation error results if <code><span style="font-family: "Tahoma","sans-serif";">JSP</span></code> or any other value is used. Defaults to <code><span style="font-family: "Tahoma","sans-serif";">scriptless</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005172"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">dynamic-attributes="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">page-scoped attribute</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005556"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Indicates whether this tag supports additional attributes with dynamic names. If present, the generated tag handler must implement the <code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.jsp.tagext.DynamicAttributes</span></code> interface, and the container must treat the tag as if its corresponding TLD entry contained <code><span style="font-family: "Tahoma","sans-serif";"><dynamic-attributes>true</dynamic-attributes></span></code>. The implementation must not reject any attribute names. The value identifies a page-scoped attribute in which to place a <code><span style="font-family: "Tahoma","sans-serif";">Map</span></code> containing the names and values of the dynamic attributes passed during invocation of the tag. The <code><span style="font-family: "Tahoma","sans-serif";">Map</span></code> must contain each dynamic attribute name as the key and the dynamic attribute value as the corresponding value. Only dynamic attributes with no URI are to be present in the <code><span style="font-family: "Tahoma","sans-serif";">Map</span></code>; all other dynamic attributes are ignored. A translation error results if the value of the <code><span style="font-family: "Tahoma","sans-serif";">dynamic-attributes</span></code> of a tag directive is equal to the value of a <code><span style="font-family: "Tahoma","sans-serif";">name-given</span></code> of a variable directive or the value of a <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute of an attribute directive. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005190"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">small-icon="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005564"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Either a context-relative path, or a path relative to the tag source file, of an image file containing a small icon that can be used by tools. Defaults to no small icon. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005193"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">large-icon="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005568"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Either a context-relative path, or a path relative to the tag source file, of an image file containing a large icon that can be used by tools. Defaults to no large icon. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005196"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">description="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">text</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005572"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines an arbitrary string that describes this tag. Defaults to no description. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005198"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">example="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">text</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005576"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines an arbitrary string that presents an informal description of an example of a use of this action. Defaults to no example. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005201"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">language="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005580"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Carries the same syntax and semantics of the <code><span style="font-family: "Tahoma","sans-serif";">language</span></code> attribute of the <code><span style="font-family: "Tahoma","sans-serif";">page</span></code> directive. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005203"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">import="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.*</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">} , ... "</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005584"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Carries the same syntax and semantics of the <code><span style="font-family: "Tahoma","sans-serif";">import</span></code> attribute of the <code><span style="font-family: "Tahoma","sans-serif";">page</span></code> directive. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005209"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">pageEncoding="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">characterSet</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | </span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ISO-8859-1</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">}"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005588"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Carries the same syntax and semantics of the <code><span style="font-family: "Tahoma","sans-serif";">pageEncoding</span></code> attribute in the <code><span style="font-family: "Tahoma","sans-serif";">page</span></code> directive. However, there is no corresponding global configuration element in web.xml. The <code><span style="font-family: "Tahoma","sans-serif";">pageEncoding</span></code> attribute cannot be used in tag files in XML syntax. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005214"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">isELIgnored="true|</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">false</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1005592"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Carries the same syntax and semantics of the <code><span style="font-family: "Tahoma","sans-serif";">isELIgnored</span></code> attribute of the <code><span style="font-family: "Tahoma","sans-serif";">page</span></code> directive. However, there is no corresponding global configuration element in web.xml. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Taglib Directive<o:p></o:p></span></h2> <p><a name="9053"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines a tag library and prefix for the custom tags used in the JSP page. <o:p></o:p></span></p> <h4><a name="9028"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><%@ taglib </span></code><span style="font-family: "Tahoma","sans-serif";">{uri="<em><span style="font-family: "Tahoma","sans-serif";">URI</span></em>" | tagdir="/WEB-INF/tags[/<em><span style="font-family: "Tahoma","sans-serif";">subdir</span></em>]+"} <o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">prefix="<em><span style="font-family: "Tahoma","sans-serif";">tagPrefix</span></em><code><span style="font-family: "Tahoma","sans-serif";">" %><o:p></o:p></span></code></span></pre> <h4><a name="998144"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <p><a name="998148"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">None. Included in <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2024.html#1003283"><jsp:root></a> and in any other XML element using the <code><span style="font-family: "Tahoma","sans-serif";">xmlns</span></code> attribute instead: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><anyxmlelement><span style="font-family: "Tahoma","sans-serif";">prefix</span></em>="{<em><span style="font-family: "Tahoma","sans-serif";">uri</span></em> | urn:jsptld:<em><span style="font-family: "Tahoma","sans-serif";">path</span></em> | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> urn:jsptagdir:/WEB-INF/tags[/<em><span style="font-family: "Tahoma","sans-serif";">subdir</span></em>]+}" ><o:p></o:p></span></pre> <h4><a name="9374"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ taglib uri="http://www.jspcentral.com/tags" prefix="public" %><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><public:loop><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> ...<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></public:loop><o:p></o:p></span></pre> <h4><a name="9039"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="10748"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The taglib directive declares that the JSP page uses custom tags, names the tag library that defines them, and specifies their tag prefix. <o:p></o:p></span></p> <p><a name="1002797"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You must use a taglib directive <em><span style="font-family: "Tahoma","sans-serif";">before</span></em> you use the custom tag in a JSP page. You can use more than one taglib directive in a JSP page, but the prefix defined in each must be unique. <o:p></o:p></span></p> <p><a name="1002799"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tutorials on creating custom tags are available at <a href="http://java.sun.com/products/jsp/taglibraries.html#tutorials">http://java.sun.com/products/jsp/taglibraries.html#tutorials</a>. <o:p></o:p></span></p> <h4><a name="10720"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="10721"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">uri="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">URI</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="10722"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Uniform Resource Identifier (URI) that uniquely locates the TLD that describes the set of custom tags associated with the named tag prefix. A URI can be any of the following: <o:p></o:p></span></p> <ul type="disc"><ul type="circle"><li class="MsoNormal" style=""><a name="17047"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A Uniform Resource Locator (URL), as defined in RFC 2396, available at <code><span style="font-family: "Tahoma","sans-serif";">http://www.hut.fi/u/jkorpela/rfc/2396/full.html</span></code> <a name="17048"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A Uniform Resource Name (URN), as defined in RFC 2396 <a name="17049"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">An absolute or relative pathname <o:p></o:p></span></li></ul></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1011288"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the URI is a URL or URN, then the TLD is located by consulting the mapping indicated in <code><span style="font-family: "Tahoma","sans-serif";">web.xml</span></code> extended using the implicit maps in the packaged tag libraries. If URI is pathname, it is interpreted relative to the root of the web application and should resolve to a TLD file directly, or to a JAR file that has a TLD file at location META-INF/taglib.tld. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1011294"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">tagdir="/WEB-INF/tags[/</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">subdir</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">]+"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1011308"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Indicates this prefix is to be used to identify tag extensions installed in the <code><span style="font-family: "Tahoma","sans-serif";">/WEB-INF/tags/</span></code> directory or a subdirectory. An implicit tag library descriptor is used. A translation error must occur under any of these conditions: <o:p></o:p></span></p> <ul type="disc"><ul type="circle"><li class="MsoNormal" style=""><a name="1011332"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value does not start with <code><span style="font-family: "Tahoma","sans-serif";">/WEB-INF/tags/</span></code>. <a name="1011337"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value does not point to a directory that exists. <a name="1011340"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If this attribute is used in conjunction with the <code><span style="font-family: "Tahoma","sans-serif";">uri</span></code> attribute. <o:p></o:p></span></li></ul><li class="MsoNormal" style=""><a name="1011290"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">prefix="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">tagPrefix</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="10725"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The prefix that precedes the custom tag name, for example, <code><span style="font-family: "Tahoma","sans-serif";">public</span></code> in <code><span style="font-family: "Tahoma","sans-serif";"><public:loop></span></code>. Empty prefixes are illegal. If you are developing or using custom tags, you cannot use the tag prefixes <code><span style="font-family: "Tahoma","sans-serif";">jsp</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">jspx</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">java</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">javax</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">servlet</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">sun</span></code>, and <code><span style="font-family: "Tahoma","sans-serif";">sunw</span></code>, as they are reserved by Sun Microsystems. <o:p></o:p></span></p> <h4><a name="1002041"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1002053"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2024.html#1003283"><jsp:root></a> <a name="1011329"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Section JSP.8.4 of the JSP 2.0 Specification for information on the implicit tag library descriptor. <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Variable Directive<o:p></o:p></span></h2> <p><a name="1005867"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Declares an expression language variable exposed by the tag to the calling page. <o:p></o:p></span></p> <h4><a name="1003552"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ variable { name-given="<em><span style="font-family: "Tahoma","sans-serif";">scripting variable</span></em>" | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> (name-from-attribute="<em><span style="font-family: "Tahoma","sans-serif";">scripting variable</span></em>" <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> alias="<em><span style="font-family: "Tahoma","sans-serif";">locally-scoped attribute</span></em>")}<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ variable-class="<strong><span style="font-family: "Tahoma","sans-serif";">java.lang.String</span></strong>" | <em><span style="font-family: "Tahoma","sans-serif";">name of the variable class</span></em>" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ declare="<strong><span style="font-family: "Tahoma","sans-serif";">true</span></strong> | false" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ scope="AT_BEGIN | AT_END | <strong><span style="font-family: "Tahoma","sans-serif";">NESTED</span></strong>" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ description="<em><span style="font-family: "Tahoma","sans-serif";">text</span></em>" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">%><o:p></o:p></span></pre> <p><a name="1011362"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">OR <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.variable><o:p></o:p></span></pre> <h4><a name="1003554"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:directive.variable><o:p></o:p></span></pre> <h4><a name="1003556"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1011444"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following tag file declares a variable, x, with a scope of AT_END and sets its value to 3. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%-- a.tag --%><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ variable name-given="x" scope="AT_END" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><c:set var="x" value="3"><o:p></o:p></span></pre> <p><a name="1011447"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following JSP page references the variable with an EL expression. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%-- b.jsp --%><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">${x} <o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><tags:a><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">${x} <o:p></o:p></span></pre> <p><a name="1011434"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The first reference to the variable is undefined because the variable has not been declared yet. After the tag file has been invoked and the variable is set, the page references the variable again, which will result in an output of 3. <o:p></o:p></span></p> <h4><a name="1003558"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1007016"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The variable directive is used to declare variables in tag files. The variable directive is analogous to the variable element in the Tag Library descriptor, and defines the details of a variable exposed by the tag handler to the calling page. <o:p></o:p></span></p> <p><a name="1010158"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A custom tag (whether it's implemented using Java or a tag file) is able to declare that it returns variables to the calling page. For example, the following tag can look up user information and place it in a bean: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><mytag:lookupuserinfo><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>${userInfo.name}<o:p></o:p></span></pre> <p><a name="1010163"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this case, the lookupUserInfo tag can declare that it returns a variable to the calling page with a name of <code><span style="font-family: "Tahoma","sans-serif";">userInfo</span></code>. <o:p></o:p></span></p> <p><a name="1010211"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here is another example: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><mytag:displaycustomers><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>${customer.name}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></mytag:displayCustomers> <o:p></o:p></span></pre> <p><a name="1010171"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The scope of the variable affects how it is exposed to the calling page (<code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> means the variable is available from the start tag onwards, <code><span style="font-family: "Tahoma","sans-serif";">AT_END</span></code> means the variable is available from the end tag onwards, and <code><span style="font-family: "Tahoma","sans-serif";">NESTED</span></code> means the variable is only available in the body of the tag). In the first preceding example, you would probably use <code><span style="font-family: "Tahoma","sans-serif";">AT_END</span></code> so that the variable is still available at the end of the tag. In the second example, you would probably use <code><span style="font-family: "Tahoma","sans-serif";">NESTED</span></code> since the <code><span style="font-family: "Tahoma","sans-serif";">${customer}</span></code> variable doesn't need to be accessible anywhere but inside the displayCustomers tag. <o:p></o:p></span></p> <p><a name="1010232"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">When you want to emulate OUT parameters, use variables with scope <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">AT_END</span></code>. For each <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">AT_END</span></code> variable, a page-scoped attribute is made available in the <code><span style="font-family: "Tahoma","sans-serif";">JspContext</span></code> of the tag file. The scoped attribute is not initialized. Synchronization is performed at the end of the tag for <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">AT_END</span></code> and also before the invocation of a fragment for <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code>. <o:p></o:p></span></p> <p><a name="1010258"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">When you want to emulate nested parameters, use variables with scope <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">NESTED</span></code>. For each <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">NESTED</span></code> variable, a page-scoped attribute is made available in the <code><span style="font-family: "Tahoma","sans-serif";">JspContext</span></code> of the tag file. The scoped attribute is not initialized. Synchronization is performed before each fragment invocation for <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">NESTED</span></code>, and also after the end of the tag for <code><span style="font-family: "Tahoma","sans-serif";">AT_BEGIN</span></code> <o:p></o:p></span></p> <p><a name="1010274"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP specification recommends that to accomplish IN parameters, use attributes. To accomplish OUT or NESTED parameters, use variables. <o:p></o:p></span></p> <h4><a name="1003560"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003561"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name-given="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scripting variable</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" | name-from-attribute="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scripting variable</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1003562"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines an EL variable to be used in the page invoking this tag. Either name-given or name-from-attribute must be specified. If name-given is specified, the value is the name of an attribute whose (translation-time) value at the start of the tag invocation will give the name of the variable. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1005910"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Translation errors arise in the following circumstances: <o:p></o:p></span></p> <ul type="disc"><ul type="circle"><li class="MsoNormal" style=""><a name="1005911"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Specifying neither name-given nor name-from-attribute. <a name="1005912"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If two variable directives have the same name-given. <a name="1005913"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the value of a name-given attribute of a variable directive is equal to the value of a name attribute of an attribute directive or the value of a <code><span style="font-family: "Tahoma","sans-serif";">dynamic-attributes</span></code> attribute of a tag directive. <o:p></o:p></span></li></ul></ul> <ul type="disc"><li class="MsoNormal" style=""><a name="1005914"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">alias="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">locally-scoped attribute</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1005955"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines a variable, local to the tag file, to hold the value of the EL variable. The container will synchronize this value with the variable whose name is given in <code><span style="font-family: "Tahoma","sans-serif";">name-from-attribute</span></code>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1005960"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Required when <code><span style="font-family: "Tahoma","sans-serif";">name-from-attribute</span></code> is specified. A translation error results if used without <code><span style="font-family: "Tahoma","sans-serif";">name-from-attribute</span></code>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1005961"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A translation error results if the value of <code><span style="font-family: "Tahoma","sans-serif";">alias</span></code> is the same as the value of a <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute of an <code><span style="font-family: "Tahoma","sans-serif";">attribute</span></code> directive or the <code><span style="font-family: "Tahoma","sans-serif";">name-given</span></code> attribute of a <code><span style="font-family: "Tahoma","sans-serif";">variable</span></code> directive. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005956"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">variable-class="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.String</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" | </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name of the variable class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1005990"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of the class of the variable. The default is <code><span style="font-family: "Tahoma","sans-serif";">java.lang.String</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1006001"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">declare="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | false"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1006010"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whether or not the variable is declared. Defaults to <code><span style="font-family: "Tahoma","sans-serif";">true</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1006019"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scope="AT_BEGIN | AT_END | </span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">NESTED</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1006020"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The scope of the variable. Defaults to NESTED. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1005991"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">description="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">text</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1006042"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">An optional description of this variable. Defaults to no description. <o:p></o:p></span></p> <h4><a name="1003563"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003564"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2012.html#1003416">Taglib Directive</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:attribute><o:p></o:p></span></h2> <p><a name="1006344"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The jsp:attribute element allows you to define the value of a tag attribute in the body of an XML element instead of in the value of an XML attribute. <o:p></o:p></span></p> <h4><a name="1003572"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:attribute name=""><span style="font-family: "Tahoma","sans-serif";">attributeName</span></em>" [ trim= "<strong><span style="font-family: "Tahoma","sans-serif";">true</span></strong> | false" ] /><o:p></o:p></span></pre> <h4><a name="1003574"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <p><a name="1003575"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Same as JSP syntax. <o:p></o:p></span></p> <h4><a name="1003576"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1006394"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following template page uses <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code>, which uses the output of <code><span style="font-family: "Tahoma","sans-serif";">fmt:message</span></code> to set the value of the <code><span style="font-family: "Tahoma","sans-serif";">value</span></code> attribute of <code><span style="font-family: "Tahoma","sans-serif";">tt:parameter</span></code>: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";">...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><tt:screen id="/bookcatalog"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <tt:parameter name="title" direct="true"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:attribute name="value"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <fmt:message key="TitleBookCatalog"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> </jsp:attribute><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> </tt:parameter><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></tt:screen><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">...<o:p></o:p></span></pre> <h4><a name="1003578"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1006641"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The jsp:attribute standard action has two uses: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1006682"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It allows the page author to define the value of an action attribute in the body of an XML element instead of in the value of an XML attribute. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1006691"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It allows the page author to specify the attributes of an element dynamically generated by the <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> action, which can only appear as a subelement of a standard or custom action.<o:p></o:p></span></li></ul> <p><a name="1006680"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">All JSP standard actions and custom actions can contain a <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> standard element as a substitute for any of its attributes. One use case in which <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> is particularly helpful is where the value of an attribute is the result of a multi-line expression, which would not fit in the value of an attribute in the start tag of the action. <o:p></o:p></span></p> <p><a name="1006668"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If an action contains any <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> elements and the action also has a body, it must use the <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> tag to represent the body. The body of <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> is restricted according to the type of attribute being specified: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1006632"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">For simple attributes that accept an EL expression, the body can be any JSP content. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1006634"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">For simple attributes that do not accept an EL expression, the body can contain only static text.<a name="1006636"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">For fragment attributes, the body must not contain any scripting elements.<o:p></o:p></span></li></ul> <h4><a name="1003580"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003581"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">attributeName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1006467"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Identifies which tag attribute is being specified. When used with jsp:element, this attribute specifies the name of the attribute to be included in the generated element. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1006551"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> tag is not being used with <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> and the action does not accept dynamic attributes, the name must match the name of an attribute for the action being invoked, as declared in the Tag Library Descriptor for a custom action, or as specified for a standard action. If it doesn't match, a translation error results. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1006523"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> element is being used with a <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> tag, a translation error results if both an XML element attribute and a <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> element are used to specify the value for the same attribute. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1006537"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of name can be a <code><span style="font-family: "Tahoma","sans-serif";">QName</span></code>. If so, a translation error must occur if the prefix does not match that of the action it applies to, unless the action supports dynamic attributes or the action is <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1006483"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">trim= "</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">true</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | false"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1013071"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The optional trim attribute determines whether or not whitespace appearing at the beginning and end of the element body should be discarded. By default, the leading and trailing whitespace (including spaces, carriage returns, line feeds, and tabs) is discarded. The whitespace is trimmed when the JSP page is translated. If a body contains a custom tag that produces leading or trailing whitespace, that whitespace is preserved regardless of the value of the trim attribute. <o:p></o:p></span></p> <h4><a name="1003583"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003584"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2015.html#1006731"><jsp:body></a> <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1012993"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2016.html#1003696"><jsp:element></a><o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:body><o:p></o:p></span></h2> <p><a name="1006732"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Specifies the body of a tag. <o:p></o:p></span></p> <h4><a name="1006733"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:body><em><span style="font-family: "Tahoma","sans-serif";">any elements or text</span></em></jsp:body><o:p></o:p></span></pre> <h4><a name="1003759"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <p><a name="1003760"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Same as JSP syntax. <o:p></o:p></span></p> <h4><a name="1003761"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1006743"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This example generates an HTML <code><span style="font-family: "Tahoma","sans-serif";">header</span></code> tag with a <code><span style="font-family: "Tahoma","sans-serif";">lang</span></code> attribute: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:element name="${content.headerName}" style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> xmlns:jsp="http://java.sun.com/JSP/Page"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:attribute name="lang">${content.lang}</jsp:attribute><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:body>${content.body}</jsp:body><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:element><o:p></o:p></span></pre> <p><a name="1006745"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute identifies the generated tag's name. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> tag generates the <code><span style="font-family: "Tahoma","sans-serif";">lang</span></code> attribute. The body of the <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> tag identifies the value of the <code><span style="font-family: "Tahoma","sans-serif";">lang</span></code> attribute. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> tag generates the body of the tag. The output of this example <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> could be: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><h1 lang="fr">Heading in French</h1><o:p></o:p></span></pre> <h4><a name="1003763"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1006759"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Normally, the body of a standard or custom action invocation is defined implicitly as the body of the XML element used to represent the invocation. The body of a standard or custom action can also be defined explicitly using the <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> standard action. This is required if one or more <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> elements appear in the body of the tag. <o:p></o:p></span></p> <p><a name="1006764"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If one or more <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> elements appear in the body of a tag invocation but no <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> element appears or an empty <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> element appears, it is the equivalent of the tag having an empty body. <o:p></o:p></span></p> <p><a name="1006767"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It is also legal to use the <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> standard action to supply bodies to any standard actions that accepts a body (except for <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">jsp:scriptlet</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">jsp:expression</span></code>, and <code><span style="font-family: "Tahoma","sans-serif";">jsp:declaration</span></code>). The body standard action accepts no attributes. <o:p></o:p></span></p> <h4><a name="1003768"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003769"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2014.html#1003424"><jsp:attribute></a> <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1012977"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2016.html#1003696"><jsp:element></a><o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:element><o:p></o:p></span></h2> <p><a name="1006051"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Dynamically generates an XML element. <o:p></o:p></span></p> <h4><a name="1003697"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";">(<jsp:element name=""><span style="font-family: "Tahoma","sans-serif";">elementName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> ( /> | ><span style=""> </span>( any elements or text </jsp:element> ))<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">) <o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">| ( <jsp:element name=""><span style="font-family: "Tahoma","sans-serif";">elementName</span></em>"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>[ <jsp:attribute name=""><span style="font-family: "Tahoma","sans-serif";">attributeName</span></em>" <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>[ trim="<strong><span style="font-family: "Tahoma","sans-serif";">true</span></strong> | false" ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>( /> | (<em><span style="font-family: "Tahoma","sans-serif";">any elements or text</span></em> </jsp:attribute> ) ) ]+ <o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>[ <jsp:body> <em><span style="font-family: "Tahoma","sans-serif";">any elements or text</span></em> </jsp:body> ]<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></jsp:element><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>)<o:p></o:p></span></pre> <h4><a name="1003699"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";">Same as JSP syntax.<o:p></o:p></span></pre> <h4><a name="1003701"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1006071"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This example generates an HTML <code><span style="font-family: "Tahoma","sans-serif";">header</span></code> tag with a <code><span style="font-family: "Tahoma","sans-serif";">lang</span></code> attribute: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:element name="${content.headerName}" style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> xmlns:jsp="http://java.sun.com/JSP/Page"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:attribute name="lang">${content.lang}</jsp:attribute><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:body>${content.body}</jsp:body><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:element><o:p></o:p></span></pre> <p><a name="1006079"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute identifies the generated tag's name. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> tag generates the <code><span style="font-family: "Tahoma","sans-serif";">lang</span></code> attribute. The body of the <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> tag identifies the value of the <code><span style="font-family: "Tahoma","sans-serif";">lang</span></code> attribute. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code> tag generates the body of the tag. The output of this example <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> could be: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><h1 lang="fr">Heading in French</h1><o:p></o:p></span></pre> <h4><a name="1003703"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1006146"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> action is used to dynamically define the value of the tag of an XML element. This action can be used in JSP pages, tag files and JSP documents. <o:p></o:p></span></p> <p><a name="1006154"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> action has one mandatory attribute, name, of type String. The value of the name attribute is used as that of the tag of the element generated. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> action can have a body. Two forms are valid, depending on whether the element is to have attributes or not. In the first form, no attributes are present: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:element name="name"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> optional body<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:element><o:p></o:p></span></pre> <p><a name="1006166"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In the second form, zero or more attributes are requested, using jsp:attribute and <code><span style="font-family: "Tahoma","sans-serif";">jsp:body</span></code>, as appropriate. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:element name="name"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [jsp:attribute]+<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [jsp:body]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:element><o:p></o:p></span></pre> <p><a name="1006176"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The one valid, mandatory, attribute of <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code> is its name. Unlike other standard actions, the value of the name attribute must be given as an XML-style attribute and cannot be specified using <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> This is because <code><span style="font-family: "Tahoma","sans-serif";">jsp:attribute</span></code> has a special meaning when used in the body of <code><span style="font-family: "Tahoma","sans-serif";">jsp:element</span></code>. <o:p></o:p></span></p> <h4><a name="1003705"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003706"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">elementName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1006193"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of name is that of the element generated. The name can be a <code><span style="font-family: "Tahoma","sans-serif";">QName</span></code>; JSP 2.0 places no constraints on this value: it is accepted as is. A request-time attribute value may be used for this attribute. <o:p></o:p></span></p> <h4><a name="1003708"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003709"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2014.html#1003424"><jsp:attribute></a> <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1012962"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2015.html#1006731"><jsp:body></a><o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:dobody><o:p></o:p></span></h2> <p><a name="1006218"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Evaluates the body of the tag used by the calling page to invoke this tag file. <o:p></o:p></span></p> <h4><a name="1003606"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:dobody var=""><span style="font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em>"<span style=""> </span>|<span style=""> </span><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>varReader="<em><span style="font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em>" }<span style=""> </span><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>[scope="<strong><span style="font-family: "Tahoma","sans-serif";">page</span></strong> | request | session | application" ] />) | /><o:p></o:p></span></pre> <h4><a name="1003608"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <p><a name="1003609"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Same as JSP syntax. <o:p></o:p></span></p> <h4><a name="1003610"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1009991"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This example tag file encapsulates the <code><span style="font-family: "Tahoma","sans-serif";">double</span></code> custom tag <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%-- double.tag --%><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:dobody><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:dobody><o:p></o:p></span></pre> <p><a name="1010126"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It includes two <code><span style="font-family: "Tahoma","sans-serif";">jsp:doBody</span></code> tags, which will each invoke the body of the custom double tag in any JSP that includes the tag. <o:p></o:p></span></p> <p><a name="1010133"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This example JSP page uses the custom double tag to output the text included in the body of the tag two times. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%-- a.jsp --%><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><tags:double><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>This text will be printed twice.<br /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></tags:double><o:p></o:p></span></pre> <p><a name="1003611"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The result will be the output: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";">This text will be printed twice.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">This text will be printed twice.<o:p></o:p></span></pre> <h4><a name="1003612"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1009997"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:doBody</span></code> standard action can only be used in tag files. It invokes the body of the tag, sending the output of the result to the <code><span style="font-family: "Tahoma","sans-serif";">JspWriter</span></code>, or to a scoped attribute that can be examined and manipulated. <o:p></o:p></span></p> <p><a name="1010086"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:doBody</span></code> standard action behaves exactly like <code><span style="font-family: "Tahoma","sans-serif";">jsp:invoke</span></code>, except that it operates on the body of the tag instead of on a specific fragment passed as an attribute. Because it always operates on the body of the tag, there is no name attribute for this standard action. <o:p></o:p></span></p> <p><a name="1010095"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Fragments are provided access to variables the same way for <code><span style="font-family: "Tahoma","sans-serif";">jsp:doBody</span></code> as they are for <code><span style="font-family: "Tahoma","sans-serif";">jsp:invoke</span></code>. If no body was passed to the tag, <code><span style="font-family: "Tahoma","sans-serif";">jsp:doBody</span></code> will behave as though a body was passed in that produces no output. <o:p></o:p></span></p> <p><a name="1010090"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The body of a tag is passed to the simple tag handler as a <code><span style="font-family: "Tahoma","sans-serif";">JspFragment</span></code> object. A translation error shall result if the <code><span style="font-family: "Tahoma","sans-serif";">jsp:doBody</span></code> action contains a nonempty body. <o:p></o:p></span></p> <p><a name="1007044"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The result of evaluating the tag body is sent to the response or is stored in an EL variable for later manipulation. To store the result of evaluating a fragment to an EL variable, you specify the <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> attribute. If <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> is specified, the container stores the result in an EL variable of type String with the name specified by <code><span style="font-family: "Tahoma","sans-serif";">var</span></code>. If <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> is specified, the container stores the result in an EL variable of type <code><span style="font-family: "Tahoma","sans-serif";">java.io.Reader</span></code>, with the name specified by <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code>. The <code><span style="font-family: "Tahoma","sans-serif";">Reader</span></code> object can then be passed to a custom tag for further processing. A translation error occurs if both <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified. An optional <code><span style="font-family: "Tahoma","sans-serif";">scope</span></code> attribute indicates the scope of the resulting variable. The possible values are <code><span style="font-family: "Tahoma","sans-serif";">page</span></code> (default), <code><span style="font-family: "Tahoma","sans-serif";">request</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">session</span></code>, or <code><span style="font-family: "Tahoma","sans-serif";">application</span></code>. A translation error occurs if you use this attribute without specifying the <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> attribute. <o:p></o:p></span></p> <h4><a name="1003614"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1006234"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">var="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1006269"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of a scoped attribute to store the result of the body invocation in, as a java.lang.<code><span style="font-family: "Tahoma","sans-serif";">String</span></code> object. A translation error must occur if both <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified. If neither <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> nor <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified, the result of the body goes directly to the <code><span style="font-family: "Tahoma","sans-serif";">JspWriter</span></code>, as described above. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1006240"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">varReader="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1006293"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of a scoped attribute to store the result of the body invocation in, as a <code><span style="font-family: "Tahoma","sans-serif";">java.io.Reader</span></code> object. A translation error must occur if both <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified. If neither <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> nor <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> is specified, the result of the body invocation goes directly to the <code><span style="font-family: "Tahoma","sans-serif";">JspWriter</span></code>, as described above. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1006246"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scope="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">page</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | request | session | application"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1006312"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The scope in which to store the resulting variable. A translation error results if the value is not one of <code><span style="font-family: "Tahoma","sans-serif";">page</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">request</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">session</span></code>, or <code><span style="font-family: "Tahoma","sans-serif";">application</span></code>. A translation error results if this attribute appears without specifying either the <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> attribute as well. Note that a value of session should be used with caution since not all calling pages may be participating in a session. A container must throw an <code><span style="font-family: "Tahoma","sans-serif";">IllegalStateException</span></code> at runtime if scope is session and the calling page does not participate in a session. Defaults to <code><span style="font-family: "Tahoma","sans-serif";">page</span></code>. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:forward><o:p></o:p></span></h2> <p><a name="15695"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Forwards a request to a web resource. <o:p></o:p></span></p> <h4><a name="15696"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><jsp:forward page=""></code><em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | '${' </span></code><em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em><code><span style="font-family: "Tahoma","sans-serif";">'}' | <span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> <%= </span></code><em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> %>}" { /> | > [<jsp:param name=""></code><em><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em><code><span style="font-family: "Tahoma","sans-serif";">" <o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";">value="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">parameterValue</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | '${' </span></code><em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> '}' | <%= </span></code><em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> %>}" } <o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";">/> ]+ </jsp:forward>}<o:p></o:p></span></code></pre> <h4><a name="998158"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:forward page=""><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em> | '${' <em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em> '}' | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> % }" { /> | > [<jsp:param<span style=""> </span>name="<em><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em>" <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> value="{<em><span style="font-family: "Tahoma","sans-serif";">parameterValue</span></em> | '${' <em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em> '}' | %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %}" }<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">/> ]+ </jsp:forward> }<o:p></o:p></span></pre> <h4><a name="15698"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:forward page="/servlet/login"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:forward page="/servlet/login"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:param name="username" value="jsmith"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:forward><o:p></o:p></span></pre> <h4><a name="17081"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="15701"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:forward</span></code> element forwards the <code><span style="font-family: "Tahoma","sans-serif";">request</span></code> object containing the client request information from one JSP page to another resource. The target resource can be an HTML file, another JSP page, or a servlet, as long as it is in the same application context as the forwarding JSP page. The lines in the source JSP page after the <code><span style="font-family: "Tahoma","sans-serif";">jsp:forward</span></code> element are not processed. <o:p></o:p></span></p> <p><a name="18339"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can pass parameter names and values to the target resource by using a <code><span style="font-family: "Tahoma","sans-serif";">jsp:param</span></code> clause. An example of this would be passing the parameter name <code><span style="font-family: "Tahoma","sans-serif";">username</span></code> (with <code><span style="font-family: "Tahoma","sans-serif";">name="username"</span></code>) and the value <code><span style="font-family: "Tahoma","sans-serif";">scott</span></code> (with <code><span style="font-family: "Tahoma","sans-serif";">value="scott"</span></code>) to a servlet as part of the request. If you use <code><span style="font-family: "Tahoma","sans-serif";">jsp:param</span></code>, the target resource should be a dynamic resource that can handle the parameters. <o:p></o:p></span></p> <p><a name="18363"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Be careful when using <code><span style="font-family: "Tahoma","sans-serif";">jsp:forward</span></code> with unbuffered output. If you have used the page directive with <code><span style="font-family: "Tahoma","sans-serif";">buffer="none"</span></code> to specify that the output of your JSP page should not be buffered, and if the JSP page has any data in the out object, using <code><span style="font-family: "Tahoma","sans-serif";">jsp:forward</span></code> will cause an <code><span style="font-family: "Tahoma","sans-serif";">IllegalStateException</span></code>. <o:p></o:p></span></p> <h4><a name="15703"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="15704"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">page="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | <%= </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> %>}"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="15705"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A <code><span style="font-family: "Tahoma","sans-serif";">String</span></code> or an expression representing the relative URL of the component to which you are forwarding the request. The component can be another JSP page, a servlet, or any other object that can respond to a request. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="17094"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The relative URL looks like a path--it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP page. If it is absolute (beginning with a <code><span style="font-family: "Tahoma","sans-serif";">/</span></code>), the path is resolved by your web or application server. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="18312"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:param name=""></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">parameterName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" value="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">parameterValue</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | <%= </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> %>}" />+ </span></code><a name="18317"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Sends one or more name/value pairs as parameters to a dynamic resource. The target resource should be dynamic, that is, a JSP page, servlet, or other resource that can process the data that is sent to it as parameters. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18614"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can use more than one <code><span style="font-family: "Tahoma","sans-serif";">jsp:param</span></code> clause if you need to send more than one parameter to the target resource. The <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute specifies the parameter name and takes a case-sensitive literal string as a value. The <code><span style="font-family: "Tahoma","sans-serif";">value</span></code> attribute specifies the parameter value and takes either a case-sensitive literal string or an expression that is evaluated at request time. <o:p></o:p></span></p> <h4><a name="15708"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="15712"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref209.html#1003408">Include Directive</a> <a name="15716"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2020.html#8828"><jsp:include></a> <a name="15720"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2010.html#15653">Page Directive</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></code></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:getproperty><o:p></o:p></span></h2> <p><a name="9771"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Inserts the value of a bean property into the result. <o:p></o:p></span></p> <h4><a name="9190"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax and XML Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><jsp:getproperty name=""></code><em><span style="font-family: "Tahoma","sans-serif";">beanInstanceName</span></em><code><span style="font-family: "Tahoma","sans-serif";">" property="</span></code><em><span style="font-family: "Tahoma","sans-serif";">propertyName</span></em><code><span style="font-family: "Tahoma","sans-serif";">" /><o:p></o:p></span></code></pre> <h4><a name="9194"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean id="calendar" scope="page" class="employee.Calendar"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><h2><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Calendar of <jsp:getproperty name="calendar" property="username"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></h2><o:p></o:p></span></pre> <h4><a name="9198"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="19459"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:getProperty</span></code> element gets a bean property value using the property's getter methods and inserts the value into the response. You must create or locate a bean with <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2027.html#8865"><jsp:usebean></a> <em><span style="font-family: "Tahoma","sans-serif";">before</span></em> you use <code><span style="font-family: "Tahoma","sans-serif";">jsp:getProperty</span></code>. <o:p></o:p></span></p> <p><a name="17115"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:getProperty</span></code> element has a few limitations you should be aware of: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="17116"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You cannot use <code><span style="font-family: "Tahoma","sans-serif";">jsp:getProperty</span></code> to retrieve the values of an indexed property. <a name="16053"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can use <code><span style="font-family: "Tahoma","sans-serif";">jsp:getProperty</span></code> with JavaBeans components, but not with enterprise beans. As alternatives, you can write a JSP page that retrieves values from a bean that in turn retrieves values from an enterprise bean, or you can write a custom tag that retrieves values from an enterprise bean directly. <o:p></o:p></span></li></ul> <h4><a name="15747"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="15748"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">beanInstanceName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="15749"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of an object (usually an instance of a bean) as declared in a <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2027.html#8865"><jsp:usebean></a> element. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="10919"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">property="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">propertyName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="10920"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of the bean property whose value you want to display. The property is declared as a variable in a bean and must have a corresponding getter method (for more information on declaring variables and writing getter methods in beans, see <em><span style="font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/javabeans/docs/">http://java.sun.com/products/javabeans/docs/</a></span></em>). <o:p></o:p></span></p> <h4><a name="19482"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tip<o:p></o:p></span></h4> <p><a name="19487"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If you use <code><span style="font-family: "Tahoma","sans-serif";">jsp:getProperty</span></code> to retrieve a property value that is null, a <code><span style="font-family: "Tahoma","sans-serif";">NullPointerException</span></code> is thrown. However, if you use a scriptlet or expression to retrieve the value, the string <code><span style="font-family: "Tahoma","sans-serif";">null</span></code> is displayed in the browser; see <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996">Scriptlet</a> or <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref205.html#1004353">Expression</a> for more information. <o:p></o:p></span></p> <h4><a name="9201"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="9202"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2027.html#8865"><jsp:usebean></a> <a name="9203"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#8856"><jsp:setproperty></a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:include><o:p></o:p></span></h2> <p><a name="10117"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Includes a static file or the result from another web component. <o:p></o:p></span></p> <h4><a name="9217"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><jsp:include page="</span"></code><span style="font-family: "Tahoma","sans-serif";">"{<em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | '${' </span></code><em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> '}' |<span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> <%=</span></code><span style="font-family: "Tahoma","sans-serif";"> <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> %>}</span></code>"<code><span style="font-family: "Tahoma","sans-serif";"> <span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> [ flush="true</span></code><span style="font-family: "Tahoma","sans-serif";">| <strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> { /> | > [ <jsp:param name=""><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> value="{<em><span style="font-family: "Tahoma","sans-serif";">parameterValue</span></em> | '${' <em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em> '}' | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <%= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %>}" />] +<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:include> }<o:p></o:p></span></pre> <h4><a name="1008152"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><jsp:include page="</span"></code><span style="font-family: "Tahoma","sans-serif";">"{<em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | '${' </span></code><em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> '}' |<span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> %=</span></code><span style="font-family: "Tahoma","sans-serif";"> <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> %}</span></code>"<code><span style="font-family: "Tahoma","sans-serif";"> <span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> [ flush="true</span></code><span style="font-family: "Tahoma","sans-serif";">| <strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> { /> | > [ <jsp:param name=""><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> value="{parameterValue | '${' <em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em> '}' | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %}" />] +<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:include> }<o:p></o:p></span></pre> <h4><a name="9221"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:include page="scripts/login.jsp"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:include page="copyright.html"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:include page="/index.html"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:include page="scripts/login.jsp"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:param name="username" value="jsmith"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:include><o:p></o:p></span></pre> <h4><a name="9225"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="997649"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:include</span></code> element allows you to include either a <em><span style="font-family: "Tahoma","sans-serif";">static </span></em>or <em><span style="font-family: "Tahoma","sans-serif";">dynamic</span></em> <em><span style="font-family: "Tahoma","sans-serif";">resource</span></em> in a JSP page. The results of including static and dynamic resources are quite different. If the resource is static, its content is included in the calling JSP page. If the resource is dynamic, it acts on a request and sends back a result that is included in the JSP page. When the include action is finished, the JSP container continues processing the remainder of the JSP page. <o:p></o:p></span></p> <p><a name="16143"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You cannot always determine from a pathname if a resource is static or dynamic. For example, <em><span style="font-family: "Tahoma","sans-serif";">http://server:8080/index.html</span></em> might map to a servlet through a server alias. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:include</span></code> element handles both types of resources, so it is convenient to use when you don't know whether the resource is static or dynamic. <o:p></o:p></span></p> <p><a name="18394"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the included resource is dynamic, you can use a <code><span style="font-family: "Tahoma","sans-serif";">jsp:param</span></code> clause to pass the name and value of a parameter to the resource. As an example, you could pass the string <code><span style="font-family: "Tahoma","sans-serif";">username</span></code> and a user's name to a login form that is coded in a JSP page. <o:p></o:p></span></p> <h4><a name="10929"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="10930"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">page=</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"{ <em><span style="font-family: "Tahoma","sans-serif";">relativeURL</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | <%= </span></code><em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> %> }</span></code>" <a name="11213"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The relative URL that locates the resource to be included, or an expression that evaluates to a <code><span style="font-family: "Tahoma","sans-serif";">String</span></code> equivalent to the relative URL. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="17155"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The relative URL looks like a pathname--it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP page. If it is absolute (beginning with a <code><span style="font-family: "Tahoma","sans-serif";">/</span></code>), the pathname is resolved by your web or application server. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="17145"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">flush="true </span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">| <strong><span style="font-family: "Tahoma","sans-serif";">false</span></strong>" <a name="999394"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the page output is buffered and the <code><span style="font-family: "Tahoma","sans-serif";">flush</span></code> attribute is given a true value, the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the <code><span style="font-family: "Tahoma","sans-serif";">flush</span></code> attribute is <code><span style="font-family: "Tahoma","sans-serif";">false</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="18376"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:param name=""></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">parameterName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" value="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">parameterValue</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | <%= </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> %>}" />+ </span></code><a name="18405"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:param</span></code> clause allows you to pass one or more name/value pairs as parameters to an included resource. The included resource should be dynamic, that is, a JSP page, servlet, or other resource that can process the parameter. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18578"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can use more than one <code><span style="font-family: "Tahoma","sans-serif";">jsp:param</span></code> clause if you want to send more than one parameter to the included resource. The <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute specifies the parameter name and takes a case-sensitive literal string. The <code><span style="font-family: "Tahoma","sans-serif";">value</span></code> attribute specifies the parameter value and takes either a case-sensitive literal string or an expression that is evaluated at request time. <o:p></o:p></span></p> <h4><a name="9228"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="9229"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref209.html#1003408">Include Directive</a> <a name="9230"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2018.html#1003349"><jsp:forward></a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:invoke><o:p></o:p></span></h2> <p><a name="1007272"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Evaluates a fragment attribute. <o:p></o:p></span></p> <h4><a name="1003623"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:invoke fragment=""><span style="font-family: "Tahoma","sans-serif";">fragmentName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">({var="<em><span style="font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em>" |<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">varReader="<em><span style="font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em>"}<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">[scope="<strong><span style="font-family: "Tahoma","sans-serif";">page</span></strong> | request | session | application" ] />) | /><o:p></o:p></span></pre> <h4><a name="1003625"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <p><a name="1003626"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Same as JSP syntax <o:p></o:p></span></p> <h4><a name="1003627"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1007225"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following tag file represents a tag that renders the catalog of a book database as an HTML table. The tag file declares that it sets variables, which are used by two fragment attributes. Before the tag invokes the fragment attributes using the <code><span style="font-family: "Tahoma","sans-serif";">jsp:invoke</span></code> element, the Web container passes values for the variables back to the calling page. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><%@ attribute name="bookDB" required="true"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>type="database.BookDB" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ attribute name="color" required="true" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ attribute name="normalPrice" fragment="true" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ attribute name="onSale" fragment="true" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ variable name-given="price" %> <o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ variable name-given="salePrice" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><center><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><table><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><c:foreach var="book" begin="0" items="${bookDB.books}"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><c:set var="salePrice" value="${book.price * .85}"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><c:set var="price" value="${book.price}"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><c:choose><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><c:when test="${book.onSale}"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><jsp:invoke fragment="onSale"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><span style=""> </span></c:when><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><c:otherwise><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><jsp:invoke fragment="normalPrice"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></c:otherwise><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></c:choose><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">...<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></table><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></center> <o:p></o:p></span></pre> <p><a name="1007252"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The following page invokes the tag. The formatting of the book price is determined by two fragment attributes--<code><span style="font-family: "Tahoma","sans-serif";">normalPrice</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">onSale</span></code>--that are conditionally invoked by the tag according to data retrieved from the book database. <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><sc:catalog bookdb ="${bookDB}" color="#cccccc"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><jsp:attribute name="normalPrice"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><fmt:formatnumber value="${price}" type="currency"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></jsp:attribute><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><jsp:attribute name="onSale"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><strike><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><fmt:formatnumber value="${price}" type="currency"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></strike><br/><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><span style="color:red;"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><fmt:formatnumber value="${salePrice}" type="currency"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></jsp:attribute><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></sc:catalog> <o:p></o:p></span></pre> <h4><a name="1003629"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1010310"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:invoke</span></code> standard action takes the name of an attribute that is a fragment, and invokes the fragment, sending the output of the result to the <code><span style="font-family: "Tahoma","sans-serif";">JspWriter</span></code>, or to a scoped attribute that can be examined and manipulated. If the fragment identified by the given name is null, <code><span style="font-family: "Tahoma","sans-serif";">jsp:invoke</span></code> will behave as though a fragment was passed in that produces no output. <o:p></o:p></span></p> <p><a name="1007284"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The most basic usage of this standard action will invoke a fragment with the given name with no parameters. It is also possible to invoke the fragment and send the results to a scoped attribute for further examination and manipulation. This can be accomplished by specifying the <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> attribute in the action. If var is specified, the container stores the result in an EL variable of type <code><span style="font-family: "Tahoma","sans-serif";">String</span></code> with the name specified by <code><span style="font-family: "Tahoma","sans-serif";">var</span></code>. If <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> is specified, the container stores the result in an EL variable of type <code><span style="font-family: "Tahoma","sans-serif";">java.io.Reader</span></code>, with the name specified by <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code>. The <code><span style="font-family: "Tahoma","sans-serif";">Reader</span></code> object can then be passed to a custom tag for further processing. A translation error occurs if both <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified. <o:p></o:p></span></p> <h4><a name="1003631"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1007359"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">fragment="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">fragmentName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1007387"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name used to identify this fragment during this tag invocation. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007361"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">var="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1007403"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of a scoped attribute to store the result of the fragment invocation in, as a <code><span style="font-family: "Tahoma","sans-serif";">java.lang.String</span></code> object. A translation error must occur if both <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified. If neither <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> nor <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified, the result of the fragment goes directly to the <code><span style="font-family: "Tahoma","sans-serif";">JspWriter</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007367"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">varReader="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1007430"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of a scoped attribute to store the result of the fragment invocation in, as a <code><span style="font-family: "Tahoma","sans-serif";">java.io.Reader</span></code> object. A translation error must occur if both <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> are specified. If neither <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> nor <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> is specified, the result of the fragment invocation goes directly to the <code><span style="font-family: "Tahoma","sans-serif";">JspWriter</span></code>. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007373"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scope="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">page</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | request | session | application" <a name="1007457"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The scope in which to store the resulting variable. A translation error must result if the value is not one of <code><span style="font-family: "Tahoma","sans-serif";">page</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">request</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">session</span></code>, or <code><span style="font-family: "Tahoma","sans-serif";">application</span></code>. A translation error will result if this attribute appears without specifying either the <code><span style="font-family: "Tahoma","sans-serif";">var</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">varReader</span></code> attribute as well. Note that a value of session should be used with caution since not all calling pages may be participating in a session. A container must throw an <code><span style="font-family: "Tahoma","sans-serif";">IllegalStateException</span></code> at runtime if scope is <code><span style="font-family: "Tahoma","sans-serif";">session</span></code> and the calling page does not participate in a session. Defaults to <code><span style="font-family: "Tahoma","sans-serif";">page.var="</span></code><em><span style="font-family: "Tahoma","sans-serif";">scopedAttributeName</span></em><code><span style="font-family: "Tahoma","sans-serif";">"</span></code>. <o:p></o:p></span></p> <h4><a name="1003634"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003635"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref208.html#997991">Attribute Directive</a> <a name="1012943"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2013.html#15694">Variable Directive</a> <a name="1012947"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2014.html#1003424"><jsp:attribute></a><o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:output><o:p></o:p></span></h2> <p><a name="1007492"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Specifies the XML declaration or the document type declaration in the request output of a JSP document or a tag file that is in XML syntax. <o:p></o:p></span></p> <h4><a name="1005353"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:output declaration="yes|no|true|false" style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> { doctypeDecl } /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> doctypeDecl ::= ( doctype-root-element="<em><span style="font-family: "Tahoma","sans-serif";">rootElement</span></em>"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> doctype-public="<em><span style="font-family: "Tahoma","sans-serif";">PubidLiteral</span></em>"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> doctype-system="<em><span style="font-family: "Tahoma","sans-serif";">SystemLiteral</span></em>" )<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> | ( doctype-root-element="<em><span style="font-family: "Tahoma","sans-serif";">rootElement</span></em>"<span style=""> </span><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> doctype-system="<em><span style="font-family: "Tahoma","sans-serif";">SystemLiteral</span></em>" )<o:p></o:p></span></pre> <h4><a name="1005361"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <p><a name="1007641"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here is an example of specifying a document type declaration with jsp:output: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:output element="books" style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> doctype-system="books.dtd" /> <o:p></o:p></span></pre> <p><a name="1007646"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The resulting output is: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><!DOCTYPE books SYSTEM "books.dtd" > <o:p></o:p></span></pre> <h4><a name="1005366"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1007615"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:output</span></code> element specifies the XML declaration or the document type declaration in the request output of the JSP document. <o:p></o:p></span></p> <p><a name="1007637"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The XML declaration and document type declaration that are declared by the <code><span style="font-family: "Tahoma","sans-serif";">jsp:output</span></code> element are not interpreted by the JSP container. Instead, the container simply directs them to the request output. <o:p></o:p></span></p> <h5><a name="1007770"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Generating a Document Type Declaration<o:p></o:p></span></h5> <p><a name="1007829"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A document type declaration (DTD) defines the structural rules for the XML document in which the document type declaration occurs. XML documents are not required to have a DTD associated with them. <o:p></o:p></span></p> <p><a name="1007628"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Specifying the document type declaration in the jsp:output element will not cause the JSP container to validate the JSP document against the DTD. <o:p></o:p></span></p> <p><a name="1007630"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If you want the JSP document to be validated against the DTD, you must manually include the document type declaration within the JSP document, just as you would with any XML document. <o:p></o:p></span></p> <h5><a name="1007667"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Generating XML Declarations<o:p></o:p></span></h5> <p><a name="1007669"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here is an example of an XML declaration: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><?xml version="1.0" encoding="UTF-8" ?> <o:p></o:p></span></pre> <p><a name="1007673"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This declaration is the default XML declaration. It means that if the JSP container is generating an XML declaration, this is what the JSP container will include in the output of your JSP document. <o:p></o:p></span></p> <p><a name="1007675"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Neither a JSP document nor its request output is required to have an XML declaration. In fact, if the JSP document is not producing XML output then it shouldn't have an XML declaration. <o:p></o:p></span></p> <p><a name="1007677"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP container will not include the XML declaration in the output when either of the following is true: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007679"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You set the <code><span style="font-family: "Tahoma","sans-serif";">omit-xml-declaration</span></code> attribute of the <code><span style="font-family: "Tahoma","sans-serif";">jsp:output</span></code> element to either <code><span style="font-family: "Tahoma","sans-serif";">true</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">yes</span></code>. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1007680"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You have a <code><span style="font-family: "Tahoma","sans-serif";">jsp:root</span></code> element in your JSP document, and you do not specify <code><span style="font-family: "Tahoma","sans-serif";">omit-xml-declaration="</span></code><em><span style="font-family: "Tahoma","sans-serif";">false</span></em><code><span style="font-family: "Tahoma","sans-serif";">"</span></code> in <code><span style="font-family: "Tahoma","sans-serif";">jsp:output</span></code>.<o:p></o:p></span></li></ul> <p><a name="1007682"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The JSP container will include the XML declaration in the output when either of the following is true: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007684"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You set the <code><span style="font-family: "Tahoma","sans-serif";">omit-xml-declaration</span></code> attribute of the <code><span style="font-family: "Tahoma","sans-serif";">jsp:output</span></code> element to either <code><span style="font-family: "Tahoma","sans-serif";">false</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">no</span></code>. <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1007685"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You do not have a <code><span style="font-family: "Tahoma","sans-serif";">jsp:root</span></code> action in your JSP document, and you do not specify the <code><span style="font-family: "Tahoma","sans-serif";">omit-xml-declaration</span></code> attribute in <code><span style="font-family: "Tahoma","sans-serif";">jsp:output</span></code>.<o:p></o:p></span></li></ul> <p><a name="1007694"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:output</span></code> element has three attributes that you use to generate the document type declaration: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007696"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doctype-root-element</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Indicates the root element of the XML document <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1007697"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doctype-system</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Indicates the URI reference to the DTD<a name="1007698"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doctype-public</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: A more flexible way to reference the DTD. This identifier gives more information about the DTD without giving a specific location. A public identifier resolves to the same actual document on any system even though the location of that document on each system may vary. See the XML 1.0 specification for more information.<o:p></o:p></span></li></ul> <p><a name="1007700"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The rules for using the attributes are as follows: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007702"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The doctype attributes can appear in any order <o:p></o:p></span></li></ul> <ul type="disc"><li class="MsoNormal" style="margin-bottom: 12pt;"><a name="1007703"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">doctype-root</span></code> attribute must be specified if the <code><span style="font-family: "Tahoma","sans-serif";">doctype-system</span></code> attribute is specified<a name="1007704"></a><o:p></o:p></span></li><li class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">doctype-public attribute</span></code> must not be specified unless <code><span style="font-family: "Tahoma","sans-serif";">doctype-system</span></code> is specified<o:p></o:p></span></li></ul> <h4><a name="1007519"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1007525"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">omit-xml-declaration="yes | no | true | false"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1007539"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Indicates whether to omit the generation of an XML declaration. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007528"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doctype-root-element="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">rootElement</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1007540"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Must be specified if and only if doctype-system is specified or a translation error must occur. Indicates the name that is to be output in the generated DOCTYPE declaration. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007532"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doctype-system="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">SystemLiteral</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1007541"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Specifies that a DOCTYPE declaration is to be generated and gives the value for the System Literal. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1007534"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doctype-public="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">PubidLiteral</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><a name="1007542"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Must not be specified unless doctype-system is specified. Gives the value for the Public ID for the generated DOCTYPE. <o:p></o:p></span></p> <h4><a name="1007521"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1012930"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2024.html#1003283"><jsp:root></a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:plugin><o:p></o:p></span></h2> <p><a name="1004159"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Causes the execution of an applet or bean. The applet or bean executes in the specified plugin. If the plugin is not available, displays a dialog to initiate the download of the plugin software. <o:p></o:p></span></p> <h4><a name="9244"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><jsp:plugin<span style=""> </span><o:p></o:p></span></code></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">type="bean|applet"<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">code="</span></code><em><span style="font-family: "Tahoma","sans-serif";">classFileName</span></em><code><span style="font-family: "Tahoma","sans-serif";">"<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">codebase="</span></code><em><span style="font-family: "Tahoma","sans-serif";">classFileDirectoryName</span></em><code><span style="font-family: "Tahoma","sans-serif";">"<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ name="</span></code><em><span style="font-family: "Tahoma","sans-serif";">instanceName</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ archive="</span></code><em><span style="font-family: "Tahoma","sans-serif";">URIToArchive</span></em><code><span style="font-family: "Tahoma","sans-serif";">, ..." ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ align="</span></code><strong><span style="font-family: "Tahoma","sans-serif";">bottom</span></strong><code><span style="font-family: "Tahoma","sans-serif";">|top|middle|left|right" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ height="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">displayPixels</span></em><code><span style="font-family: "Tahoma","sans-serif";"> </span></code>|<span style=""> </span><%= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %>}"]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ width="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">displayPixels</span></em><code><span style="font-family: "Tahoma","sans-serif";"> </span></code>|<span style=""> </span><%= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %>}"]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ hspace="</span></code><em><span style="font-family: "Tahoma","sans-serif";">leftRightPixels</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ vspace="</span></code><em><span style="font-family: "Tahoma","sans-serif";">topBottomPixels</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ jreversion="</span></code><em><span style="font-family: "Tahoma","sans-serif";">JREVersionNumber</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | </span></code><strong><span style="font-family: "Tahoma","sans-serif";">1.2</span></strong><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ nspluginurl="</span></code><em><span style="font-family: "Tahoma","sans-serif";">URLToPlugin</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ iepluginurl="</span></code><em><span style="font-family: "Tahoma","sans-serif";">URLToPlugin</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ] ><span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ <jsp:params><span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ <jsp:param name=""></code><em><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em><code><span style="font-family: "Tahoma","sans-serif";">"<span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> value="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">parameterValue</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | '${' Expression '}' | <span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> <%= </span></code><em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> %>}" /> ]+<span style=""> </span><o:p></o:p></span></code></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";"></jsp:params> ]<span style=""> </span><o:p></o:p></span></code></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ <jsp:fallback> </span></code>text message if plugin download fails <span style=""> </span><o:p></o:p></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> </jsp:fallback> ]<span style=""> </span><o:p></o:p></span></code></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"></jsp:plugin><o:p></o:p></span></code></pre> <h4><a name="998648"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:plugin<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> type="bean|applet"<span style=""> </span>code="<em><span style="font-family: "Tahoma","sans-serif";">classFileName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> codebase="<em><span style="font-family: "Tahoma","sans-serif";">classFileDirectoryName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ name="<em><span style="font-family: "Tahoma","sans-serif";">instanceName</span></em>" ]<span style=""> </span>[ archive="<em><span style="font-family: "Tahoma","sans-serif";">URIToArchive</span></em>, ..." ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ align="<strong><span style="font-family: "Tahoma","sans-serif";">bottom</span></strong>|top|middle|left|right" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ height="{<em><span style="font-family: "Tahoma","sans-serif";">displayPixels</span></em> | '${' Expression '}' | %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %}" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ width="{<em><span style="font-family: "Tahoma","sans-serif";">displayPixels</span></em> | '${' Expression '}' | %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %}"]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ hspace="<em><span style="font-family: "Tahoma","sans-serif";">leftRightPixels</span></em>" ]<span style=""> </span>[ vspace="<em><span style="font-family: "Tahoma","sans-serif";">topBottomPixels</span></em>" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ jreversion="<em><span style="font-family: "Tahoma","sans-serif";">JREVersionNumber</span></em> | 1.2" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ nspluginurl="<em><span style="font-family: "Tahoma","sans-serif";">URLToPlugin</span></em>" ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ iepluginurl="<em><span style="font-family: "Tahoma","sans-serif";">URLToPlugin</span></em>" ]<span style=""> </span>><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ <jsp:params><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ <jsp:param name=""><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> value="{<em><span style="font-family: "Tahoma","sans-serif";">parameterValue</span></em> | '${' Expression '}' | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %}" /> ]+<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> </jsp:params> ]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ <jsp:fallback><span style=""> </span>text message if plugin download fails<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> </jsp:fallback><span style=""> </span>]<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:plugin><o:p></o:p></span></pre> <h4><a name="9248"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:plugin type="applet" code="Molecule.class" codebase="/html"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:params><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:param name="molecule" value="molecules/benzene.mol"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> </jsp:params><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:fallback><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <p>Unable to load applet</p><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> </jsp:fallback><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:plugin><o:p></o:p></span></pre> <h4><a name="9252"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="9253"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:plugin</span></code> element plays or displays an object (typically an applet or bean) in the client web browser, using a Java plug-in that is built in to the browser or downloaded from a specified URL. <o:p></o:p></span></p> <p><a name="18976"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">When the JSP page is translated and compiled and Java and sends back an HTML response to the client, the <code><span style="font-family: "Tahoma","sans-serif";">jsp:plugin</span></code> element is replaced by either an <code><span style="font-family: "Tahoma","sans-serif";"><object></span></code> or <code><span style="font-family: "Tahoma","sans-serif";"><embed></span></code> element, according to the browser version. The <code><span style="font-family: "Tahoma","sans-serif";"><object></span></code> element is defined in HTML 4.0 and <code><span style="font-family: "Tahoma","sans-serif";"><embed></span></code> in HTML 3.2. <o:p></o:p></span></p> <p><a name="18961"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In general, the attributes to the <code><span style="font-family: "Tahoma","sans-serif";">jsp:plugin</span></code> element specify whether the object is a bean or an applet, locate the code that will be run, position the object in the browser window, specify an URL from which to download the plug-in software, and pass parameter names and values to the object. The attributes are described in detail in the next section. <o:p></o:p></span></p> <h4><a name="10937"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="10935"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">type="bean|applet"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="11588"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The type of object the plug-in will execute. You must specify either <code><span style="font-family: "Tahoma","sans-serif";">bean</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">applet</span></code>, as this attribute has no default value. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11514"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">code="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">classFileName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="11676"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of the Java class file the plug-in will execute. You must include the <code><span style="font-family: "Tahoma","sans-serif";">.class</span></code> extension in the name. The class file you specify should be in the directory named in the <code><span style="font-family: "Tahoma","sans-serif";">codebase</span></code> attribute. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11515"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">codebase="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">classFileDirectoryName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="11677"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The directory (or path to the directory) that contains the Java class file the plug-in will execute. If you do not supply a value, the path of the JSP page that calls <code><span style="font-family: "Tahoma","sans-serif";">jsp:plugin</span></code> is used. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11547"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">instanceName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="11678"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A name for the instance of the bean or applet, which makes it possible for applets or Beans called by the same JSP page to communicate with each other. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11553"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">archive="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">URIToArchive</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">, ..."</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="11679"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A comma-separated list of pathnames that locate archive files that will be preloaded with a class loader located in the directory named in <code><span style="font-family: "Tahoma","sans-serif";">codebase</span></code>. The archive files are loaded securely, often over a network, and typically improve the applet's performance. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11516"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">align="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">bottom</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">|top|middle|left|right" <a name="11680"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The position of the image, object, or applet. The position descriptions listed below use the term <em><span style="font-family: "Tahoma","sans-serif";">text line</span></em> to mean the line in the viewable JSP page that corresponds to the line in the JSP page where the <code><span style="font-family: "Tahoma","sans-serif";">jsp:plugin</span></code> element appears. The allowed values for <code><span style="font-family: "Tahoma","sans-serif";">align</span></code> are listed below: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="11699"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">bottom</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Aligns the bottom of the image with the baseline of the text line. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="11700"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">top</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Aligns the top of the image with the top of the text line. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="11701"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">middle</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Aligns the vertical center of the image with the baseline of the text line. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="11702"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">left</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Floats the image to the left margin and flows text along the image's right side. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="11703"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">right</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Floats the image to the right margin and flows text along the image's left side. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11518"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">height="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">displayPixels</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> </span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">| <%= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %>}" width="{<em><span style="font-family: "Tahoma","sans-serif";">displayPixels</span></em> | <%= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %>}" <a name="11681"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The initial height and width, in pixels, of the image the applet or bean displays, not counting any windows or dialog boxes the applet or bean brings up. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11568"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">hspace="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">leftRightPixels</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" vspace="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">topBottomPixels</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" </span></code><a name="11706"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The amount of space, in pixels, to the left and right (or top and bottom) of the image the applet or bean displays. The value must be a nonzero number. Note that hspace creates space to both the left <em><span style="font-family: "Tahoma","sans-serif";">and</span></em> right and vspace creates space to both the top <em><span style="font-family: "Tahoma","sans-serif";">and</span></em> bottom. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11520"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">jreversion="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JREVersionNumber</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | </span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">1.2</span></strong><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" </span></code><a name="11685"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The version of the Java Runtime Environment (JRE) the applet or bean requires. The default value is 1.2. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11525"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">nspluginurl="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">URLToPlugin</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="11686"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The URL where the user can download the JRE plug-in for Netscape Navigator. The value is a full URL, with a protocol name, optional port number, and domain name. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11526"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ie</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">pluginurl="<em><span style="font-family: "Tahoma","sans-serif";">URLToPlugin</span></em>" <a name="11687"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The URL where the user can download the JRE plug-in for Internet Explorer. The value is a full URL, with a protocol name, optional port number, and domain name. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11538"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:params> [ <jsp:param name=""></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">parameterName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";">value="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">parameterValue</span></em><code><span style="font-family: "Tahoma","sans-serif";"> | <%= </span></code><em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> %>}" /> ]+ </jsp:params> </span></code><a name="11688"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The parameters and values that you want to pass to the applet or bean. To specify more than one parameter value, you can use more than one <code><span style="font-family: "Tahoma","sans-serif";">jsp:param</span></code> element within the <code><span style="font-family: "Tahoma","sans-serif";">jsp:params</span></code> element. The <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> attribute specifies the parameter name and takes a case-sensitive literal string. The <code><span style="font-family: "Tahoma","sans-serif";">value</span></code> attribute specifies the parameter value and takes either a case-sensitive literal string or an expression that is evaluated at runtime. If the dynamic resource you are passing the parameter to is an applet, it reads the parameter with the <code><span style="font-family: "Tahoma","sans-serif";">java.applet.Applet.getParameter</span></code> method. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11583"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:fallback> </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">text message for user</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> </jsp:fallback></span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="11691"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A text message to display for the user if the plug-in cannot be started. If the plug-in starts but the applet or bean does not, the plug-in usually displays a popup window explaining the error to the user. <o:p></o:p></span></p> <h4><a name="19029"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="19035"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The HTML 3.2 specification: <a href="http://www.w3.org/TR/REC-html32.html">http://www.w3.org/TR/REC-html32.html</a> <a name="19036"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The HTML 4.0 specification: <a href="http://www.w3.org/TR/REC-html40">http://www.w3.org/TR/REC-html40/</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></code></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:root><o:p></o:p></span></h2> <p><a name="1003284"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines standard JSP elements and namespace attributes of tag libraries. <o:p></o:p></span></p> <h4><a name="1003285"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <p><a name="1003289"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">None. However, see <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2012.html#1003416">Taglib Directive</a>. <o:p></o:p></span></p> <h4><a name="1003290"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:root<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> xmlns:jsp="http://java.sun.com/JSP/Page"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> [ xmlns:taglibPrefix="<em><span style="font-family: "Tahoma","sans-serif";">URI</span></em>" ]+ ...<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> version="1.2 | 2.0"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> JSP Page<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:root><o:p></o:p></span></pre> <h4><a name="1003292"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Example<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:root style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> xmlns:jsp="http://java.sun.com/JSP/Page"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> xmlns:public="http://www.jspcentral.com/tags" <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> version="2.0"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <public:loop><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> ...<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> </public:loop><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:root><o:p></o:p></span></pre> <h4><a name="1003294"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1003295"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A JSP page in XML syntax can have <code><span style="font-family: "Tahoma","sans-serif";">jsp:root</span></code> as its root element, but it is not required. You can instead specify your own tag as a root element. Tag libraries used within the JSP page can be represented in the root element through <code><span style="font-family: "Tahoma","sans-serif";">xmlns</span></code> attributes. (Again, you can use the <code><span style="font-family: "Tahoma","sans-serif";">xmlns</span></code> attributes in other tags besides the <code><span style="font-family: "Tahoma","sans-serif";">jsp:root</span></code> element. The <code><span style="font-family: "Tahoma","sans-serif";">xmlns:jsp</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">version</span></code> attributes are mandatory. <o:p></o:p></span></p> <h4><a name="1003296"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003297"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">xmlns:jsp="http://java.sun.com/JSP/Page"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1003298"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Enables the use of the standard elements defined in the JSP specification. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1003299"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">version="1.2 | 2.0"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1003300"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Specifies the version of the JSP specification the page is using. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1003301"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">xmlns:taglibPrefix="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">URI</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1003302"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Specifies a tag library prefix and URI. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1003303"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">taglibPrefix precedes the custom tag name, for example, <code><span style="font-family: "Tahoma","sans-serif";">public</span></code> in <code><span style="font-family: "Tahoma","sans-serif";"><public:loop></span></code>. Empty prefixes are illegal. If you are developing or using custom tags, you cannot use the tag prefixes <code><span style="font-family: "Tahoma","sans-serif";">jsp</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">jspx</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">java</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">javax</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">servlet</span></code>, <code><span style="font-family: "Tahoma","sans-serif";">sun</span></code>, and <code><span style="font-family: "Tahoma","sans-serif";">sunw</span></code>, as they are reserved by Sun Microsystems. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1003304"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">URI uniquely locates the TLD that describes the set of custom tags associated with the named prefix. URI may be of one of two forms: <o:p></o:p></span></p> <ul type="disc"><ul type="circle"><li class="MsoNormal" style=""><a name="1003305"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A URI: <o:p></o:p></span></li><ul type="square"><li class="MsoNormal" style=""><a name="1003307"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A Uniform Resource Locator (URL), as defined in RFC 2396, available at <a href="http://www.rfc-editor.org/rfc/rfc2396.txt">http://www.rfc-editor.org/rfc/rfc2396.txt</a> <a name="1003308"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A Uniform Resource Name (URN), as defined in RFC 2396 <o:p></o:p></span></li></ul><li class="MsoNormal" style=""><a name="1003309"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">urn:jsptld:</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">path</span></em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">. <o:p></o:p></span></li></ul></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="1003310"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the URI is a URI, then the TLD is located by consulting the mapping indicated in <code><span style="font-family: "Tahoma","sans-serif";">web.xml</span></code> extended using the implicit maps in the packaged tag libraries. If URI is of the form <code><span style="font-family: "Tahoma","sans-serif";">urn:jsptld:</span></code>path, path is interpreted relative to the root of the web application and should resolve to a TLD file directly, or to a JAR file that has a TLD file at location <code><span style="font-family: "Tahoma","sans-serif";">META-INF/taglib.tld</span></code>. <o:p></o:p></span></p> <h4><a name="1003311"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="1003315"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2012.html#1003416">Taglib Directive</a> <o:p></o:p></span></li></ul> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:setproperty><o:p></o:p></span></h2> <p><a name="9866"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Sets a property value or values in a bean. <o:p></o:p></span></p> <h4><a name="9318"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><jsp:setproperty name=""></code><em><span style="font-family: "Tahoma","sans-serif";">beanInstanceName</span></em><code><span style="font-family: "Tahoma","sans-serif";">"<span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";">{ <span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> property="*" |<span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> property="</span></code><em><span style="font-family: "Tahoma","sans-serif";">propertyName</span></em><code><span style="font-family: "Tahoma","sans-serif";">"</span></code><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">[ param="</span></code><em><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em>" ]<code><span style="font-family: "Tahoma","sans-serif";"> |<span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> property="</span></code><em><span style="font-family: "Tahoma","sans-serif";">propertyName</span></em><code><span style="font-family: "Tahoma","sans-serif";">" value="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">stringLiteral</span></em><code><span style="font-family: "Tahoma","sans-serif";">| <span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> '${' </span></code><em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> '}' | <%= </span></code><em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">%>}"<span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";">}<span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";">/><o:p></o:p></span></code></pre> <h4><a name="998744"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:setproperty name=""><span style="font-family: "Tahoma","sans-serif";">beanInstanceName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">{ <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> property="*" |<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> property="<em><span style="font-family: "Tahoma","sans-serif";">propertyName</span></em>" [ param="<em><span style="font-family: "Tahoma","sans-serif";">parameterName</span></em>" ] |<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> property="<em><span style="font-family: "Tahoma","sans-serif";">propertyName</span></em>" value="{<em><span style="font-family: "Tahoma","sans-serif";">stringLiteral</span></em> | <span style=""> </span><o:p></o:p></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> '${' </span></code><em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em><code><span style="font-family: "Tahoma","sans-serif";"> '}' | </span></code><span style="font-family: "Tahoma","sans-serif";">%= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %}" <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">}<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">/><o:p></o:p></span></pre> <h4><a name="16463"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:setproperty name="mybean" property="*"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:setproperty name="mybean" property="username"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:setproperty name="mybean" property="username" value="Steve"><o:p></o:p></span></pre> <h4><a name="17957"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="11919"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> element sets the value of one or more properties in a bean, using the bean's setter methods. You must declare the bean with <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2027.html#8865"><jsp:usebean></a> <em><span style="font-family: "Tahoma","sans-serif";">before</span></em> you set a property value with <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code>. Because <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> work together, the bean instance names they use must match (that is, the value of <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> in <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> and the value of <code><span style="font-family: "Tahoma","sans-serif";">id</span></code> in <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> must be the same). <o:p></o:p></span></p> <p><a name="9936"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can use <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> to set property values in several ways: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="11925"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">By passing all of the values the user enters (stored as parameters in the <code><span style="font-family: "Tahoma","sans-serif";">request</span></code> object) to matching properties in the bean <a name="17411"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">By passing a specific value the user enters to a specific property in the bean <a name="19153"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">By setting a bean property to a value you specify as either a <code><span style="font-family: "Tahoma","sans-serif";">String</span></code> or an expression that is evaluated at runtime <o:p></o:p></span></li></ul> <p><a name="17620"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Each method of setting property values has its own syntax, as described in the next section. <o:p></o:p></span></p> <h4><a name="18217"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes and Usage<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="17612"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">beanInstanceName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="17613"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of an instance of a bean that has already been created or located with a <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element. The value of <code><span style="font-family: "Tahoma","sans-serif";">name</span></code> must match the value of <code><span style="font-family: "Tahoma","sans-serif";">id</span></code> in <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code>. The <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element must appear before <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> in the JSP page. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="1001786"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">property="*"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="1001787"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Stores all of the values of request parameters in bean properties. The names of the bean properties must match the names of the request parameters. A bean property is usually defined by a variable declaration with matching getter and setter methods (for more information, see <em><span style="font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/javabeans/docs/"></a></span></em>http://java.sun.com/products/javabeans/docs/). <o:p></o:p></span></p> <p><a name="999493"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The values of the request parameters sent from the client to the server are always of type <code><span style="font-family: "Tahoma","sans-serif";">String</span></code>. The <code><span style="font-family: "Tahoma","sans-serif";">String</span></code> values are converted to other data types when stored in bean properties. If a property has a <code><span style="font-family: "Tahoma","sans-serif";">PropertyEditor</span></code> class as indicated in the JavaBeans specification, the <code><span style="font-family: "Tahoma","sans-serif";">setAsText(String)</span></code> method is used. A conversion failure arises if the method throws an <code><span style="font-family: "Tahoma","sans-serif";">IllegalArgumentException</span></code>. The allowed bean property types and their conversion methods are shown in <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#17460">TABLE 2</a>. <o:p></o:p></span></p> <div align="center"> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td colspan="2" style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><a name="17460"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">How jsp:setProperty Converts Strings to Other Values<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">TABLE 2 </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p style="text-align: center;" align="center"><a name="17464"></a><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Property Type <o:p></o:p></span></b></p> </td> <td style="padding: 0.75pt;"> <p style="text-align: center;" align="center"><a name="17466"></a><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">String Is Converted Using <o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="999521"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Bean Property <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="999510"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Use setAsText(<em><span style="font-family: "Tahoma","sans-serif";">stringLiteral</span></em>) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="17468"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">boolean or Boolean <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="17470"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.Boolean.valueOf(String) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="17472"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">byte or Byte <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="17474"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.Byte.valueOf(String) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="17476"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">char or Character <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="17478"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.String.charAt(0) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="17480"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">double or Double <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="17482"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.Double.valueOf(String) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="17484"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">integer or Integer <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="17486"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.Integer.valueOf(String) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="17488"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">float or Float <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="17490"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.Float.valueOf(String) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="17492"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">long or Long <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="17494"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.Long.valueOf(String) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="999489"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">short or Short <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="999491"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.lang.Short.valueOf(String) <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p><a name="999390"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Object <o:p></o:p></span></p> </td> <td style="padding: 0.75pt;"> <p><a name="999392"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">new String(string-literal) <o:p></o:p></span></p> </td> </tr> </tbody></table> </div> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; display: none;"><o:p> </o:p></span></p> <div align="center"> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> </td> </tr> </tbody></table> </div> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="9965"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can also use <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> to set the value of an indexed property in a bean. The indexed property must be an array of one of the data types shown in <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#17460">TABLE 2</a>. The array elements are converted using the conversion methods shown in the table. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="17509"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If a request parameter has an empty or null value, the corresponding bean property is not set. Likewise, if the bean has a property that does not have a matching request parameter, the property value is not set. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="9919"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">property="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">propertyName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" [ param="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">parameterName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" ]</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="9934"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Sets one bean property to the value of one request parameter. In the syntax, <code><span style="font-family: "Tahoma","sans-serif";">property</span></code> specifies the name of the bean property and <code><span style="font-family: "Tahoma","sans-serif";">param</span></code> specifies the name of the request parameter by which data is being sent from the client to the server. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="19208"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the bean property and the request parameter have different names, you must specify both <code><span style="font-family: "Tahoma","sans-serif";">property</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">param</span></code>. If they have the same name, you can specify <code><span style="font-family: "Tahoma","sans-serif";">property</span></code> and omit <code><span style="font-family: "Tahoma","sans-serif";">param</span></code>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="20482"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If a parameter has an empty or null value, the corresponding bean property is not set. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="20483"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">property="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">propertyName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" value="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">string</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | <%= </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> %>}"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="20484"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Sets one bean property to a specific value. The value can be a <code><span style="font-family: "Tahoma","sans-serif";">String</span></code> or an expression that is evaluated at runtime. If the value is a <code><span style="font-family: "Tahoma","sans-serif";">String</span></code>, it is converted to the bean property's data type according to the conversion rules shown above in <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#17460">TABLE 2</a>. If it is an expression, its value must have a data type that matches the data type of the value of the expression must match the data type of the bean property. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="10088"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the parameter has an empty or null value, the corresponding bean property is not set. You cannot use both the <code><span style="font-family: "Tahoma","sans-serif";">param</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">value</span></code> attributes in a <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> element. <o:p></o:p></span></p> <h4><a name="9329"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="9330"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2027.html#8865"><jsp:usebean></a> <a name="9331"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2019.html#8820"><jsp:getproperty></a> <o:p></o:p></span></li></ul> <h4><a name="19189"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tip<o:p></o:p></span></h4> <p><a name="19199"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">When you use <code><span style="font-family: "Tahoma","sans-serif";">property="*"</span></code>, the bean properties are not necessarily set in the order in which they appear in the HTML form or the bean. If the order in which the properties are set is important to how your bean works, use the syntax form <code><span style="font-family: "Tahoma","sans-serif";">property="</span></code>propertyName<code><span style="font-family: "Tahoma","sans-serif";">"</span></code> <code><span style="font-family: "Tahoma","sans-serif";">[ param="</span></code>parameterName<code><span style="font-family: "Tahoma","sans-serif";">" ]</span></code>. Better yet, rewrite your bean so that the order of setting properties is not important. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:text><o:p></o:p></span></h2> <p><a name="1003323"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Encloses template data. <o:p></o:p></span></p> <h4><a name="1003324"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:text><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <em><span style="font-family: "Tahoma","sans-serif";">template data</span></em><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:text><o:p></o:p></span></pre> <h4><a name="1003326"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:text><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <em><span style="font-family: "Tahoma","sans-serif";">template data</span></em><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:text><o:p></o:p></span></pre> <h4><a name="1003328"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Example<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><hello><jsp:scriptlet>i=3;</jsp:scriptlet><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><hi><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:text> hi you all<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:text><jsp:expression>i</jsp:expression><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></hi><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></hello><o:p></o:p></span></pre> <p><a name="1003330"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The output is: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><hello> <hi> hi you all<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></hi></hello><o:p></o:p></span></pre> <h4><a name="1003332"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="1003333"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A <code><span style="font-family: "Tahoma","sans-serif";">jsp:text</span></code> element is used to enclose template data in the XML representation. A<code><span style="font-family: "Tahoma","sans-serif";"> jsp:text</span></code> element has no attributes and can appear anywhere that template data can. The interpretation of a <code><span style="font-family: "Tahoma","sans-serif";">jsp:text</span></code> element is to pass its content through to the current value of <code><span style="font-family: "Tahoma","sans-serif";">out</span></code>. <o:p></o:p></span></p> <p><a name="1003334"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML syntax allows an XML element that does not represent a standard or custom action to appear anywhere a <code><span style="font-family: "Tahoma","sans-serif";">jsp:text</span></code> can appear. Such an element is passed to the current out. <o:p></o:p></span></p> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <hr align="center" size="2" width="100%"> </span></div> <h2><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><jsp:usebean><o:p></o:p></span></h2> <p><a name="9807"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Locates or instantiates a bean with a specific name and scope. <o:p></o:p></span></p> <h4><a name="9348"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">JSP Syntax<o:p></o:p></span></h4> <pre><code><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean id=""></code><em><span style="font-family: "Tahoma","sans-serif";">beanInstanceName</span></em><code><span style="font-family: "Tahoma","sans-serif";">"<span style=""> </span><o:p></o:p></span></code></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">scope="</span></code><strong><span style="font-family: "Tahoma","sans-serif";">page</span></strong><code><span style="font-family: "Tahoma","sans-serif";">|request|session|application"<span style=""> </span><o:p></o:p></span></code></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";">{<span style=""> </span><o:p></o:p></span></code></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> class="</span></code><em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-family: "Tahoma","sans-serif";">" [ type="</span></code><em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-family: "Tahoma","sans-serif";">" ]|<span style=""> </span><o:p></o:p></span></code></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">beanName="{</span></code><em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em> <code><span style="font-family: "Tahoma","sans-serif";">|</span></code> '${' <em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em> '}' | <span style=""> </span><o:p></o:p></span></pre><pre><code><span style="font-family: "Tahoma","sans-serif";"> <%= </span></code><em><span style="font-family: "Tahoma","sans-serif";">expression</span></em><span style="font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">%>}" type="</span></code><em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em>" | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> type="package.class"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">}<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">{ <code><span style="font-family: "Tahoma","sans-serif";">/> | > </span></code>other elements<code><span style="font-family: "Tahoma","sans-serif";"> </jsp:useBean> }<o:p></o:p></span></code></span></pre> <h4><a name="998828"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">XML Syntax<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean id=""><span style="font-family: "Tahoma","sans-serif";">beanInstanceName</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> scope="<strong><span style="font-family: "Tahoma","sans-serif";">page</span></strong>|request|session|application"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">{<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> class="<em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em>"<span style=""> </span>[ type="<em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em>" ]<span style=""> </span>|<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> beanName="{<em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em> <code><span style="font-family: "Tahoma","sans-serif";">|</span></code> '${' <em><span style="font-family: "Tahoma","sans-serif";">Expression</span></em> '}' | <span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> %= <em><span style="font-family: "Tahoma","sans-serif";">expression</span></em> %}" type="<em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em>" |<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> type="<em><span style="font-family: "Tahoma","sans-serif";">package.class</span></em>"<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">}<span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">{ /> | > other elements </jsp:useBean><span style=""> </span>}<o:p></o:p></span></pre> <h4><a name="16474"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Examples<o:p></o:p></span></h4> <pre><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean id="cart" scope="session" class="session.Carts"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:setproperty name="cart" property="*"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean id="checking" scope="session" class="bank.Checking"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <jsp:setproperty name="checking" property="balance" value="0.0"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></jsp:useBean><o:p></o:p></span></pre> <h4><a name="9356"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description<o:p></o:p></span></h4> <p><a name="11782"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <code><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean></span></code> element locates or instantiates a JavaBeans component. <code><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean></span></code> first attempts to locate an instance of the bean. If the bean does not exist, <code><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean></span></code> instantiates it from a class or serialized template. <o:p></o:p></span></p> <p><a name="1003204"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To locate or instantiate the bean, <code><span style="font-family: "Tahoma","sans-serif";"><jsp:usebean></span></code> takes the following steps, in this order: <o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><a name="1003205"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attempts to locate a bean with the scope and name you specify. <a name="1003206"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defines an object reference variable with the name you specify. <a name="9839"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If it finds the bean, stores a reference to it in the variable. If you specified <code><span style="font-family: "Tahoma","sans-serif";">type</span></code>, gives the bean that type. <a name="9840"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If it does not find the bean, instantiates it from the class you specify, storing a reference to it in the new variable. If the class name represents a serialized template, the bean is instantiated by <code><span style="font-family: "Tahoma","sans-serif";">java.beans.Beans.instantiate</span></code>. <a name="9843"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> has <em><span style="font-family: "Tahoma","sans-serif";">instantiated</span></em> (rather than located) the bean, and if it has body tags or elements (between <<code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean></span></code> and <code><span style="font-family: "Tahoma","sans-serif";"></jsp:useBean></span></code>), executes the body tags. <o:p></o:p></span></li></ol> <p><a name="18117"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The body of a <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element often contains a <code><span style="font-family: "Tahoma","sans-serif";">jsp:setProperty</span></code> element that sets property values in the bean. As described in <a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2027.html#9843">Step 5</a>, the body tags are only processed if <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> instantiates the bean. If the bean already exists and <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> locates it, the body tags have no effect. <o:p></o:p></span></p> <p><a name="15594"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can use a <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element to locate or instantiate a JavaBeans component, but not an enterprise bean. To create enterprise beans, you can write a <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element that calls a bean that in turn calls the enterprise bean, or you can write a custom tag that calls an enterprise bean directly. <o:p></o:p></span></p> <h4><a name="10963"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes and Usage<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="10964"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">id="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">beanInstanceName</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="10965"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A variable that identifies the bean in the scope you specify. You can use the variable name in expressions or scriptlets in the JSP page. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18001"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name is case sensitive and must conform to the naming conventions of the scripting language used in the JSP page. If you use the Java programming language, the conventions in the <em><span style="font-family: "Tahoma","sans-serif";">Java Language Specification</span></em>. If the bean has already been created by another <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element, the value of <code><span style="font-family: "Tahoma","sans-serif";">id</span></code> must match the value of <code><span style="font-family: "Tahoma","sans-serif";">id</span></code> used in the original <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="10966"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">scope="</span></code><strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">page</span></strong><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">|request|session|application" <a name="10967"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The scope in which the bean exists and the variable named in <code><span style="font-family: "Tahoma","sans-serif";">id</span></code> is available. The default value is <code><span style="font-family: "Tahoma","sans-serif";">page</span></code>. The meanings of the different scopes are shown below: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18746"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">page</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> You can use the bean within the JSP page with the <code><span style="font-family: "Tahoma","sans-serif";">jsp:useBean</span></code> element or any of the page's static include files, until the page sends a response back to the client or forwards a request to another resource. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18747"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">request</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> You can use the bean from any JSP page processing the same request, until a JSP page sends a response to the client or forwards the request to another resource. You can use the <code><span style="font-family: "Tahoma","sans-serif";">request</span></code> object to access the bean, for example, <code><span style="font-family: "Tahoma","sans-serif";">request.getAttribute(</span></code>beanInstanceName<code><span style="font-family: "Tahoma","sans-serif";">)</span></code>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18748"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">session</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> You can use the bean from any JSP page in the same session as the JSP page that created the bean. The bean exists across the entire session, and any page that participates in the session can use it. The page in which you create the bean must have a page directive with <code><span style="font-family: "Tahoma","sans-serif";">session="true"</span></code>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18749"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">application</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> You can use the bean from any JSP page in the same application as the JSP page that created the bean. The bean exists across an entire JSP application, and any page in the application can use the bean. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="10968"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">class="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="10969"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Instantiates a bean from a class, using the <code><span style="font-family: "Tahoma","sans-serif";">new</span></code> keyword and the class constructor. The class must not be abstract and must have a public, no-argument constructor. The package and class name are case sensitive. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="19433"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">type="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="19434"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the bean already exists in the scope, gives the bean a data type other than the class from which it was instantiated. The value of <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> must be a superclass of <code><span style="font-family: "Tahoma","sans-serif";">class</span></code> or an interface implemented by <code><span style="font-family: "Tahoma","sans-serif";">class</span></code>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="20059"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If you use <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> without <code><span style="font-family: "Tahoma","sans-serif";">class</span></code> or <code><span style="font-family: "Tahoma","sans-serif";">beanName</span></code>, no bean is instantiated. The package and class name are case sensitive. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="18019"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">class="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">" type="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="19417"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Instantiates a bean from the class named in <code><span style="font-family: "Tahoma","sans-serif";">class</span></code> and assigns the bean the data type you specify in <code><span style="font-family: "Tahoma","sans-serif";">type</span></code>. The value of <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> can be the same as <code><span style="font-family: "Tahoma","sans-serif";">class</span></code>, a superclass of <code><span style="font-family: "Tahoma","sans-serif";">class</span></code>, or an interface implemented by <code><span style="font-family: "Tahoma","sans-serif";">class</span></code>. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="19413"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The class you specify in <code><span style="font-family: "Tahoma","sans-serif";">class</span></code> must not be abstract and must have a public, no-argument constructor. The package and class names you use with both <code><span style="font-family: "Tahoma","sans-serif";">class</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> are case sensitive. <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><a name="15804"></a><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">beanName="{</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> | <%= </span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">expression</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> %>}" type="</span></code><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package.class</span></em><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">"</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <a name="15805"></a><o:p></o:p></span></li></ul> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Instantiates a bean from a class, a serialized template, or an expression that evaluates to a class or serialized template. When you use <code><span style="font-family: "Tahoma","sans-serif";">beanName</span></code>, the bean is instantiated by the <code><span style="font-family: "Tahoma","sans-serif";">java.beans.Beans.instantiate</span></code> method. The <code><span style="font-family: "Tahoma","sans-serif";">Beans.instantiate</span></code> method checks whether the package and class you specify represents a class or a serialized template. If they represent a serialized template, <code><span style="font-family: "Tahoma","sans-serif";">Beans.instantiate</span></code> reads the serialized form (which has a name like <code><span style="font-family: "Tahoma","sans-serif";">package.class.ser</span></code>) using a class loader. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><a name="18056"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> can be the same as <code><span style="font-family: "Tahoma","sans-serif";">beanName</span></code>, a superclass of <code><span style="font-family: "Tahoma","sans-serif";">beanName</span></code>, or an interface implemented by <code><span style="font-family: "Tahoma","sans-serif";">beanName</span></code>. The package and class names you use with both <code><span style="font-family: "Tahoma","sans-serif";">beanName</span></code> and <code><span style="font-family: "Tahoma","sans-serif";">type</span></code> are case sensitive. <o:p></o:p></span></p> <h4><a name="9359"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">See Also<o:p></o:p></span></h4> <ul type="disc"><li class="MsoNormal" style=""><a name="9360"></a><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#8856"><jsp:setproperty></a> <a name="9361"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/jsp/syntax/2.0/syntaxref2019.html#8820"><jsp:getproperty></a> <a name="1003126"></a><o:p></o:p></span></li><li class="MsoNormal" style=""><em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://java.sun.com/products/javabeans/docs/">http://java.sun.com/products/javabeans/docs/</a></span></em><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></li></ul> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-83223658601770399372009-01-02T01:50:00.000-08:002009-01-02T01:51:21.385-08:00Siege FX Reference Script Architecture/Terminology<title>Siege FX Tutorial #1</title><link href="Siege%20FX%20Reference%20-%20Terminology_files/filelist.xml" rel="File-List"><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} h1 {mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:1; font-size:16.0pt; font-family:Arial; mso-font-kerning:16.0pt;} p.MsoListBullet2, li.MsoListBullet2, div.MsoListBullet2 {mso-style-update:auto; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; text-indent:-.25in; mso-pagination:widow-orphan; mso-list:l0 level1 lfo2; tab-stops:list .5in; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoBodyText, li.MsoBodyText, div.MsoBodyText {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoBodyTextIndent, li.MsoBodyTextIndent, div.MsoBodyTextIndent {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:.25in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoListContinue2, li.MsoListContinue2, div.MsoListContinue2 {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:.5in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p.StyleArialBefore5ptAfter5pt, li.StyleArialBefore5ptAfter5pt, div.StyleArialBefore5ptAfter5pt {mso-style-name:"Style Arial Before\: 5 pt After\: 5 pt"; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt; margin-left:0in; mso-pagination:widow-orphan; font-size:10.0pt; font-family:Arial; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman";} span.SpellE {mso-style-name:""; mso-spl-e:yes;} span.GramE {mso-style-name:""; mso-gram-e:yes;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:-125; mso-list-type:simple; mso-list-template-ids:205841210;} @list l0:level1 {mso-level-number-format:bullet; mso-level-style-link:"List Bullet 2"; mso-level-text:\F0B7; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol;} @list l1 {mso-list-id:-2; mso-list-type:simple; mso-list-template-ids:572177678;} @list l1:level1 {mso-level-start-at:0; mso-level-text:*; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:0in; text-indent:0in;} @list l2 {mso-list-id:616988282; mso-list-type:hybrid; mso-list-template-ids:-487549960 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l3 {mso-list-id:666788475; mso-list-type:hybrid; mso-list-template-ids:-1698530994 1868184898 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:\F0B6; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l4 {mso-list-id:872115448; mso-list-template-ids:-487549960;} @list l4:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l4:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l4:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l4:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l4:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l4:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l4:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l4:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l4:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l5 {mso-list-id:1001858529; mso-list-type:hybrid; mso-list-template-ids:-259894358 350631756 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l5:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:22.5pt; mso-level-number-position:left; margin-left:22.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l6 {mso-list-id:1039234215; mso-list-type:hybrid; mso-list-template-ids:-446526342 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l6:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol;} @list l7 {mso-list-id:1166088963; mso-list-template-ids:705214696;} @list l7:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l7:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l7:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l7:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l7:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l7:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l7:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l7:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l7:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l8 {mso-list-id:1279751207; mso-list-template-ids:-1698530994;} @list l8:level1 {mso-level-number-format:bullet; mso-level-text:\F0B6; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l8:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l8:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l8:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l8:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l8:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l8:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l8:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l8:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l9 {mso-list-id:1592081694; mso-list-type:hybrid; mso-list-template-ids:-1191432996 1105770856 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l9:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:58.5pt; mso-level-number-position:left; margin-left:58.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l10 {mso-list-id:1615356967; mso-list-template-ids:-1698530994;} @list l10:level1 {mso-level-number-format:bullet; mso-level-text:\F0B6; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l10:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l10:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l10:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l10:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l10:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l10:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l10:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l10:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l11 {mso-list-id:1689990809; mso-list-type:hybrid; mso-list-template-ids:1654426930 1105770856 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l11:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:22.5pt; mso-level-number-position:left; margin-left:22.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l12 {mso-list-id:1835873538; mso-list-type:hybrid; mso-list-template-ids:-1977431558 -446527790 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l12:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol; color:windowtext;} @list l13 {mso-list-id:1915629704; mso-list-type:hybrid; mso-list-template-ids:705214696 1105770856 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l13:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l14 {mso-list-id:2018462080; mso-list-template-ids:-1191432996;} @list l14:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:58.5pt; mso-level-number-position:left; margin-left:58.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l14:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l14:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l14:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l14:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l14:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l14:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l14:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l14:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l15 {mso-list-id:2018799497; mso-list-type:hybrid; mso-list-template-ids:1440508192 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l15:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:58.5pt; mso-level-number-position:left; margin-left:58.5pt; text-indent:-.25in; font-family:Symbol;} @list l1:level1 lfo1 {mso-level-number-format:bullet; mso-level-numbering:continue; mso-level-text:\F0B7; mso-level-tab-stop:none; mso-level-number-position:left; mso-level-legacy:yes; mso-level-legacy-indent:0in; mso-level-legacy-space:0in; margin-left:0in; text-indent:0in; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><div class="Section1"> <p class="MsoNormal" style="margin: 5pt 0in;"><b><span style="font-size: 20pt; font-family: Arial;">
<br /></span></b><b><span style="font-size: 16pt; font-family: Arial;"><o:p></o:p></span></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">By: Aaron 'Jomdom' Ransley, and Trailstorm Radeem.
<br />Created: 1/10/003</span><o:p></o:p></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-family: Arial;">Introduction<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">This document will cover script structure and terminology, invented by myself and Trailstorm Radeem. We feel that the Dungeon Siege community has no real terminology to use in conversations relating to Siege FX scripts. We will list terminology and structure for an entire Siege FX script, start to finish. Proper indentation practices are also shown as the script progresses. Also, keep in mind that this is meant to be a reference more than a tutorial, so not every aspect of Siege mentioned will be explained with great detail.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><i style=""><span style="font-family: Arial;">Note: Some Siege FX commands already have names, or don’t need any. We will be covering mostly uncharted territory, although you might see a few little tidbits that we decided to rename. We hope this doesn’t cause any confusion.<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">We really hope this reference will become a standard, so if you enjoy it, <i style="">please</i> do your best to pass it on to anyone that is interested in Siege FX. If you need to link to the .zip file on my site, please use the following URL:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">http://dsc.conflict-imminent.com/dlcounter/odtrack.php?url=http://dsc.conflict-imminent.com/tutorials/sfx/term_reference.zip</span><b><span style="font-size: 16pt; font-family: Arial;"><o:p></o:p></span></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><span style="font-size: 16pt; font-family: Arial;">- <span style=""> </span>Script Architecture -</span></b><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Here, we are going to go over the names of the different sections of a Siege FX script.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><b><u><span style="font-family: Arial;">Script Header<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">The script header comprises of this section on code:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">efect_script</span>*]</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 1in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">name</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> = <span class="SpellE">example_script</span>; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Define the name of the script.</span><span style="font-size: 10pt; color: gray; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 1in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 1in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">script</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>=[[ </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Open the script.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><b><u><span style="font-family: Arial;">Declaration<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">In the declaration section, we create variables for use in the script:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 2in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> $color0 1,1,.3; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Store the value 1,1,.3 inside the variable, $color0 for use in the script later on.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">
<br /><span class="GramE">set</span> $size [0]; </span><span style="font-size: 10pt; color: gray; font-family: 'Courier New';">//</span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">Get the first p-param in the parameter string, whatever that may be.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><b><u><span style="font-family: Arial;">Effect Block: Pre-Block<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">In the pre-block section, we will declare the base effect, and it’s location like so:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 1.5in; text-indent: 0.5in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">create</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> fire #TARGET </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Create a fire base effect at #TARGET.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><b><u><span style="font-family: Arial;">Effect Block: Parameters<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">In the parameter block, we define all the parameters for base effect it is paired with:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 2in; text-indent: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">“<span class="GramE">instant(</span>)color0($color0)scale($size)<span class="SpellE">ts</span>(3)”; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Use these parameters in the parameter block.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><b><u><span style="font-family: Arial;">Effect Block: Post-Block<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">In the post-block, we set out <span class="GramE">targets,</span> store our completed effect in a variable, and anything else that is required before you start the effect:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 2in;"><span class="SpellE"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> rat #PEEK; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Remove all targets from the fire’s memory.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">
<br /><span class="SpellE"><span class="GramE">sfx</span></span> target #PEEK ap_trace01 target; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Redefine the target, creating the fire to attach to the end of the weapon the script is called on.
<br /></span><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> $fire #PEEK; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Store the effect in a variable. Not actually needed, just explaining how to do it.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">
<br /><span class="SpellE"><span class="GramE">sfx</span></span> start #POP; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Start the effect.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in; text-indent: 0.5in;"><b><u><span style="font-family: Arial;">Script Footer<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">In the script footer, we wrap up the script:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 1.5in; text-indent: 0.5in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">]]; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Close the script.</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">}</span><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Take note of the block pre and post notations. All the data from the pre-block to the end of the post-block is considered an effect block. This script comprises of 1 effect block.</span><span style="font-size: 10pt; color: red; font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><span style="font-size: 16pt; font-family: Arial;"><span style=""> </span>- Further Terminology -<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Now that we have covered the architecture of a Siege FX script in detail, let’s break it down further with terminology.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in; text-indent: 0.5in;"><b><u><span style="font-family: Arial;">Passed Variables<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">Variables passed between/into scripts using this method are called pass-parameters, or p-params. Using this method won’t be explained here, but is a <i style="">very </i>good way to optimize your scripts. Think of creating a script that looks for a p-param for <span class="GramE">it’s</span> color, speed, scale, <span class="SpellE">ect</span>. Think of being able to call the script from a template, putting data into those p-params to be passed. You could use the script over and over again and get different looks each time, because your p-params are different. Trailstorm Radeem, a close friend of mine, and the co-author of this reference, is a true pioneer of utilizing this method.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">Here is syntax example of grabbing a p-param after its data has been defined in the template:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> $scale [0]; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Store the first value that was passed into the script from the template in the variable named $scale.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in; text-indent: 0.5in;"><b><u><span style="font-family: Arial;">Repeater Scripts<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">A repeater script is something that I have used, and plan to continue using them, in my Cosmetics line of mods. There really isn’t an analogy I can use to explain it, so I have to get technical. A repeater script works like so:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 1in; text-indent: -0.25in;"><span style="font-family: Symbol;"><span style="">·<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><span style="font-family: Arial;">The repeater script is initially started.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 1in; text-indent: -0.25in;"><span style="font-family: Symbol;"><span style="">·<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><span style="font-family: Arial;">The script then calls what is to be repeated.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 1in; text-indent: -0.25in;"><span style="font-family: Symbol;"><span style="">·<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><span style="font-family: Arial;">Then the repeater script calls itself over again and repeats the process.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span class="GramE"><span style="font-family: Arial;">Lets</span></span><span style="font-family: Arial;"> built on this, and take a look at a script that uses this method:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//MAGNETO STAFF\\<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*]</span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">name</span><span style=""> </span>=<span class="SpellE">abr_mag_staff</span>;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">script</span><span style=""> </span>=[[
<br />
<br /><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">if(</span>!#WEAPON_TYPE_STAFF)
<br /><span style=""> </span>{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 2in; text-indent: 0.5in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">exit</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">;<span style=""> </span>
<br />}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">pause</span> .5; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Pause the script for half a second.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">call</span> <span class="SpellE">mag_curve</span>; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Call the script that is to be repeated.</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">call</span> <span class="SpellE">abr_mag_staff</span>; </span><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//Call this same script over again.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>]];<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">}<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';">//MAGNETO STAFF CURVE\\<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*] <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">name</span><span style=""> </span>=<span class="SpellE">mag_curve</span>;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">script</span><span style=""> </span>=[[<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create curve #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"curvature(1)model(0)scale(.1)color0(1,.5,.8)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">ts</span></span><span class="GramE">(</span>2)<span class="SpellE">tlength</span>(20)";<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> target #PEEK target;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> <span class="SpellE">attach_point</span> #PEEK ap_trace01 target;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> <span class="SpellE">attach_point</span> #PEEK ap_trace02 source;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> start #POP;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>]];<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">}<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in 5pt 0.5in;"><span style="font-family: Arial;">There isn’t much explaining to do… The script ends up repeating over and over again with a half second delay. The reason we don’t just call ‘<span class="SpellE">mag_curve</span>’ over and over again from itself is simply because the repeater script acts as a great hub if you wish to control many repeating scripts from there. There are times that you do not need a repeater script, though.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-family: Arial;">Resources</span></u></b><span style="font-size: 10pt; color: rgb(51, 51, 153); font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">These are various resources I find <i>very</i> useful.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/index.shtml">Dungeon Siege's Main Site</a> (Take a look around. Contains various mod resources, as well as the Dungeon Siege Toolkit)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.game-editing.net/forum/index.php?c=3">Game-Editing.net Dungeon Siege Forums</a> (If you plan of modifying Dungeon Siege, this is the place to be. Make sure to make use of the search function.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/su_212.shtml">Siege FX Siege University Course</a> (Contains a list of the 22 base effects, a list of all possible parameters for those 22 base effects, and more. A great resource indeed.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://dsc.conflict-imminent.com/">Dungeon Siege Cosmetics</a> (Home of this tutorial.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="mailto:jomdom@hotmail.com?subject=Siege%20FX%20Tutorial">Jomdom's E-mail</a> (Feel free to e-mail me with <i>any</i> questions you have about this tutorial.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-family: Arial;">In the Future<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Although this reference doesn’t really fit into the progression of the tutorials I am doing, it isn’t meant to. More tutorials are on their way, so hold tight.</span><o:p></o:p></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-family: Arial;">Credits<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"> <span style=""> </span>Icemage - Thanks for the input on the terminology.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span>Trailstorm Radeem - It was a great idea to make such a reference!<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"> <span style=""> </span>Gas Powered Games - You make a killer effects engine! Great job! Can’t wait for Dungeon Siege 2's version of Siege FX.<o:p></o:p></span></p></div>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-72995960264553630122009-01-02T01:49:00.000-08:002009-01-02T01:50:22.343-08:00Siege FX Tutorial #3<title>Siege FX Tutorial #1</title><link href="Siege%20FX%20Tutorial%20%233%20-%20Targets_files/filelist.xml" rel="File-List"><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:553679495 -2147483648 8 0 66047 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} h1 {mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:1; font-size:16.0pt; font-family:Arial; mso-font-kerning:16.0pt;} p.MsoCommentText, li.MsoCommentText, div.MsoCommentText {mso-style-noshow:yes; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoListBullet2, li.MsoListBullet2, div.MsoListBullet2 {mso-style-update:auto; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; text-indent:-.25in; mso-pagination:widow-orphan; mso-list:l0 level1 lfo2; tab-stops:list .5in; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoBodyTextIndent, li.MsoBodyTextIndent, div.MsoBodyTextIndent {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:.25in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoListContinue2, li.MsoListContinue2, div.MsoListContinue2 {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:.5in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p.MsoDocumentMap, li.MsoDocumentMap, div.MsoDocumentMap {mso-style-noshow:yes; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; background:navy; font-size:12.0pt; font-family:Tahoma; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman";} p.cour, li.cour, div.cour {mso-style-name:cour; mso-style-link:"cour Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; mso-layout-grid-align:none; text-autospace:none; font-size:10.0pt; font-family:Arial; mso-fareast-font-family:"Times New Roman";} p.StyleArialBefore5ptAfter5pt, li.StyleArialBefore5ptAfter5pt, div.StyleArialBefore5ptAfter5pt {mso-style-name:"Style Arial Before\: 5 pt After\: 5 pt"; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt; margin-left:0in; mso-pagination:widow-orphan; font-size:10.0pt; font-family:Arial; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman";} span.courChar {mso-style-name:"cour Char"; mso-style-link:cour; font-family:Arial; mso-ascii-font-family:Arial; mso-hansi-font-family:Arial; mso-bidi-font-family:Arial; mso-ansi-language:EN-US; mso-fareast-language:EN-US; mso-bidi-language:AR-SA;} span.SpellE {mso-style-name:""; mso-spl-e:yes;} span.GramE {mso-style-name:""; mso-gram-e:yes;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:-125; mso-list-type:simple; mso-list-template-ids:205841210;} @list l0:level1 {mso-level-number-format:bullet; mso-level-style-link:"List Bullet 2"; mso-level-text:\F0B7; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol;} @list l1 {mso-list-id:-2; mso-list-type:simple; mso-list-template-ids:572177678;} @list l1:level1 {mso-level-start-at:0; mso-level-text:*; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:0in; text-indent:0in;} @list l2 {mso-list-id:616988282; mso-list-type:hybrid; mso-list-template-ids:-487549960 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l3 {mso-list-id:666788475; mso-list-type:hybrid; mso-list-template-ids:-1698530994 1868184898 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:\F0B6; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l4 {mso-list-id:798760914; mso-list-template-ids:-904989288;} @list l4:level1 {mso-level-start-at:0; mso-level-number-format:image; list-style-image:url("Siege%20FX%20Tutorial%20%233%20-%20Targets_files/image001.gif"); mso-level-text:\F0B7; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol; mso-fareast-font-family:"Times New Roman"; color:windowtext;} @list l4:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:.5in; mso-level-number-position:left; margin-left:.5in; text-indent:-.25in; font-family:"Courier New";} @list l4:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Wingdings;} @list l4:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:Symbol;} @list l4:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:"Courier New";} @list l4:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Wingdings;} @list l4:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:Symbol;} @list l4:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:"Courier New";} @list l4:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Wingdings;} @list l5 {mso-list-id:872115448; mso-list-template-ids:-487549960;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l5:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l5:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l5:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l5:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l5:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l5:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l5:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l5:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l6 {mso-list-id:1001858529; mso-list-type:hybrid; mso-list-template-ids:-259894358 350631756 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l6:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:22.5pt; mso-level-number-position:left; margin-left:22.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l7 {mso-list-id:1039234215; mso-list-type:hybrid; mso-list-template-ids:-446526342 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l7:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol;} @list l8 {mso-list-id:1166088963; mso-list-template-ids:705214696;} @list l8:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l8:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l8:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l8:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l8:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l8:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l8:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l8:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l8:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l9 {mso-list-id:1235049770; mso-list-type:hybrid; mso-list-template-ids:-904989288 -1002559126 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l9:level1 {mso-level-start-at:0; mso-level-number-format:image; list-style-image:url("Siege%20FX%20Tutorial%20%233%20-%20Targets_files/image001.gif"); mso-level-text:\F0B7; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol; mso-fareast-font-family:"Times New Roman"; color:windowtext;} @list l10 {mso-list-id:1279751207; mso-list-template-ids:-1698530994;} @list l10:level1 {mso-level-number-format:bullet; mso-level-text:\F0B6; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l10:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l10:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l10:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l10:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l10:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l10:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l10:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l10:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l11 {mso-list-id:1460491438; mso-list-type:hybrid; mso-list-template-ids:-1501785772 -446527790 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l11:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol; color:windowtext;} @list l12 {mso-list-id:1592081694; mso-list-type:hybrid; mso-list-template-ids:-1191432996 1105770856 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l12:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:58.5pt; mso-level-number-position:left; margin-left:58.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l13 {mso-list-id:1615356967; mso-list-template-ids:-1698530994;} @list l13:level1 {mso-level-number-format:bullet; mso-level-text:\F0B6; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol;} @list l13:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l13:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l13:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l13:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l13:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l13:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l13:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l13:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l14 {mso-list-id:1679648439; mso-list-type:hybrid; mso-list-template-ids:-1670471752 -446527790 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l14:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol; color:windowtext;} @list l15 {mso-list-id:1685590437; mso-list-type:hybrid; mso-list-template-ids:1083197146 -1002559126 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l15:level1 {mso-level-start-at:0; mso-level-number-format:image; list-style-image:url("Siege%20FX%20Tutorial%20%233%20-%20Targets_files/image001.gif"); mso-level-text:\F0B7; mso-level-tab-stop:60.0pt; mso-level-number-position:left; margin-left:60.0pt; text-indent:-.25in; font-family:Symbol; mso-fareast-font-family:"Times New Roman"; color:windowtext;} @list l16 {mso-list-id:1689990809; mso-list-type:hybrid; mso-list-template-ids:1654426930 1105770856 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l16:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:22.5pt; mso-level-number-position:left; margin-left:22.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l17 {mso-list-id:1835873538; mso-list-type:hybrid; mso-list-template-ids:-1977431558 -446527790 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l17:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Symbol; color:windowtext;} @list l18 {mso-list-id:1877158556; mso-list-type:hybrid; mso-list-template-ids:-1214474884 -446527790 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l18:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol; color:windowtext;} @list l19 {mso-list-id:1915629704; mso-list-type:hybrid; mso-list-template-ids:705214696 1105770856 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l19:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:1.0in; mso-level-number-position:left; margin-left:1.0in; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l20 {mso-list-id:2018462080; mso-list-template-ids:-1191432996;} @list l20:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:58.5pt; mso-level-number-position:left; margin-left:58.5pt; text-indent:-.25in; font-family:Arial; mso-fareast-font-family:"Times New Roman";} @list l20:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.5in; mso-level-number-position:left; margin-left:1.5in; text-indent:-.25in; font-family:"Courier New";} @list l20:level3 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:2.0in; mso-level-number-position:left; margin-left:2.0in; text-indent:-.25in; font-family:Wingdings;} @list l20:level4 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:2.5in; mso-level-number-position:left; margin-left:2.5in; text-indent:-.25in; font-family:Symbol;} @list l20:level5 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:3.0in; mso-level-number-position:left; margin-left:3.0in; text-indent:-.25in; font-family:"Courier New";} @list l20:level6 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:3.5in; mso-level-number-position:left; margin-left:3.5in; text-indent:-.25in; font-family:Wingdings;} @list l20:level7 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:4.0in; mso-level-number-position:left; margin-left:4.0in; text-indent:-.25in; font-family:Symbol;} @list l20:level8 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:4.5in; mso-level-number-position:left; margin-left:4.5in; text-indent:-.25in; font-family:"Courier New";} @list l20:level9 {mso-level-number-format:bullet; mso-level-text:\F0A7; mso-level-tab-stop:5.0in; mso-level-number-position:left; margin-left:5.0in; text-indent:-.25in; font-family:Wingdings;} @list l21 {mso-list-id:2018799497; mso-list-type:hybrid; mso-list-template-ids:1440508192 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l21:level1 {mso-level-number-format:bullet; mso-level-text:\F0B7; mso-level-tab-stop:58.5pt; mso-level-number-position:left; margin-left:58.5pt; text-indent:-.25in; font-family:Symbol;} @list l1:level1 lfo1 {mso-level-number-format:bullet; mso-level-numbering:continue; mso-level-text:\F0B7; mso-level-tab-stop:none; mso-level-number-position:left; mso-level-legacy:yes; mso-level-legacy-indent:0in; mso-level-legacy-space:0in; margin-left:0in; text-indent:0in; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><div class="Section1"> <p class="MsoNormal" style="margin: 5pt 0in;"><b><span style="font-size: 20pt; font-family: Arial;">
<br /></span></b><b><span style="font-size: 16pt; font-family: Arial;">Targets<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">By: Aaron 'Jomdom' Ransley
<br />Created: </span><span style="font-family: Arial;">1/15/2003</span><o:p></o:p></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-size: 11pt; font-family: Arial;">Introduction<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">In this installment, we will be discussing targets. How do you get your effects to go where you want them to? Shout at the code and mash the keyboard? That works, but very rarely. Instead, I will attempt to teach you the correct way to assign effects to targets. You will need to be familiar with the Stack, so if you haven’t read that tutorial yet, </span><span class="MsoHyperlink"><a href="http://dsc.conflict-imminent.com/dlcounter/odtrack.php?url=http://dsc.conflict-imminent.com/tutorials/sfx/the_stack.zip">go ahead</a></span><span style="font-size: 11pt; font-family: Arial;"> and do that now.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><i style=""><span style="font-size: 11pt; font-family: Arial;">Notes: You might notice the lack of the Lingo section in this tutorial. The formatting is also a bit smaller than the last few tutorials. I hope it isn’t too dramatic of a change.<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-size: 11pt; font-family: Arial;">Taking a Peek<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Please note this script is very un-optimized, it is being used because it is a good example of how targets work.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Let’s take a look:<b style=""><o:p></o:p></b></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*]<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';">{<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>name<span style=""> </span>= halo;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>script<span style=""> </span>=[[<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>sfx create orbiter #TARGET<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>"radius(2.5)phi(0)<span class="SpellE">iphi</span>(40)<span class="SpellE">itheta</span>(0)color0(1,1,0)<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>offset(0,.3,0)scale(.05)invisible()";<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>sfx attach_point #PEEK bip01_head target;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>set $orb1 #PEEK;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>sfx start #POP;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>sfx create fire #TARGET<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>"flamesize(3)color0(1,.3,1)color1(0,0,0)<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>scale(1)velocity(0,0,<span class="GramE">0</span>)alphafade(.3)<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>count(100)accel(0,0,0)";<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>sfx rat #PEEK;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span><span style=""> </span>sfx target #PEEK $orb1 target;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>sfx start #POP;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';"><span style=""> </span>]];<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">}<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-size: 11pt; font-family: Arial;">Break it Down</span></u></b><span style="font-size: 11pt; font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Let’s go to the most important part of the script first; where the effect goes:<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';">sfx create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">#TARGET and #SOURCE macros can yield different results depending on how the script is called into existence, and what it is run on. In this case, #TARGET is the player. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">The next important thing in the script is where on the player the effect goes:<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';">sfx attach_point #PEEK bip01_head target;<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">This tells the Siege FX engine (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 11pt; font-family: Arial;">) to attach (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">attach_point</span></span><span style="font-size: 11pt; font-family: Arial;">) the effect (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">#PEEK</span></span><span style="font-size: 11pt; font-family: Arial;">) to the players head (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">bip01_head</span></span><span style="font-size: 11pt; font-family: Arial;">) using the effect’s target (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">target</span></span><span style="font-size: 11pt; font-family: Arial;">).<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Then, we have attaching the fire to the orbiters:<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';">sfx rat #PEEK;<o:p></o:p></span></p> <p class="cour"><span style="color: red; font-family: 'Courier New';">sfx target #PEEK $orb1 target;</span><span style="color: red; font-family: 'Courier New';"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">It’s confusing isn’t it? Why do we use the (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">target)</span></span><span style="font-size: 11pt; font-family: Arial;"> command on one effect, and the (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">attach_point</span></span><span style="font-size: 11pt; font-family: Arial;">) command on the other? You can think of it as a hierarchy.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">First, we have the player </span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">(#TARGET</span></span><span style="font-size: 11pt; font-family: Arial;">). The player has a bunch of special bones to attach to. We use (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">attach_point)</span></span><span style="font-size: 11pt; font-family: Arial;"> to get a certain bone we need (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">bip01_head</span></span><span style="font-size: 11pt; font-family: Arial;">) and hook the effect to it.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Secondly, we have the player again (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">#TARGET</span></span><span style="font-size: 11pt; font-family: Arial;">). We don’t want the player this time though. Let’s tell the Siege FX engine (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 11pt; font-family: Arial;">) to remove all targets (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">rat</span></span><span style="font-size: 11pt; font-family: Arial;">) from the effect </span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">(#PEEK</span></span><span style="font-size: 11pt; font-family: Arial;">).<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Now that we have a clean slate, we can reassign targets. This time, we don’t want to go any further than just assigning a target, because an orbiter doesn’t have any special bones to attach to. We tell the Siege FX engine (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 11pt; font-family: Arial;">) to use the command (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">target</span></span><span style="font-size: 11pt; font-family: Arial;">) on the effect </span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">(#PEEK</span></span><span style="font-size: 11pt; font-family: Arial;">) assign a new target </span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">($orb1</span></span><span style="font-size: 11pt; font-family: Arial;">) on the effect’s target (</span><span class="courChar"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">target</span></span><span style="font-size: 11pt; font-family: Arial;">). Since there are no special bones to attach to, we are done assigning targets.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">In the end, we have an orbiter rotating around the player’s head, with fire attached to it that fades out slowly, so it looks as though we have a halo above the players head. Like I said earlier, it isn’t needed. You could easily just use a fire base effect using the radius parameter to achieve almost the exact same thing.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">That wraps it up for now!<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-size: 11pt; font-family: Arial;">Resources</span></u></b><span style="font-size: 11pt; font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">These are various resources I find <i>very</i> useful.<o:p></o:p></span></p> <ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="margin-top: 5pt; margin-bottom: 5pt;"><span style="font-size: 11pt; font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/index.shtml">Dungeon Siege's Main Site</a> (Take a look around. Contains various mod resources, as well as the Dungeon Siege Toolkit)<o:p></o:p></span> </li><li class="MsoNormal" style="margin-top: 5pt; margin-bottom: 5pt;"><span style="font-size: 11pt; font-family: Arial;"><span style=""> </span><a href="http://www.game-editing.net/forum/index.php?c=3">Game-Editing.net Dungeon Siege Forums</a> (If you plan of modifying Dungeon Siege, this is the place to be. Make sure to make use of the search function.)<o:p></o:p></span> </li><li class="MsoNormal" style="margin-top: 5pt; margin-bottom: 5pt;"><span style="font-size: 11pt; font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/su_212.shtml">Siege FX Siege University Course</a> (Contains a list of the 22 base effects, a list of all possible parameters for those 22 base effects, and more. A great resource indeed.)<o:p></o:p></span> </li><li class="MsoNormal" style="margin-top: 5pt; margin-bottom: 5pt;"><span style="font-size: 11pt; font-family: Arial;"><span style=""> </span><a href="http://dsc.conflict-imminent.com/">Dungeon Siege Cosmetics</a> (Home of this tutorial.)<o:p></o:p></span> </li><li class="MsoNormal" style="margin-top: 5pt; margin-bottom: 5pt;"><span style="font-size: 11pt; font-family: Arial;"><span style=""> </span><a href="mailto:jomdom@hotmail.com?subject=Siege%20FX%20Tutorial">Jomdom's E-mail</a> (Feel free to e-mail me with <i>any</i> questions you have about this tutorial.)<o:p></o:p></span> </li></ul> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-size: 11pt; font-family: Arial;">In the Future<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Expect the next tutorial to cover some sneaky tricks with the Siege FX engine.</span><span style="font-size: 11pt; font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-size: 11pt; font-family: Arial;">Credits<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-size: 11pt; font-family: Arial;">Gas Powered Games - You make a killer effects engine! Great job! I can’t wait for Dungeon Siege 2's revision of Siege FX.</span><span style="font-size: 11pt; font-family: Arial;"><o:p></o:p></span></p></div>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-15596190973700670622009-01-02T01:48:00.000-08:002009-01-02T01:49:35.989-08:00Siege FX Tutorial #2<title>Siege FX Tutorial #1</title><link href="Siege%20FX%20Tutorial%20%232%20-%20The%20Stack_files/filelist.xml" rel="File-List"><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} h1 {mso-style-next:Normal; margin-top:12.0pt; margin-right:0in; margin-bottom:3.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:1; font-size:16.0pt; font-family:Arial; mso-font-kerning:16.0pt;} p.MsoListBullet2, li.MsoListBullet2, div.MsoListBullet2 {mso-style-update:auto; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; text-indent:-.25in; mso-pagination:widow-orphan; mso-list:l0 level1 lfo2; tab-stops:list .5in; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoBodyText, li.MsoBodyText, div.MsoBodyText {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoBodyTextIndent, li.MsoBodyTextIndent, div.MsoBodyTextIndent {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:.25in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoListContinue2, li.MsoListContinue2, div.MsoListContinue2 {margin-top:0in; margin-right:0in; margin-bottom:6.0pt; margin-left:.5in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} span.SpellE {mso-style-name:""; mso-spl-e:yes;} span.GramE {mso-style-name:""; mso-gram-e:yes;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:-125; mso-list-type:simple; mso-list-template-ids:205841210;} @list l0:level1 {mso-level-number-format:bullet; mso-level-style-link:"List Bullet 2"; mso-level-text:\F0B7; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; font-family:Symbol;} @list l1 {mso-list-id:-2; mso-list-type:simple; mso-list-template-ids:572177678;} @list l1:level1 {mso-level-start-at:0; mso-level-text:*; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:0in; text-indent:0in;} @list l1:level1 lfo1 {mso-level-number-format:bullet; mso-level-numbering:continue; mso-level-text:\F0B7; mso-level-tab-stop:none; mso-level-number-position:left; mso-level-legacy:yes; mso-level-legacy-indent:0in; mso-level-legacy-space:0in; margin-left:0in; text-indent:0in; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><div class="Section1"> <p class="MsoNormal" style="margin: 5pt 0in;"><b><span style="font-size: 20pt; font-family: Arial;">
<br /></span></b><span class="GramE"><b><span style="font-size: 16pt; font-family: Arial;">T</span></b><b><span style="font-size: 16pt; font-family: Arial;">he</span></b></span><b><span style="font-size: 16pt; font-family: Arial;"> Stack</span></b><b><span style="font-size: 20pt; font-family: Arial;"><o:p></o:p></span></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">By: Aaron 'Jomdom' Ransley
<br />Created: 1/6/2003<b><u><o:p></o:p></u></b></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-family: Arial;">Introduction<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">In this tutorial, we will be discussing the Stack. As always, any code will be in </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">red and in a different font</span><span style="font-family: Arial;">. I will try to keep code from within a text-heavy paragraph to a minimum, and save it for its own paragraph.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-family: Arial;">Lingo</span></u></b><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">- <b>Stack:</b> <i>The stack is the device that Siege FX uses to store effect data. I can’t think of any way to explain better than Icemage once did.<o:p></o:p></i></span></p> <p class="MsoNormal" style="margin: 5pt 0in; text-indent: 0.5in;"><i><span style="font-family: Arial;">“</span></i><i style=""><span style="font-family: Arial;">You can think of this like a stack of plates - as we create effects, we put each effect onto the stack, <span class="GramE">the</span> same way you would put plates that have been dried in a stack.” - Icemage<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b><u><span style="font-family: Arial;">The Stack<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><i style=""><span style="font-family: Arial;">As Icemage said, “...as we create effects, we put each effect onto the stack…”<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin: 5pt 0in;"><i style=""><span style="font-family: Arial;">Let me elaborate. Say we create an orbiter, one of the 22 base effects. It would automatically be entered into the stack (if it doesn’t have any errors that is). Here is an example:<o:p></o:p></span></i></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*]<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';">{<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">name</span><span style=""> </span>=orbs;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">script</span><span style=""> </span>=[[<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>1,1,1)scale(.25)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $orb1 #PEEK;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> start #POP;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>1,1,1)scale(.25)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $orb2 #PEEK;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> start #POP;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>1,1,1)scale(.25)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $orb3 #PEEK;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> start #POP;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>1,1,1)scale(.25)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $orb4 #PEEK;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> start #POP;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>]];<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">}<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">“Eh?” you say? No kidding.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Alright, first off, understand that this effect doesn’t actually do anything, and if it did, it wouldn’t consist of anything more than creating 4 white orbiters at its target, directly on top of each other.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">So, <span class="GramE">lets</span> break it down.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">You see that after I create the orbiter, define it’s location of creation, and <span class="GramE">it’s</span> parameters, I go on to say:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> $orb1 #PEEK;<o:p></o:p></span></p> <p class="MsoNormal"><span class="SpellE"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> start #POP;<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Let’s break this down further… By writing:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> $orb1 #PEEK;<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">I tell the Siege FX engine to create a variable (something to contain the effect for quick referencing) out of whatever is on top of the stack. It effectively peeks at the top of the stack to check what’s there… Since we just created an orbiter, it is currently king of the stack. While we are talking about variables, I might as well mention that whenever you define a variable, it should be structured like so:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> <name> <what>;<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">This means that if you want to create a variable to store a color, you can do this:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> $green .3,1,.3;<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">And it will store that color value inside the variable for later use in the script.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Getting back on track... Next we have this line:<o:p></o:p></span></p> <p class="MsoNormal"><span class="SpellE"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> start #POP;<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">This is telling the Siege FX engine to ‘start’ what ever is on top of the stack, but ‘pop’ it off so it’s not on the stack anymore. If we then tried to use another command to look for the effect, you wouldn’t find it, because someone knocked it off the stack, and made a huge mess! Some people! <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Here is an example of an invalid way of using the #POP and #PEEK commands.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">set</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> $orb1 #POP;
<br /></span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> start #PEEK;<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">We create a variable by using the data from the top of the stack, currently the data from the last effect we created, but ‘pop’ it off at the end, because we are supposedly done using it… Wrong.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">The next line tries to start whatever is currently in the stack, but there is nothing there! Jeepers! It must be because someone made a mistake and knocked the effect off the stack too soon.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><b style=""><u><span style="font-family: Arial;">Slick Stack <span class="SpellE">Slingin</span>’ <o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">Think your hot stuff? Try this on for size:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*]<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';">{<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">name</span><span style=""> </span>=<span class="SpellE">technicolor_orbs</span>;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">script</span><span style=""> </span>=[[<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $color4 .5,.5,.5;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $color3 0,1,0;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $color2 0,0,1;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $color1 1,0,0;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>$color4)scale(2)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>$color3)scale(2)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>$color2)scale(2)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> create orbiter #TARGET<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>"<span class="GramE">color0(</span>$color1)scale(2)radius(0)";<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $orb3 #POP;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="GramE">set</span> $orb2 #POP;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> start $orb2;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span><span class="SpellE"><span class="GramE">sfx</span></span> start $orb3;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><o:p> </o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>]];<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; color: red; font-family: 'Courier New';">}<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">What color will the pile of orbs be when the script is complete? If you can figure that out, you’re done with the tutorial. If you can’t, just keep decoding it, because everything here has been covered so far.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0in;"><span style="font-family: Arial;">See you next time!<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Resources<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">These are various resources I find <i>very</i> useful.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/index.shtml">Dungeon Siege's Main Site</a> (Take a look around. Contains various mod resources, as well as the Dungeon Siege Toolkit)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.game-editing.net/forum/index.php?c=3">Game-Editing.net Dungeon Siege Forums</a> (If you plan of modifying Dungeon Siege, this is the place to be. Make sure to make use of the search function.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/su_212.shtml">Siege FX Siege University Course</a> (Contains a list of the 22 base effects, a list of all possible parameters for those 22 base effects, and more. A great resource indeed.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://dsc.conflict-imminent.com/">Dungeon Siege Cosmetics</a> (Home of this tutorial.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="mailto:jomdom@hotmail.com?subject=Siege%20FX%20Tutorial">Jomdom's E-Mail</a> (Feel free to e-mail me with <i>any</i> questions you have about this tutorial.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">In the Future<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Expect more and more advanced tutorials in the future. Enough said </span><span style="font-family: Wingdings;"><span style="">J</span></span><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Credits</span></u></b><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span>Icemage - You have really helped me with the more advanced aspects of Siege FX. I thank you, Icemage.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span>Gas Powered Games - You make a killer effects engine! Great <span class="GramE">job,</span> can't wait for Dungeon Siege 2's version of Siege FX.<o:p></o:p></span></p></div>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-5502528193032620412009-01-02T01:46:00.000-08:002009-01-02T01:48:10.938-08:00Siege FX Tutorial #1<p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Introduction</span></u></b><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">This tutorial will cover a small bit of the language used to create effects in Dungeon Siege.<span style=""> </span>Siege FX.<span style=""> </span>Fire from the torches on grimy dungeon walls, healing spells you cast frantically to stay alive, the glow on that new sword you just got from a chicken run, it's all done with Siege FX.<span style=""> </span>Since I have been working with Siege FX for quite awhile now, and I thought <span class="GramE">its</span> about time I put together a tutorial for those of you interested in it.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Please take note that I have never written a tutorial before, so don't expect to be glued to your monitor, although I will do my best to be as thorough as possible.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><i style=""><span style="font-family: Arial;">When I give examples of code, </span></i><span style="font-size: 10pt; color: red; font-family: 'Courier New';">they will be in a different font, and in red.</span><i style=""><span style="font-family: Arial;"> When I show full scripts, they will be formatted for the web, so don’t expect your script to look exactly like mine.<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Lingo</span></u></b><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">- <b>Base Effect:</b><span style=""> </span><i>All Siege FX scripts are built off 22 different base effects. Please check the Resources section at the bottom of this tutorial for a link to a full listing of the base effects.</i><br />- <b>Parameter:</b><span style=""> </span><i>A parameter is how we tell any of the base effects how to act. They can be used to manipulate various aspects of a base effect; size, speed, color, density, duration, etc.</i><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Dissecting the Fire Parameter</span></u></b><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">We will start the tutorial by learning how to use one of the most versatile of all the Siege FX base effects, </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">fire</span><span style="font-family: Arial;">. This base effect supports many different parameters that allow you to manipulate the way it acts.<span style=""> </span>Let’s find an effect that keeps it simple for the time being...<span style=""> </span>Ah yes, this looks like a good effect script:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*]<br />{<br /><span style=""> </span>name = <span class="SpellE">fire_pit_fire_small</span>;<br /><br /><span style=""> </span>script = [[<br /><br /><span style=""> </span><span class="SpellE">sfx</span> create fire #TARGET<br /><span style=""> </span><span style=""> </span><span style=""> </span>"instant()offset(0,.25,0)scale(1)<span class="SpellE">ts</span>(.5)";<br /><span style=""> </span><span class="SpellE">sfx</span> start #POP;<br /><br /><span style=""> </span>]];<br />}</span><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Alright, let’s break it down...<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">All Siege FX scripts will be structured like so:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*]<br />{<br /><span style=""> </span><span class="GramE">name</span> = <name>;<br /><br /><span style=""> </span>script = [[<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';"><span style=""> </span>...Code...<br /><br /><span style=""> </span>]];<br />}</span><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">With that in mind, let’s talk about the base effect created here. We prefix the command to create the base effect with </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-family: Arial;">, as we do with almost every command in Siege FX. What we are doing is telling the </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-family: Arial;"> engine to </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">create fire</span><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-family: Arial;">at a certain place - in this case, at our target.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Next we start the creating the actual parameters that effect the way the base effect acts. We start it with a double quote, followed by these parameters:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">-<b> <span class="GramE">instant(</span>): </b><i>This parameter causes the </i></span><span style="font-size: 10pt; font-family: 'Courier New';">fire</span><i><span style="font-family: Arial;"> base effect to be instantly at full flame, and skip any gradual gaining of density and speed.</span></i><b><span style="font-family: Arial;"><br /></span></b><span style="font-family: Arial;">-<b> <span class="GramE">offset(</span><span class="SpellE">x,x,x</span>): </b><i>This parameter offsets the base effect from the location of it's creation. </i></span><span class="GramE"><i><span style="font-size: 10pt; color: red; font-family: 'Courier New';">offset(</span></i></span><i><span style="font-size: 10pt; color: red; font-family: 'Courier New';">0,.25,0)</span></i><i><span style="font-family: Arial;"> causes the flame to be offset along the Y axis (up and down) just a tad.</span></i><b><span style="font-family: Arial;"><br /></span></b><span style="font-family: Arial;">-<b> <span class="GramE">scale(</span>x): </b><i>This is the overall scale of the base effect. It affects the size of the flames more than anything.</i><b><br /></b>-<b> <span class="SpellE"><span class="GramE">ts</span></span><span class="GramE">(</span>x): </b><i>This parameter stands for the <b>T</b>ime <b>S</b>cale of the base effect. It can be used on almost any base effect to speed it up or slow it down.<o:p></o:p></i></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Then we end it with another double quote and a semi-colon.<i><o:p></o:p></i></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Alright, now that we have that done, lets take a look at what it looks like in the game... This effect is part of the main game resources, so you won't need to create a new tank unless you have decided to modify it ahead of time.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><span style="font-family: Arial;">You will need DSMOD.exe for the next few steps, so please make sure you have downloaded the Dungeon Siege Toolkit. You can find a link to the Dungeon Siege Toolkit at the bottom of this tutorial in the Resources section.<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Now, go ahead and fire up DSMOD.exe and get yourself into a map. Bring up the console by pressing the </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">~</span><span style="font-family: Arial;"> key to the left of the </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">1</span><span style="font-family: Arial;"> key. Type in: </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> run <span class="SpellE">fire_pit_fire_small</span></span><span style="font-family: Arial;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;"><v:shapetype id="_x0000_t75" coordsize="21600,21600" preferrelative="t" spt="75" filled="f" stroked="f" path=" m@4@5 l@4@11@9@11@9@5 xe"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0 "></v:f><v:f eqn="sum @0 1 0 "></v:f><v:f eqn="sum 0 0 @1 "></v:f><v:f eqn="prod @2 1 2 "></v:f><v:f eqn="prod @3 21600 pixelWidth "></v:f><v:f eqn="prod @3 21600 pixelHeight "></v:f><v:f eqn="sum @0 0 1 "></v:f><v:f eqn="prod @6 1 2 "></v:f><v:f eqn="prod @7 21600 pixelWidth "></v:f><v:f eqn="sum @8 21600 0 "></v:f><v:f eqn="prod @7 21600 pixelHeight "></v:f><v:f eqn="sum @10 21600 0 "></v:f></v:formulas><v:path extrusionok="f" gradientshapeok="t" connecttype="rect"></v:path><o:lock aspectratio="t" ext="edit"></o:lock></v:shapetype><v:shape id="_x0000_i1026" style="width: 231pt; height: 231pt;" type="#_x0000_t75" coordsize="21600,21600"><v:imagedata title="flameguy01" src="Siege%20FX%20Tutorial%20%231%20-%20Getting%20Started_files/image002.jpg"></v:imagedata></v:shape><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span class="SpellE"><span style="font-family: Arial;">Ack</span></span><span style="font-family: Arial;">, you’re on fire!</span><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-family: Arial;">Put yourself out by typing </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> stop scripts</span><span style="font-family: Arial;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Playing with Fire<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Now that we've seen the effect in action, let’s try to modify it a little.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">First we will change the color of the flame, then we will add a special parameter to cause it to last longer before fading away, then we will change the size of the flame. Sounds like a lot? Not really, I'll step you though it bit by bit.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">When we first created the fire, we added no parameter to manipulate the color, so it used <span class="GramE">it's</span> default base effect color. Different base effects have different default color values, and the default color for </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">fire</span><span style="font-family: Arial;"> is an orange color. We can overwrite this default color by adding a special parameter. This parameter is known as </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">color0</span><span style="font-family: Arial;">. Let’s see take a look at a definition:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">- <b>color0(<span class="SpellE">x<span class="GramE">,x,x</span></span>):</b> <i>This parameter is simply a RGB (Red, Green, Blue)<span style=""> </span>value. The numbers range from 0 to 1, and go out to two decimal places. You might use </i></span><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">color0(</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">1,.5,.5)</span><i><span style="font-family: Arial;"> to get a bright red, or </span></i><span style="font-size: 10pt; color: red; font-family: 'Courier New';">color0(1,.5,1)</span><i><span style="font-family: Arial;"> to get a dark-<span class="SpellE">ish</span> purple.<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Now that we have that out of the way, you should have a basic understanding of what the </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">color0</span><span style="font-family: Arial;"> parameter does. Let’s put them to work, shall we?<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">We will need to create a new .gas file for this step... Go ahead and open up Tank Viewer and load up <span class="SpellE">Logic.dsres</span>. <span class="GramE">Extract <span style="font-size: 10pt; color: red; font-family: 'Courier New';">..\world\global\effects\<span class="SpellE">environmental.gas</span></span> to a directory of your choice.</span> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">If you wish to use the Bits folder, then just extract it to there. Using the Bits folder allows for rapid reloading of scripts while in game; saves a lot of time. The Bits folder is located <span class="GramE">in <span style="font-size: 10pt; color: red; font-family: 'Courier New';">..\my documents\dungeon siege\</span>.</span> <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">If you wish to use traditional Tank files, this directory will be your Tank's source, so make sure you have the directory tree correct. Open us <span class="SpellE">environmental.gas</span> that you just extracted and search for </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">fire_pit_fire_small</span></span><span style="font-family: Arial;">, once you have located it, select all of it and cut it (</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">ctrl + x</span><span style="font-family: Arial;">). Select the rest of the document (</span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">ctrl + a</span><span style="font-family: Arial;">) and press the delete key. Now, paste the </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">fire_pit_fire_small</span></span><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-family: Arial;">script back into the now empty document. Give it a new name, by changing the </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">name = <span class="SpellE">fire_pit_fire_small</span></span><span style="font-family: Arial;"> to something else.<span style=""> </span>Make sure you use no capitals or spaces. Save and close the document. Give it a new name as well. You might have noticed that there are a few other commands in the script that aren't listed above... I stripped down the script so it didn't contain anything we didn't need for the lesson, so you might want to just copy the script from the tutorial.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Now you are probably ready to actually do something. Open up the document again, and find the last parameter, </span><span class="SpellE"><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">ts</span></span></span><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">(</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">.5)</span><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-family: Arial;">and type in </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">color0(1,.5,.5)</span><span style="font-family: Arial;"> directly after it, but not outside the quotation mark. Your script should now look like this:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">[<span class="SpellE">effect_script</span>*]<br />{<br /><span style=""> </span>name = <span class="SpellE">fire_pit_fire_small</span>;<br /><br /><span style=""> </span>script = [[<br /><br /><span style=""> </span><span class="SpellE">sfx</span> create fire<span class="SpellE"> #TARGET<br /></span><span style=""> </span><span style=""> </span><span style=""> </span>"instant()offset(0,.25,0)scale(1)<span class="SpellE">ts</span>(.5)color0(1,.5,.5)";<br /><span style=""> </span><span class="SpellE">sfx</span> start #POP;<br /><br /><span style=""> </span>]];<br />}<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Save the script, Tank it if you aren't using the Bits folder, and open up DSMOD.exe. If you already have it open, you won't be able to Tank the files, close it down. If it's open and your using Bits, then make sure your not currently flaming, if you are, bring up the console and type </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> stop scripts</span><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-family: Arial;">to stop the effect script from running, then type </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> reload</span><span style="font-size: 10pt; font-family: 'Courier New';"> </span><span style="font-family: Arial;">to reload any <span class="SpellE">sfx</span> scripts that have been changed since the last time they were loaded. Once you are done reloading the scripts (you won't need to reload the scripts if you didn't have DSMOD.exe open when editing the script), run your script like you did last time (</span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">sfx</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';"> run <span class="SpellE">yourscriptname</span></span><span style="font-family: Arial;">), except use your new script name instead of </span><span class="SpellE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">fire_pit_fire_small</span></span><span style="font-family: Arial;">. You should see a red flame... <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span class="SpellE"><span style="font-family: Arial;">Ack</span></span><span style="font-family: Arial;">! Well, since it isn't actually hurting, you don't need to put it out this time. <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;"><v:shape id="_x0000_i1025" style="width: 231pt; height: 231pt;" type="#_x0000_t75" coordsize="21600,21600"><v:imagedata title="flameguy02" src="Siege%20FX%20Tutorial%20%231%20-%20Getting%20Started_files/image001.jpg"></v:imagedata></v:shape><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Observe the flame... Notice how it fades out so fast? Bah! Let’s change that...<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">If you have using the Bits folder, Leave DSMOD.exe open this time, minimize it (alt + tab if you’re in full screen). If you are using Tanks, you need to close it. Insert another parameter into your script. Just like you did before, add it before the first parameter, but inside the double quotation mark. Add the parameter, </span><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">alphafade(</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">.5)</span><span style="font-family: Arial;"> parameter to the script. Save the script, go back into DSMOD, stop the scripts, reload the scripts, and play it again. The flame should last about twice as long... Let’s see a definition:<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">- <span class="GramE"><b>alphafade(</b></span><b>x): </b><i>Using this parameter changes the length of time before the particle is faded from existence, pretty straight forward. The lower the value, the longer it lasts. The default value is 1.<o:p></o:p></i></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">Everything should be going smoothly, so let’s change the size of the flame. Go ahead and edit the script and change the </span><span class="GramE"><span style="font-size: 10pt; color: red; font-family: 'Courier New';">scale(</span></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">1)</span><span style="font-family: Arial;"> parameter to a higher value... See what you get.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">It seems that we are done with our tutorial for the time being. Continue to edit the </span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">fire</span><span style="font-family: Arial;"> base effect by adding more and more parameters. Please check the Resources section below for some useful information.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Resources<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">These are various resources I find <i>very</i> useful.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/index.shtml">Dungeon Siege's Main Site</a> (Take a look around. Contains various mod resources, as well as the Dungeon Siege Toolkit)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.game-editing.net/forum/index.php?c=3">Game-Editing.net Dungeon Siege Forums</a> (If you plan of modifying Dungeon Siege, this is the place to be. Make sure to make use of the search function.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://www.dungeonsiege.com/su_212.shtml">Siege FX Siege University Course</a> (Contains a list of the 22 base effects, a list of all possible parameters for those 22 base effects, and more. A great resource indeed.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="http://dsc.conflict-imminent.com/">Dungeon Siege Cosmetics</a> (Home of this tutorial.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span><a href="mailto:jomdom@hotmail.com?subject=Siege%20FX%20Tutorial">Jomdom's E-Mail</a> (Feel free to e-mail me with <i>any</i> questions you have about this tutorial.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">In the Future<o:p></o:p></span></u></b></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><span style="font-family: Arial;">This tutorial was very simple, I’ll admit. Expect more and more advanced tutorials in the future. I will try to explain everything that’s going on in any Siege FX script that is included in any of my tutorials, so as long as you pay attention, and <i>experiment, </i>you won't have to worry about falling behind.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in;"><b><u><span style="font-family: Arial;">Credits</span></u></b><span style="font-family: Arial;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span>Icemage - You have really helped me with the more advanced aspects of Siege FX. I thank you, Icemage.<o:p></o:p></span></p> <p class="MsoNormal" style="margin: 5pt 0.5in 5pt 0in; text-indent: 0in;"><span style="font-family: Symbol;"><span style="">·</span></span><span style="font-family: Arial;"><span style=""> </span>Gas Powered Games - You make a killer effects engine! Great <span class="GramE">job,</span> can't wait for Dungeon Siege 2's version of Siege FX.<o:p></o:p></span></p>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-43867948163757824302009-01-02T01:43:00.000-08:002009-01-02T01:46:32.575-08:00Struts Tutorials - Jakarta Struts Tutorial<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="0" name="footer"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Code"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="No List"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:1627400839 -2147483648 8 0 66047 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h1 {mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"Heading 1 Char"; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:1; font-size:20.0pt; font-family:"Times New Roman","serif"; color:navy; mso-fareast-language:EN-US; font-weight:bold;} p.MsoHeader, li.MsoHeader, div.MsoHeader {mso-style-unhide:no; mso-style-link:"Header Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} p.MsoFooter, li.MsoFooter, div.MsoFooter {mso-style-unhide:no; mso-style-link:"Footer Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {mso-style-unhide:no; color:#0000AA; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p {mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} code {mso-style-unhide:no; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} pre {mso-style-unhide:no; mso-style-link:"HTML Preformatted Char"; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Heading 1"; mso-ansi-font-size:20.0pt; mso-bidi-font-size:20.0pt; color:navy; mso-font-kerning:18.0pt; mso-fareast-language:EN-US; font-weight:bold;} span.klink {mso-style-name:klink; mso-style-unhide:no;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"HTML Preformatted"; font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New"; mso-fareast-language:EN-US;} p.bulletted, li.bulletted, div.bulletted {mso-style-name:bulletted; mso-style-unhide:no; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} span.bodycopy {mso-style-name:bodycopy; mso-style-unhide:no;} span.HeaderChar {mso-style-name:"Header Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Header; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; mso-fareast-language:EN-US;} span.FooterChar {mso-style-name:"Footer Char"; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:Footer; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:45.0pt 1.25in .5in 1.25in; mso-header-margin:.5in; mso-footer-margin:13.5pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:236092899; mso-list-template-ids:1666460680;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l1 {mso-list-id:288052733; mso-list-template-ids:233063626;} @list l1:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l2 {mso-list-id:433988174; mso-list-template-ids:1756934910;} @list l2:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l3 {mso-list-id:474026723; mso-list-template-ids:-1499409108;} @list l3:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l3:level2 {mso-level-number-format:bullet; mso-level-text:o; mso-level-tab-stop:1.0in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:"Courier New"; mso-bidi-font-family:"Times New Roman";} @list l4 {mso-list-id:479271437; mso-list-template-ids:1044027326;} @list l4:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l5 {mso-list-id:624048226; mso-list-template-ids:-1723574594;} @list l5:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l6 {mso-list-id:661663570; mso-list-template-ids:218645160;} @list l6:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l7 {mso-list-id:788666767; mso-list-template-ids:-2120823498;} @list l7:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l8 {mso-list-id:791552305; mso-list-template-ids:495767210;} @list l8:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l9 {mso-list-id:937906835; mso-list-template-ids:1151794064;} @list l9:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l10 {mso-list-id:962690233; mso-list-template-ids:1430798880;} @list l10:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l11 {mso-list-id:1025015153; mso-list-template-ids:1640935548;} @list l11:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l12 {mso-list-id:1038703944; mso-list-template-ids:-1089975872;} @list l12:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l13 {mso-list-id:1098788438; mso-list-template-ids:-827194196;} @list l13:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l14 {mso-list-id:1116025428; mso-list-template-ids:104869516;} @list l14:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l15 {mso-list-id:1121652809; mso-list-template-ids:59537384;} @list l15:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l16 {mso-list-id:1292595309; mso-list-template-ids:-1860165442;} @list l16:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l17 {mso-list-id:1385519148; mso-list-template-ids:-1671298158;} @list l17:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l18 {mso-list-id:1467773091; mso-list-template-ids:-149753348;} @list l18:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l19 {mso-list-id:1516262922; mso-list-template-ids:775985114;} @list l19:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l20 {mso-list-id:1959678785; mso-list-template-ids:1400647504;} @list l20:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l21 {mso-list-id:2056730369; mso-list-template-ids:-765921968;} @list l21:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l22 {mso-list-id:2094550254; mso-list-template-ids:-204935122;} @list l22:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This complete reference of Jakarta Struts shows you how to develop Struts applications using ant and deploy on the JBoss Application Server. Ant script is provided with the example code. Many advance topics like Tiles, Struts Validation Framework, Java Script validations are covered in this tutorial. <o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/strutsguide.shtml"><b><span style="color: windowtext;">Introduction to the Apache Struts</span></b></a>
<br /> This lesson is an introduction to the Struts and its architecture.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/mvc-architecture.shtml"><span style="color: windowtext;">MVC Architecture</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> The main aim of the MVC architecture is to separate the business logic and application data from the presentation data to the user.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml"><span style="color: windowtext;">Struts Architecture</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> Struts is an open source framework used for developing J2EE web applications using Model View Controller (MVC) design pattern. It uses and extends the <a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">Java Servlet</span></span></a> API to encourage developers to adopt an MVC architecture.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/how-struts-works.shtml"><b><span style="color: windowtext;">How Struts Works?</span></b></a>
<br /> The basic purpose of the Java Servlets in struts is to handle requests made by the client or by web browsers. In struts JavaServerPages (<a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">JSP</span></span></a>) are used to design the dynamic web pages. In struts, servlets helps to route request which has been made by the web browsers to the appropriate ServerPage.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/understanding_struts_controller.shtml"><b><span style="color: windowtext;">Introduction to the Struts Controller</span></b></a>
<br /> This lesson is an introduction to Controller part of the Struts Framework.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml"><b><span style="color: windowtext;">Introduction to the Struts Action Class</span></b></a>
<br /> This lesson is an introduction to Action Class of the Struts Framework.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/strutsActionForms.shtml"><b><span style="color: windowtext;">Using Struts ActionFrom Class</span></b></a>
<br /> This shows how to create user interface form using struts ActionFrom class and jsp page.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml"><b><span style="color: windowtext;">Using Struts HTML Tags</span></b></a>
<br /> Section shows you the different types of Struts <a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">HTML Tags</span></span></a> available for the development of views in JSP.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts_validator_framework.shtml"><b><span style="color: windowtext;">Introduction to Struts Validator Framework</span></b></a>
<br /> Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the <a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">users browser</span></span></a> as well as on the server side.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/address_struts_validator.shtml"><b><span style="color: windowtext;">Client Side Address Validation in Struts</span></b></a>
<br /> In this lesson we will create JSP page for entering the address and use the functionality provided by Validator Framework to validate the user data on the browser.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml"><b><span style="color: windowtext;">Custom Validators Example</span></b></a>
<br /> In this tutorial you will learn how to develop Custom Validators in your Struts 1.3 <a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">applications</span></span></a>. Struts Validator framework provides many validation rules that can be used in the web applications. If you application needs special kind of validation, then you can extend the validator framework to develop your own validation rule.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts_tiles.shtml"><b><span style="color: windowtext;">Developing Application with Struts Tiles</span></b></a>
<br /> In this lesson we will create Struts Tiles Applications.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/using-tiles-defs-xml.shtml"><b><span style="color: windowtext;">Using tiles-defs.xml in Tiles Application</span></b></a>
<br /> In this lesson you will learn how to define and use the "plugin" definitation in tiles-defs.<a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">xml file</span></span></a>.
<br />
<br /> <b>Advance Struts
<br /> </b><o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/DynaActionForm.shtml"><b><span style="color: windowtext;">Struts DynaActionForm</span></b></a>
<br /> In this lesson we will create Struts DynaActionForm.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/strutsfileupload.shtml"><b><span style="color: windowtext;">Struts File Upload</span></b></a>
<br /> In this lesson we will create Struts File Upload program.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/strutsfileuploadandsave.shtml"><span style="color: windowtext;">Struts file upload and save on server</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> In this tutorial you will learn how to use Struts program to upload on the <a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">Server</span></span></a> and display a link to the user to download the uploaded file .
<br />
<br /> <b>Struts Actions Examples
<br /> </b> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts-built-in-actions.shtml"><span style="color: windowtext;">Struts Built-In Actions</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> In this section we will give a quick look to the few of built-in utility actions shipped with Struts APIs. These built-in utility actions provide different functionalities useful to diverse applications.<b>
<br /> </b> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts-dispatch-action.shtml"><span style="color: windowtext;">Struts Dispatch Action Example</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> Here in this example you will learn more about Struts Dispatch Action that will help you grasping the concept better.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts-forward-action.shtml"><b><span style="color: windowtext;">Struts Forward Action</span></b></a>
<br /> <b>In this section we will learn about Struts ForwardAction </b>(org.<a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.actions.ForwardAction). The ForwardAction is one of the Built-in Actions that is shipped with struts framework.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts-LookupDispatchAction.shtml"><span style="color: windowtext;">Struts LookupDispatchAction Example</span></a>
<br /> Struts LookupDispatch Action</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> (org.apache.struts.actions.LookupDispatchAction) is one of the Built-in Actions provided along with the struts framework.<b>
<br /> </b> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts-MappingDispatchAction.shtml"><span style="color: windowtext;">Struts MappingDispatchAction Example</span></a>
<br /> Struts MappingDispatch Action</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> (org.apache.struts.actions.MappingDispatchAction) is one of the Built-in Actions provided along with the struts framework.<b>
<br /> </b> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/struts-action-aggregating-actions.shtml"><b><span style="color: windowtext;">STRUTS ACTION - AGGREGATING ACTIONS IN STRUTS</span></b></a>
<br /> In this article we will see how to achieve this. Struts provides four important classes for this
<br /> purpose.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/aggregating-actions-struts.shtml"><span style="color: windowtext;">Aggregating Actions In Struts Revisited</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> An action aggregation is a grouping of a set of related actions into a single unified action in order to eliminate the need to write a new action class for every action. In this part, I will walk through a full-fledged practical example of each of the types presented in Part I namely the DispatchAction , LookupDispatchAction , MappingDispatchAction and ActionDispatcher along with two new aggregations which slightly differ in syntax but are more efficient than the previous ones.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/set-mapping-name.shtml"><span style="color: windowtext;">Set the mapping name example</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> Set the mapping name to the action attribute of html:link
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/set-action-name.shtml"><span style="color: windowtext;">Set the action name example</span></a></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> Set the action name to the action attribute of html:link <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml"><b><span style="color: windowtext;">Configuring Struts DataSource Manager on Tomcat 5</span></b></a>
<br /> In this lesson we will create example to Configure Struts DataSource Manager on <a href="http://www.roseindia.net/struts/" target="_top"><span class="klink"><span style="color: windowtext;">Tomcat</span></span></a>
<br /> <o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><a href="http://www.roseindia.net/struts/strutsguide.shtml"><b><span style="color: windowtext;">Introduction to the Apache Struts</span></b></a>
<br /> <!--[if !supportLineBreakNewLine]-->
<br /> <!--[endif]--><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This tutorial is extensive guide to the Struts Framework. In this tutorial you will learn how to develop robust <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> using Jakarta Struts Framework. This tutorial assumes that the reader is familiar with the web application development with JSP, Servlets, JDBC and <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">custom tags</span></span></a>. To begin with let's understand the Jakarta Struts Framework.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What is Struts?<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts Frame work is the implementation of Model-View-Controller (MVC) design pattern for the JSP. Struts is maintained as a part of Apache Jakarta project and is <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">open source</span></span></a>. Struts Framework is suited for the application of any size. Latest version of struts can be downloaded from <a href="http://jakarta.apache.org/"><span style="color: windowtext;">http://jakarta.apache.org/</span></a>. We are using jakarta-struts-1.1 and jakarta-<a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">tomcat</span></span></a>-5.0.4 for this tutorial.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What is Model-View-Controller (MVC) Architecture?<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Model-View-Controller architecture is all about dividing application components into three different categories Model, View and the Controller. Components of the MVC architecture has unique responsibility and each component is independent of the other component. Changes in one component will have no or less impact on other component. Responsibilities of the components are:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Model:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Model is responsible for providing the data from the <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">database</span></span></a> and saving the data into the data store. All the business logic are implemented in the Model. Data entered by the user through View are check in the model before saving into the database. <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Data access</span></span></a>, Data validation and the data saving logic are part of Model. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">View: </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">View represents the user view of the application and is responsible for taking the input from the user, dispatching the request to the controller and then receiving response from the controller and displaying the result to the user. HTML, <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JSPs</span></span></a>, Custom Tag Libraries and Resources files are the part of view component.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Controller:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Controller is intermediary between Model and View. Controller is responsible for receiving the request from client. Once request is received from client it executes the appropriate business logic from the Model and then produce the output to the user using the View component. ActionServlet, Action, ActionForm and struts-config.<a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a> are the part of Controller. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:formulas> <v:path extrusionok="f" gradientshapeok="t" connecttype="rect"> <o:lock ext="edit" aspectratio="t"> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:225pt;"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png" href="http://www.roseindia.net/struts/strutsstructure.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.jpg" shapes="_x0000_i1025" border="0" width="300" height="276" /><!--[endif]--><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Setting Up Development Environment <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Installing JDK:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Download JDK 1.4 or above from <a href="http://java.sun.com/"><span style="color: windowtext;">sun site</span></a>. Follow the instruction given in the installation manual and install JDK.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Installing Tomcat:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Download Tomcat from the <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a> site and install it. I have downloaded <a href="http://jakarta.apache.org/tomcat/"><span style="color: windowtext;">jakarta-tomcat-5.0.4</span></a> and installed for this tutorial. To test your installation go to your installation <b>directory/bin</b> and issue startup command to run the <a href="http://www.roseindia.net/struts/strutsguide.shtml" target="_top"><span class="klink"><span style="color: windowtext;">server</span></span></a>. Open browser and type <a href="http://localhost:8080/"><span style="color: windowtext;">http://localhost:8080/</span></a> to test the server. It should display the welcome page. If not consult tomcat documentation before going further.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Installing Struts Application:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Download latest version of Struts from the official site of Struts <a href="http://jakarta.apache.org/struts"><span style="color: windowtext;">http://jakarta.apache.org/struts</span></a>. Extract the file ito your favorite directory and copy <b>struts-blank.war</b>, <b>struts-documentation.war</b> and <b>struts-example.war</b> from "<b>jakarta-struts-1.1\webapps</b>" directtory into "<b>jakarta-tomcat-5.0.4\webapps</b>" directory.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">struts-blank.war</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> is the blank struts application which is useful in creating struts application from scratch. We will use this file to create our web application.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">struts-documentation.war</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> contains API and important documents for the struts application development.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">struts-example.war</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> is simple MailReader Demonstration Application.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">MVC Architecture<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The main aim of the MVC architecture is to separate the business logic and application data from the presentation data to the user.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here are the reasons why we should use the MVC <a href="http://www.roseindia.net/struts/mvc-architecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">design pattern</span></span></a>.<o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">They are <b>resuable</b> : When the problems recurs, there is no need to invent a new solution, we just have to follow the pattern and adapt it as necessary. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">They are <b>expressive</b>: By using the MVC design pattern our <a href="http://www.roseindia.net/struts/mvc-architecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> becomes more expressive. <o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">1). <b>Model:</b> The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">2). <b>View :</b> The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view's to maintain the consistency in its presentation when the model changes. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">3). <b>Controller:</b> Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. In GUIs, the views and the controllers often work very closely together.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Difference between Model 1 and Model 2 architecture:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Features of MVC1:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Html or jsp files are used to code the presentation. To retrieve the data JavaBean can be used. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In mvc1 archictecture all the view, control elements are implemented using Servlets or Jsp. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In MVC1 there is tight coupling between page and model as data access is usually done using Custom tag or through <a href="http://www.roseindia.net/struts/mvc-architecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java bean</span></span></a> call. <o:p></o:p></span></li></ol> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Features of MVC2:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The MVC2 architecture removes the page centric property of MVC1 architecture by separating Presentation, control logic and the application state. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In MVC2 architecture there is only one controller which receives all the request for the application and is responsible for taking appropriate action in response to each request. <o:p></o:p></span></li></ol> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">What is Struts - Struts Architecture<o:p></o:p></span></h1> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this section we will discuss about Architecture. Struts is famous for its robust Architecture and it is being used for developing small and big software projects. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts is an <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">open source</span></span></a> framework used for developing J2EE web applications using Model View Controller (MVC) design pattern. It uses and extends the <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Java Servlet</span></span></a> API to encourage developers to adopt an MVC architecture. Struts framework provides three key components:<o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A <b>request</b> handler provided by the <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application developer</span></span></a> that is used to mapped to a particular URI. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A <b>response</b> handler which is used to transfer the control to another resource which will be responsible for completing the response. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A <b>tag library</b> which helps developers to create the interactive form based applications with <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">server pages</span></span></a>.<o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts provides you the basic infrastructure infrastructure for implementing MVC allowing the developers to concentrate on the business logic.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">MVC Architecture</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The main aim of the MVC architecture is to separate the business logic and application data from the presentation data to the user.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here are the reasons why we should use the MVC <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">design pattern</span></span></a>.<o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">They are <b>resuable</b> : When the problems recurs, there is no need to invent a new solution, we just have to follow the pattern and adapt it as necessary. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">They are <b>expressive</b>: By using the MVC design pattern our <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> becomes more expressive. <o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">1). <b>Model:</b> The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">2). <b>View :</b> The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view's to maintain the consistency in its presentation when the model changes. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">3). <b>Controller:</b> Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. In GUIs, the views and the controllers often work very closely together.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Overview of the Struts Framework</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Struts framework is composed of approximately 300 classes and interfaces which are organized in about 12 top level packages. Along with the utility and helper classes framework also provides the classes and interfaces for working with controller and presentation by the help of the custom <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">tag libraries</span></span></a>. It is entirely on to us which model we want to choose. The view of the Struts architecture is given below:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Struts Controller Components:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Whenever a user request for something, then the request is handled by the Struts Action Servlet. When the ActionServlet receives the request, it intercepts the URL and based on the Struts <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Configuration files</span></span></a>, it gives the handling of the request to the Action class. Action class is a part of the controller and is responsible for communicating with the model layer. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Struts View Components:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The view components are responsible for presenting information to the users and accepting the input from them. They are responsible for displaying the information provided by the model components. Mostly we use the <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Java Server Pages</span></span></a> (JSP) for the view presentation. To extend the capability of the view we can use the Custom tags, <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java script</span></span></a> etc. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> The Struts model component:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The model components provides a model of the business logic behind a Struts program. It provides interfaces to databases or back- ends systems. Model components are generally a <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java class</span></span></a>. There is not any such defined format for a Model component, so it is possible for us to reuse <a href="http://www.roseindia.net/struts/StrutsArchitecture.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Java code</span></span></a> which are written for other projects. We should choose the model according to our client requirement. <o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">How Struts Works<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The basic purpose of the <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Java Servlets</span></span></a> in struts is to handle requests made by the client or by web browsers. In struts JavaServerPages (JSP) are used to design the dynamic web pages. In struts, servlets helps to route request which has been made by the web browsers to the appropriate ServerPage. The use of servlet as a <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">router</span></span></a> helps to make the web applications easier to design, create, and maintain. Struts is purely based on the Model- View- Contoller (MVC) design pattern. It is one of the best and most well developed <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">design patterns</span></span></a> in use. By using the MVC architecture we break the processing in three sections named Model, the View, and the Controller. Below we are describing the working of struts.<o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">As we all are well aware of the fact that each <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> we develop has a deployment descriptor i.e. <b>WEB-INF/web.xml</b>. This is the file which the container reads. This file has all the configuration information which we have defined for our <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">web application</span></span></a>. The configuration information includes the index file, the default welcome page, the mapping of our servlets including path and the extension name, any init parameters, information related to the context elements.
<br /> In the <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">file WEB</span></span></a>-INF/web.xml of struts application we need to configure the Struts ActionServlet which handles all the request made by the web browsers to a given mapping. ActionServlet is the central component of the Struts controller. This servlet extends the HttpServlet. This servlet basically performs two important things. <b>First is : </b>When the container gets start, it reads the Struts <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Configuration files</span></span></a> and loads it into memory in the <b>init()</b> method. You will know more about the Struts Configuration files below. <b>Second</b> <b>point is:</b> It intercepts the HTTP request in the <b>doGet()</b> and <b>doPost()</b> method and handles it appropriately.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In struts application we have another <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml file</span></span></a> which is a Struts configuration file named as <b>struts.config.xml</b>. The name of this file can be changed. The name of the struts configuration file can be configured in the web.xml file. This file is placed under the <b>WEB-INF</b> directory of the web application. It is an <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">XML document</span></span></a> that describes all or part of Struts application. This file has all the information about many types of Struts resources and configures their interaction. This file is used to associate paths with the controller components of your application., known as Action classes like <b><action path ="/login" type = "LoginAction"></b>. This tag tells the Struts <b>ActionServlet</b> that whenever the incoming request is <a href="http://myhost/myapp/login.do"><b><span style="color: windowtext;">http://myhost/myapp/login.do</span></b></a>, then it must invoke the controller component <b>LoginAction</b>. Above, you can see that we have written <b>.do</b> in the URL. This mapping is done to tell the web application that whenever a request is received with the <b>.do</b> extension then it should be appended to the URL.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">For each action we also have to configure Struts with the names of the resulting pages that will be shown as a result of that action. In our application there can be more than one view which depends on the result of an action. One can be for a <b>success</b> and the other for the <b>failure</b>. If the result action is "success" then the action tells the ActionServlet that the action has been successfully accomplished or vice- versa. The struts knows how to forward the specific page to the concerned destination. The model which we want to use is entirely to you, the model is called from within the controller components.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Action can also get associate with a JavaBean in our Struts configuration file. Java bean is nothing but a class having getter and setter methods that can be used to communicate between the view and the controller layer. These <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java beans</span></span></a> are validated by invoking the <b>validate()</b> method on the <b>ActionForm </b>by the help of the Struts system. The client sends the request by the normal form submission by using Get or Post method, and the Struts <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">system</span></span></a> updates that data in the Bean before calling the controller components.
<br /> <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The view we use in the struts can be either Jsp page, Velocity templates, XSLT pages etc. In struts there are set of <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JSP tags</span></span></a> which has been bundled with the struts distribution, but it is not mandatory to use only Jsp tags, even plain HTML files can be used within our Struts application but the disadvantage of using the html is that it can't take the full advantage of all the dynamic features provided in the struts framework.
<br /> The framework includes a set of custom <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">tag libraries</span></span></a> that facilitate in creating the user interfaces that can interact gracefully with ActionForm beans. The struts Jsp taglibs has a number of generic and struts specific tags tags which helps you to use dynamic data in your view. These tags helps us to interact with your controller without writing much <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java code</span></span></a> inside your jsp. These tags are used create forms, internally forward to other pages by interacting with the bean and helps us to invoke other actions of the web application.
<br /> There are many tags provided to you in the struts frameworks which helps you in sending <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">error messages</span></span></a>, internationalization etc.
<br /> <o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Note: The points we have described above will be in effect if and only if when the ActionServlet is handling the request. When the request is submitted to the container which call the ActionServlet, make sure that the extension of the file which we want to access should have the extension .<b>do</b>.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts working:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style="'width:420pt;height:279pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image003.gif" href="http://www.roseindia.net/struts/struts-flow.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image003.gif" shapes="_x0000_i1026" border="0" width="560" height="372" /><!--[endif]--><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Process flow:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">web.xml :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Whenever the container gets start up the first work it does is to check the web.xml file and determine what struts action Servlets exist. The container is responsible for mapping all the file request to the correct action Servlet. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A Request :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> This is the second step performed by the container after checking the web.xml file. In this the user submits a form within a browser and the request is intercepted by the controller. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Controller :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> This is the heart of the container. Most Struts application will have only one controller that is ActionServlet which is responsible for directing several Actions. The controller determines what action is required and sends the information to be processed by an action Bean. The key advantage of having a controller is its ability to control the flow of logic through the highly controlled, centralized points. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">struts.config.xml :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Struts has a configuration file to store mappings of actions. By using this file there is no need to hard code the module which will be called within a component. The one more responsibility of the controller is to check the struts.config.xml file to determine which module to be called upon an action request. Struts only reads the struts.config.xml file upon start up. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Model :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> The model is basically a business logic part which takes the response from the user and stores the result for the duration of the process. This is a great place to perform the preprocessing of the data received from request. It is possible to reuse the same model for many page requests. Struts provides the ActionForm and the Action classes which can be extended to create the model objects. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">View :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> The view in struts framework is mainly a jsp page which is responsible for producing the output to the user. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts tag libraries :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> These are struts components helps us to integrate the struts framework within the project's logic. These struts tag libraries are used within the <a href="http://www.roseindia.net/struts/how-struts-works.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JSP</span></span></a> page. This means that the controller and the model part can't make use of the tag library but instead use the struts class library for strut process control. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Property file</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> : It is used to store the messages that an object or page can use. Properties files can be used to store the titles and other string data. We can create many property files to handle different languages. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Business objects :</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> It is the place where the rules of the actual project exists. These are the modules which just regulate the day- to- day site activities. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Response </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: This is the output of the View JSP object. <o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Understanding Struts Controller<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this section I will describe you the Controller part of the <a href="http://www.roseindia.net/struts/understanding_struts_controller.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Struts</span></span></a> Framework. I will show you how to configure the struts-config.xml file to map the request to some destination servlet or jsp file. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The class <i>org.<a href="http://www.roseindia.net/struts/understanding_struts_controller.shtml" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.action.ActionServlet</i> is the heart of the Struts Framework. It is the Controller part of the Struts Framework. <i>ActionServlet</i> is configured as Servlet in the <b>web.xml </b>file as shown in the following <a href="http://www.roseindia.net/struts/understanding_struts_controller.shtml" target="_top"><span class="klink"><span style="color: windowtext;">code snippets</span></span></a>.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 424.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="566"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 417pt;" width="556"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!-- Standard Action Servlet Configuration (with debugging) -->
<br /> <servlet>
<br /> <servlet-name>action</servlet-name>
<br /> <b><servlet-class>org.apache.struts.action.ActionServlet</servlet-class></b>
<br /> <init-param>
<br /> <param-name>config</param-name>
<br /> <param-value>/WEB-INF/struts-config.<a href="http://www.roseindia.net/struts/understanding_struts_controller.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a></param-value>
<br /> </init-param>
<br /> <init-param>
<br /> <param-name>debug</param-name>
<br /> <param-value>2</param-value>
<br /> </init-param>
<br /> <init-param>
<br /> <param-name>detail</param-name>
<br /> <param-value>2</param-value>
<br /> </init-param>
<br /> <load-on-startup>2</load-on-startup>
<br /> </servlet><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This servlet is responsible for handing all the request for the Struts Framework, user can map the specific pattern of request to the ActionServlet. <b><servlet-mapping></b> tag in the <b>web.xml</b> file specifies the url pattern to be handled by the servlet. By default it is <b>*.do</b>, but it can be changed to anything. Following code form the <b>web.xml </b>file shows the mapping.<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="400"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!-- Standard Action Servlet Mapping -->
<br /> <servlet-mapping>
<br /> <servlet-name>action</servlet-name>
<br /> <b><url-pattern>*.do</url-pattern></b>
<br /> </servlet-mapping><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The above mapping maps all the requests ending with <b>.do</b> to the ActionServlet. ActionServlet uses the configuration defined in struts-config.<a href="http://www.roseindia.net/struts/understanding_struts_controller.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml file</span></span></a> to decide the destination of the request. Action Mapping Definitions (described below) is used to map any action. For this lesson we will create Welcome.jsp file and map the "Welcome.do" request to this page.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <b>Welcome.jsp</b><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="400"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<br /> <%@ taglib uri="/tags/struts-html" prefix="html" %>
<br /> <html:html locale="true">
<br /> <head>
<br /> <title><bean:message key="welcome.title"></title>
<br /> <html:base/>
<br /> </head>
<br /> <body bgcolor="white">
<br /> <<a href="http://www.roseindia.net/struts/understanding_struts_controller.shtml" target="_top"><span class="klink"><span style="color: windowtext;">h3</span></span></a>><bean:message key="welcome.heading"></h3>
<br /> <p><bean:message key="welcome.message"></p>
<br /> </body>
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Forwarding the Welcome.do request to Welcome.jsp</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The "Action Mapping Definitions" is the most important part in the <b>struts-config.xml</b>. This section takes a form defined in the "Form Bean Definitions" section and maps it to an action class.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Following code under the <action-mappings> tag is used to forward the request to the Welcome.jsp.<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="400"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action>path="/Welcome"
<br /> forward="/pages/Welcome.jsp"</b>/>
<br /> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To call this Welcome.jsp file we will use the following code.<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="400"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><<b>html:link</b> page="<b>/Welcome.do</b>">First Request to the controller</html:link> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Once the use clicks on on First Request to the controller link on the index page, request (for <b>Welcome.do</b>) is sent to the Controller and the controller forwards the request to <b>Welcome.jsp</b>. The content of <b>Welcome.jsp</b> is displayed to the user.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Understanding <a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Struts</span></span></a> Action Class<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this lesson I will show you how to use Struts Action Class and forward a jsp file through it. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What is Action Class?</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">An Action class in the struts <a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> extends Struts 'org.apache.struts.action.Action" Class. Action class acts as wrapper around the business logic and provides an inteface to the application's Model layer. It acts as glue between the View and Model layer. It also transfers the data from the view layer to the specific business process layer and finally returns the procssed data from business layer to the view layer.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">An Action works as an adapter between the contents of an incoming HTTP request and the business logic that corresponds to it. Then the struts controller (ActionServlet) slects an appropriate Action and creates an instance if necessary, and finally calls execute method.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To use the Action, we need to Subclass and overwrite the execute() method. In the Action Class don't add the business process logic, instead move the <a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml" target="_top"><span class="klink"><span style="color: windowtext;">database</span></span></a> and business process logic to the process or dao layer.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The ActionServlet (commad) passes the parameterized class to Action Form using the <i>execute()</i> method. The return type of the execute method is <i>ActionForward</i> which is used by the Struts Framework to forward the request to the file as per the value of the returned <i>ActionForward</i> object.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing our Action Class?</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Our Action class (TestAction.<a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java</span></span></a>) is simple class that only forwards the TestAction.jsp. Our Action class returns the <i>ActionForward</i> called "testAction", which is defined in the struts-config.<a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml file</span></span></a> (action mapping is show later in this page). Here is code of our Action Class:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">TestAction.java</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 415.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="554"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 408pt;" width="544"> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 408pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="544"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.<a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.action.Action;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">TestAction <b>extends </b>Action</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward execute(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("testAction");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /><b>Understanding Action Class
<br /></b>Here is the signature of the Action Class.<o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";">public ActionForward <b>execute</b>(ActionMapping mapping,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>ActionForm form,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>javax.servlet.http.HttpServletRequest request,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>javax.servlet.http.HttpServletResponse response)<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>throws java.lang.Exception<o:p></o:p></span></pre> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Action Class process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it), with provision for handling exceptions thrown by the business logic. Return an <code><span style="font-family: "Tahoma","sans-serif";">ActionForward</span></code> instance describing where and how control should be forwarded, or <code><span style="font-family: "Tahoma","sans-serif";">null</span></code> if the response has already been completed.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Parameters:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">mapping</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> - The ActionMapping used to select this instance <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">form</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> - The optional ActionForm bean for this request (if any) <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">request</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> - The HTTP request we are processing <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">response</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> - The HTTP response we are creating <o:p></o:p></span></p> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Throws:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 0.5in;"><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Action class throws java.lang.Exception</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> - if the application business logic throws an exception <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Adding the Action Mapping in the struts-config.xml
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To test the application we will add a link in the index.jsp
<br /><b><html:link page="/TestAction.do">Test the Action</html:link></b><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Following code under the <action-mappings> tag is used to for mapping the <b>TestAction</b> class.<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="400"> <tbody><tr style=""> <td style="padding: 0.75pt;"><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><action<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>path="/TestAction"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>type="roseindia.net.TestAction"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><forward name="testAction" path="/pages/TestAction.jsp"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></action><span style=""> </span><span style=""> </span><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To test the new application click on <b>Test the Action </b>link on the index page. The content of TestAction.jsp should be displayed on the user browser.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style="'width:351pt;height:240pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image004.png" href="http://www.roseindia.net/struts/testaction.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image005.jpg" shapes="_x0000_i1027" border="0" width="468" height="320" /><!--[endif]--><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this lesson you learned how to create Action Class and add the mappings in the struts-config.<a href="http://www.roseindia.net/struts/understandingstruts_action_class.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a>. Our Action Class returns the <i>ActionForward</i> mapping of the TestAction.jsp.<o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">The ActionForm Class<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this lesson you will learn about the ActionForm in detail. I will show you a good example of ActionForm. This example will help you understand Struts in detail. We will create user interface to accept the address details and then validate the details on server side. On the successful validation of data, the data will be sent to model (the action class). In the Action class we can add the business processing logic but in this case we are just forwarding it to the sucess.jsp. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What is ActionForm?
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">An ActionForm is a JavaBean that extends <code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm</span></code>. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">We will first create the class AddressForm which extends the ActionForm class. Here is the code of the class:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">AddressForm.java</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.*;</span></code>
<br />
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Deepak Kumar</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email roseindia_net@yahoo.com</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * Form bean for the Address Entry Screen.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> *</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">AddressForm <b>extends </b>ActionForm</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>private </b>String name=<b>null</b>;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>private </b>String address=<b>null</b>;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>private </b>String emailAddress=<b>null</b>;</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public void </b>setName(String name){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.name=name;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>String getName(){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return this</b>.name;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public void </b>setAddress(String address){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.address=address;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>String getAddress(){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return this</b>.address;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public void </b>setEmailAddress(String emailAddress){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.emailAddress=emailAddress;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>String getEmailAddress(){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return this</b>.emailAddress;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> /**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * Reset all properties to their default values.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> *</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @param mapping The mapping used to select this instance</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @param request The servlet request we are processing</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> */</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public void </b>reset(ActionMapping mapping, HttpServletRequest request) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.name=<b>null</b>;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.address=<b>null</b>;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.emailAddress=<b>null</b>;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> /**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * Reset all properties to their default values.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> *</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @param mapping The mapping used to select this instance</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @param request The servlet request we are processing</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @return errors</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> */</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionErrors validate( </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping, HttpServletRequest request ) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionErrors errors = <b>new </b>ActionErrors();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>( getName() == <b>null </b>|| getName().length() <></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> errors.add("name",new ActionMessage("error.name.required"));</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>( getAddress() == <b>null </b>|| getAddress().length() <></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> errors.add("address",new ActionMessage("error.address.required"));</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>( getEmailAddress() == <b>null </b>|| getEmailAddress().length() <></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> errors.add("emailaddress",new ActionMessage("error.emailaddress.required"));</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>errors;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The above class populates the Address Form data and validates it. The validate() method is used to validate the inputs. If any or all of the fields on the form are blank, error messages are added to the ActionMapping object. Note that we are using <code><span style="font-family: "Tahoma","sans-serif";">ActionMessage class, ActionError is now deprecated and will be removed in next version.</span></code><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Now we will create the Action class which is the model part of the application. Our action class simply forwards the request the Success.jsp. Here is the code of the AddressAction class:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">AddressAction.java</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 415.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="554"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 408pt;" width="544"> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Deepak Kumar</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email roseindia_net@yahoo.com</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.Action;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">AddressAction <b>extends </b>Action</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward execute(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("success");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Now we have to create an entry for form bean in the struts-config.xml. Add the following lines in the struts-config.xml file:<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><form-bean
<br />name="AddressForm"
<br />type="roseindia.net.AddressForm"/><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the struts-config.xml file for handling the action "/Address.do":<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/Address"
<br /> type="roseindia.net.AddressAction"
<br /> name="AddressForm"
<br /> scope="request"
<br /> validate="true"
<br /> input="/pages/Address.jsp">
<br /> <forward name="success" path="/pages/success.jsp">
<br /></action><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Now create Address.jsp, which is our form for entering the address details. Code for Address.jsp is as follows:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Address.jsp</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 402pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="536"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 477.75pt;" valign="top" width="637" nowrap="nowrap"><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><%@ taglib uri="/tags/struts-bean" prefix="bean" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><span style=""> </span><%@ taglib uri="/tags/struts-html" prefix="html" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:html locale="true"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><head><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><title><bean:message key="welcome.title"></title><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:base/><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></head><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><body bgcolor="white"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:form action="/Address"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:errors/><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><table><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="center" colspan="2"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><span style="font-size:130%;">Please Enter the Following Details</span><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <span style=""> </span></tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="right"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>Name<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="left"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:text property="name" size="30" maxlength="30"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="right"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>Address<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="left"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:text property="address" size="30" maxlength="30"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="right"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>E-mail address<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="left"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:text property="emailAddress" size="30" maxlength="30"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><span style=""> </span><td align="right"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:submit>Save</html:submit><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><td align="left"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><html:cancel>Cancel</html:cancel><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></table><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></html:form><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></body><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></html:html><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">User enter the values in the form and click on the submit form. Form validation is done on the server side and error message is displays on the jsp page. To display the error on the jsp page <b><html:errors/> </b>tag is used. The <b><html:errors/></b> tag displays all the errors in one go. To create text box <b><html:text></b> is used in jsp page. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">e.g.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:text property="address" size="30" maxlength="30"></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Above tag creates text box for entering the address. The address is retrieved from and later stored in the property named address in the form-bean. The tag <b><html:submit>Save</html:submit></b> creates the submit button and the tag <b><html:cancel>Cancel</html:cancel></b> is used to create the Cancel button. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to create a link for testing the Address.jsp form:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:link page="/pages/Address.jsp">Test the Address Form</html:link></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Build the application and click on the <b>Test the Address Form</b> link on the index page to test the newly created screen. You should see the following screen.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" alt="" style="'width:249pt;height:147.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image006.gif" href="http://www.roseindia.net/struts/address.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image006.gif" shapes="_x0000_i1028" border="0" width="332" height="197" /><!--[endif]--><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this lesson you learned how to create data entry form using struts, validate and finally send process the business logic in the model part of the struts.<o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts HTML Tags<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts provides <a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml" target="_top"><span class="klink"><span style="color: windowtext;">HTML tag</span></span></a> library for easy creation of user interfaces. In this lesson I will show you what all Struts HTML Tags are available to the <a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JSP</span></span></a> for the development of user interfaces.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To use the Struts HTML Tags we have to include the following line in our JSP file:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/tags/struts-html" prefix="html" %></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">above code makes available the tag to the jsp.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 98%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="98%"> <tbody><tr style=""> <td colspan="2" style="padding: 0in; width: 100%;" valign="top" width="100%"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts HTML Tags</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:message key="thekey"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Looks up the message corresponding to the given key in the message resources and displays it.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:password property="prop" size="10"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates the password field. The string is stored in the property named prop in the form bean.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:text property="text1" size="5"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates the <a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml" target="_top"><span class="klink"><span style="color: windowtext;">text field</span></span></a>. The string is retrieved from and later stored in the property named text1 in the form bean.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:submit>Submit</html:submit><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates a submit button with the provided content as the button text. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:reset>Reset</html:reset><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates a reset button with the provided content as the button text. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:errors/><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag prints all the available error on the page.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:file property="fileSelectionBox"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates the file upload element on the form. The property must be of the type org.<a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.upload.FormFile.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:checkbox property="myCheckBox"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates check box on the form.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:hidden property="hiddenfield"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates the hidden <a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml" target="_top"><span class="klink"><span style="color: windowtext;">html element</span></span></a> on the form.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:radio value="abc" property="myCheckBox"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates the check box on the form.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:select multiple="true" property="selectBox"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates list box on the form. The property selectBox must be an array of supported <a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml" target="_top"><span class="klink"><span style="color: windowtext;">data-types</span></span></a>, and the user may select several entries. Use <code><span style="font-family: "Tahoma","sans-serif";"><html:options></span></code> to specify the entries.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:textarea property="myTextArea" value="Hello Struts"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag creates the text area on the form.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:form action="/Address" method="post"><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag is used to create the <a href="http://www.roseindia.net/struts/strutsHtmlTags.shtml" target="_top"><span class="klink"><span style="color: windowtext;">HTML Form</span></span></a> for posting the data on the server.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:base/><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag generates the base tag. <code><span style="font-family: "Tahoma","sans-serif";"><base></span></code> tells the browser to pretend that the current page is located at some URL other than where the browser found it. Any relative reference will be calculated from the URL given by <code><span style="font-family: "Tahoma","sans-serif";"><base href="..."></span></code> instead of the actual URL. <code><span style="font-family: "Tahoma","sans-serif";"><base></span></code> goes in the <code><span style="font-family: "Tahoma","sans-serif";"><head></span></code> section.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0in; width: 24%;" valign="top" width="24%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:html><o:p></o:p></span></p> </td> <td style="padding: 0in; width: 76%;" valign="top" width="76%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Tag renders an HTML <html> Element.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In the Address.jsp we have used some of the above tags. In the future sections I will show you more examples of the Struts HTML tags.<o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts Validator Framework<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This lesson introduces you the Struts Validator Framework. In this lesson you will learn how to use Struts Validator Framework to validate the user inputs on the client browser. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Introduction to Validator Framework</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">users browser</span></span></a> as well as on the server side. Struts Framework emits the java scripts and it can be used to validate the form data on the client browser. <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Server side</span></span></a> validation of the form can be accomplished by sub classing your From Bean with <b>DynaValidatorForm</b> class. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Validator framework was developed by David Winterfeldt as third-party add-on to Struts. Now the Validator framework is a part of Jakarta Commons project and it can be used with or without Struts. The Validator framework comes integrated with the Struts Framework and can be used without doing any extra settings.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Using Validator Framework</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Validator uses the <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">XML file</span></span></a> to pickup the validation rules to be applied to an form. In XML validation requirements are defined applied to a form. In case we need special validation rules not provided by the validator framework, we can plug in our own custom validations into Validator.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Validator Framework uses two XML <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">configuration files</span></span></a> <b>validator-rules.xml</b> and <b>validation.xml</b>. The <b>validator-rules.xml</b> defines the standard validation routines, these are reusable and used in <b>validation.xml</b>. to define the form specific validations. The <b>validation.xml</b> defines the validations applied to a form bean.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Structure of validator-rule.xml</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <b>validation-rules.xml</b> is provided with the Validator Framework and it declares and assigns the logical names to the validation routines. It also contains the client-side javascript code for each validation routine. The validation routines are <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java</span></span></a> methods plugged into the system to perform specific validations.
<br />
<br />Following table contains the details of the elements in this file: <o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 477.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="637"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Element<o:p></o:p></span></b></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 384pt;" width="512"> <p style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes and Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">form-validation<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 384pt;" width="512"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This is the root node. It contains nested elements for all of the other configuration settings.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">global<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 384pt;" width="512"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The validator details specified within this, are global and are accessed by all forms.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" valign="top" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">validator<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 384pt;" width="512"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The validator element defines what validators objects can be used with the fields referenced by the formset elements.<o:p></o:p></span></p> <p class="bulletted"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The attributes are:<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">name</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Contains a logical name for the validation routine<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">classname</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Name of the Form Bean class that extends the subclass of ActionForm class<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">method</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Name of the method of the Form Bean class<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">methodParams</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: parameters passed to the method<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">msg</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">:Validator uses Struts' Resource Bundle mechanism for externalizing <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">error messages</span></span></a>. Instead of having hard-coded error messages in the framework, Validator allows you to specify a key to a message in the ApplicationResources.properties file that should be returned if a validation fails. Each validation routine in the validator-rules.xml file specifies an error message key as value for this attribute.<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">depends</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: If validation is required, the value here is specified as 'required' for this attribute.<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">jsFunctionName</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Name of the <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">javascript</span></span></a> function is specified here. <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" valign="top" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">javascript<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 384pt;" width="512"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Contains the code of the javascript function used for client-side validation. Starting in Struts 1.2.0 the default javascript definitions have been consolidated to commons-validator. The default can be overridden by supplying a <javascript> element with a CDATA section, just as in struts 1.1.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The Validator plug-in (validator-rules.xml) is supplied with a predefined set of commonly used validation rules such as Required, Minimum Length, Maximum length, Date Validation, Email Address validation and more. This basic set of rules can also be extended with custom validators if required.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Structure of validation.xml</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This <b>validation.xml </b>configuration file defines which validation routines that is used to validate Form Beans. You can define validation logic for any number of Form Beans in this configuration file. Inside that definition, you specify the validations you want to apply to the Form Bean's fields. The definitions in this file use the logical names of Form Beans from the struts-config.xml file along with the logical names of validation routines from the validator-rules.xml file to tie the two together.<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 477pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="636"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Element<o:p></o:p></span></b></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Attributes and Description<o:p></o:p></span></b></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">form-validation<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This is the root node. It contains nested elements for all of the other configuration settings<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">global<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The constant details are specified in <constant> element within this element.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">constant<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Constant properties are specified within this element for pattern matching.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">constant-name<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Name of the constant property is specified here<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">constant-value<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Value of the constant property is specified here.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">formset<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This element contains multiple <form> elements<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">form<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This element contains the form details.
<br /> The attributes are:<b>
<br /> name</b>:Contains the form name. Validator uses this logical name to map the validations to a Form Bean defined in the struts-config.xml file<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">field<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This element is inside the form element, and it defines the validations to apply to specified Form Bean fields.
<br />
<br /> The attributes are:<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">property</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Contains the name of a field in the specified Form Bean<o:p></o:p></span></p> <p class="bulletted" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">depends</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">: Specifies the logical names of validation routines from the validator-rules.xml file that should be applied to the field.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">arg<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">A key for the error message to be thrown incase the validation fails, is specified here<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">var<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Contains the variable names and their values as nested elements within this element.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">var-name<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of the criteria against which a field is validated is specified here as a variable<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 86.25pt;" width="115"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">var-value<o:p></o:p></span></p> </td> <td style="border: 1pt inset maroon; padding: 0.75pt; width: 383.25pt;" width="511"> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The value of the field is specified here<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Example of form in the <b>validation.xml </b>file:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 297.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="397"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 296.25pt;" width="395"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!-- An example form -->
<br /> <form name="logonForm">
<br /> <field property="username"
<br /> depends="required">
<br /> <arg key="logonForm.username">
<br /> </field>
<br /> <field property="password"
<br /> depends="required,mask">
<br /> <arg key="logonForm.password">
<br /> <var>
<br /> <var-name>mask</var-name>
<br /> <var-value>^[0-9a-zA-Z]*$</var-value>
<br /> </var>
<br /> </field>
<br /> </form><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <html:javascript> tag to allow front-end validation based on the <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a> in validation.xml. For example the code: <html:javascript formname="logonForm" dynamicjavascript="true" staticjavascript="true"> generates the client side <a href="http://www.roseindia.net/struts/struts_validator_framework.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java script</span></span></a> for the form "logonForm" as defined in the validation.xml file. The <html:javascript> when added in the jsp file generates the client site validation script. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In the next lesson we will create a new form for entering the address and enable the client side java script with the Validator Framework.<o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Client Side Address Validation in Struts<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this lesson we will create <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JSP</span></span></a> page for entering the address and use the functionality provided by Validator Framework to validate the user data on the browser. Validator Framework emits the <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JavaScript code</span></span></a> which validates the user input on the browser. To accomplish this we have to follow the following steps:<o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Enabling the Validator plug-in: </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This makes the Validator available to the <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">system</span></span></a>. <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create Message Resources</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> for the displaying the error message to the user. <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing the Validation rules</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> We have to define the validation rules in the validation.<a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a> for the address form. Struts Validator Framework uses this rule for generating the JavaScript for validation. <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Applying the rules: </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">We are required to add the appropriate tag to the JSP for generation of JavaScript. <o:p></o:p></span></li><li class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Build and test:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> We are required to build the <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> once the above steps are done before testing. <o:p></o:p></span></li></ol> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Enabling the Validator plug- in
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To enable the validator plug-in open the file struts-config.xml and make sure that following line is present in the file.<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 354pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="472"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 351pt;" width="468"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!-- Validator plugin -->
<br /> <plug-in classname="org.<a href=" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.validator.ValidatorPlugIn">
<br /> <set-property
<br /> property="pathnames"
<br /> value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
<br /> </plug-in><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating Message Resources
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Message resources are used by the Validator Framework to generate the validation <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">error messages</span></span></a>. In our application we need to define the messages for name, Address and E-mail address. Open the Struts\strutstutorial\web\WEB-INF\MessageResources.properties file and add the following lines:
<br />AddressForm.name=Name
<br />AddressForm.address=Address
<br />AddressForm.emailAddress=E-mail address<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing Validation rules
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this application we are adding only one validation that the fields on the form should not be blank. Add the following code in the validation.xml. <o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 354pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="472"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 351pt;" width="468"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!-- Address <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">form Validation</span></span></a>-->
<br /> <form name="AddressForm">
<br /> <field property="name"
<br /> depends="required">
<br /> <arg key="AddressForm.name">
<br /> </field>
<br /> <field property="address"
<br /> depends="required">
<br /> <arg key="AddressForm.address">
<br /> </field>
<br /> <field property="emailAddress"
<br /> depends="required">
<br /> <arg key="AddressForm.emailAddress">
<br /> </field>
<br /> </form><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The above definition defines the validation for the form fields <b>name</b>, <b>address</b> and <b>emailAddress</b>. The attribute <b>depends="required"</b> instructs the Validator Framework to generate the <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JavaScript</span></span></a> that checks that the fields are not left blank. If the fields are left blank then JavaScript shows the error message. In the error message the message are taken from the key defined in the <arg>key=".."</b>/> tag. The value of key is taken from the message resources (Struts\strutstutorial\web\WEB-INF\<b>MessageResources.properties</b>).<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Applying Validation rules to JSP
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Now create the<b> AddressJavascriptValidation.jsp </b>file to test the application. The code for AddressJavascriptValidation.jsp is as follows:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 428.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="571"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 425.25pt;" width="567"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<br /> <%@ taglib uri="/tags/struts-html" prefix="html" %>
<br />
<br /> <html:html locale="true">
<br /> <head>
<br /> <title><bean:message key="welcome.title"></title>
<br /> <html:base/>
<br /> </head>
<br /> <body bgcolor="white">
<br /> <html:form action="/AddressJavascriptValidation" method="post" onsubmit="return validateAddressForm(this);">
<br />
<br /> <div align="left">
<br /> <p>
<br /> This application shows the use of Struts Validator.<br />
<br /> The following form contains fields that are processed by Struts Validator.<br />
<br /> Fill in the form and see how JavaScript generated by Validator Framework validates the form.
<br /> </p>
<br />
<br /> <p>
<br /> <html:errors/>
<br /> </p>
<br /> <table>
<br />
<br /> <tr>
<br /> <td align="center" colspan="2">
<br /> <<a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">font</span></span></a> size="4"><b>Please Enter the Following Details</b></span>
<br /> </tr>
<br /> <tr>
<br /> <td align="right">
<br /> <b>Name</b>
<br /> </td>
<br /> <td align="left">
<br /> <html:text property="name" size="30" maxlength="30">
<br /> </td>
<br /> </tr>
<br /> <tr>
<br /> <td align="right">
<br /> <b>Address</b>
<br /> </td>
<br /> <td align="left">
<br /> <html:text property="address" size="30" maxlength="30">
<br /> </td>
<br /> </tr>
<br />
<br /> <tr>
<br /> <td align="right">
<br /> <b>E-mail address</b>
<br /> </td>
<br /> <td align="left">
<br /> <html:text property="emailAddress" size="30" maxlength="30">
<br /> </td>
<br /> </tr>
<br />
<br /> <tr>
<br /> <td align="right">
<br /> <html:submit>Save</html:submit>
<br /> </td>
<br /> <td align="left">
<br /> <html:cancel>Cancel</html:cancel>
<br /> </td>
<br /> </tr>
<br /> </table>
<br /> </div>
<br />
<br /> <!-- Begin Validator Javascript Function-->
<br /> <b><html:javascript formname="AddressForm"></b>
<br /> <!-- End of Validator Javascript Function-->
<br />
<br /> </html:form>
<br /> </body>
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The code <b><html:javascript formname="AddressForm"></b> is used to plug-in the Validator JavaScript.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create the following entry in the struts-config.xml for the mapping the <b>/AddressJavascriptValidation</b> url for handling the form submission through <b>AddressJavascriptValidation.jsp</b>.<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 354pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="472"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 351pt;" width="468"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/AddressJavascriptValidation"
<br /> type="roseindia.net.AddressAction"
<br /> name="AddressForm"
<br /> scope="request"
<br /> validate="true"
<br /> input="/pages/AddressJavascriptValidation.jsp">
<br /> <forward name="success" path="/pages/success.jsp">
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to call the form.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="">/pages/AddressJavascriptValidation.jsp</b>">Client Side Validation for Address Form</html:link>
<br /><br />
<br />The Address Form that validates the data on the client side using Stuts Validator generated JavaScript.
<br /></li><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Building Example and Testing</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To build and deploy the application go to Struts\strutstutorial directory and type ant on the <a href="http://www.roseindia.net/struts/address_struts_validator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">command prompt</span></span></a>. This will deploy the application. Open the browser and navigate to the <b>AddressJavascriptValidation.jsp </b>page. Your browser should show the following out put.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" alt="" style="'width:414pt;height:298.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image007.gif" href="http://www.roseindia.net/struts/addressjavascript.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image007.gif" shapes="_x0000_i1029" border="0" width="552" height="398" /><!--[endif]--><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">If the fields are left blank and Save button is clicked, browser shows the error message.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this lesson you learned how to use Struts Validator Framework to validate the form on client browser. <o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Creating Custom Validators in STRUTS<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this tutorial you will learn how to develop Custom Validators in your Struts 1.3 applications. Struts Validator framework provides many validation rules that can be used in the <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">web applications</span></span></a>. If you application needs special kind of validation, then you can extend the validator framework to develop your own validation rule. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The client-side validation in Struts is well known. Here are some of the <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">available features</span></span></a>: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">required <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">requiredif <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">validwhen <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">minlength <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">maxlength <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">mask <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">byte <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">short <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">integer <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">long <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">float <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">double <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">byteLocale <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">shortLocale <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">integerLocale <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">longLocale <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">floatLocale <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doubleLocale <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">date <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">intRange <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">longRange <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">floatRange <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">doubleRange <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">creditCard <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">email <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">url <o:p></o:p></span></li></ul> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">These are found in the validator-rules.<a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a> inside the <validator> tags. The validator-rules.xml file is found in the commons-validator jar. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Let us know create a new validator for entering the name field of a form. The form should accept only "administrator" for the name field. To accomplish this edit the validator-rules.xml and add the following code under the <global> tag: <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <validator name="matchname"
<br /> classname="org.apache.struts.validator.FieldChecks"
<br /> method="validateName"
<br /> methodParams="<a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java</span></span></a>.lang.Object,
<br /> org.apache.commons.validator.ValidatorAction,
<br /> org.apache.commons.validator.Field,
<br /> org.apache.struts.action.ActionMessages,
<br /> org.apache.commons.validator.Validator,
<br /> javax.servlet.http.HttpServletRequest"
<br /> msg="errors.name">
<br /> <<a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">javascript</span></span></a>><![CDATA[
<br /> function validateName(form) {
<br /> var isValid = true;
<br /> var focusField = null;
<br /> var i = 0;
<br /> var fields = new Array();
<br />
<br /> var omatchName= eval('new ' + jcv_retrieveFormName(form) + '_matchname() ');
<br />
<br /> for (var x in omatchName) {
<br /> if (!jcv_verifyArrayElement(x, omatchName[x])) {
<br /> continue;
<br /> }
<br /> var field = form[omatchName[x][0]];
<br />
<br /> if (!jcv_isFieldPresent(field)) {
<br /> fields[i++] = omatchName[x][1];
<br /> isValid=false;
<br /> } else if (field.value != "administrator") {
<br /> fields[i++]=omatchName[x][1];
<br /> isValid=false;
<br /> }
<br /> }
<br />
<br /> if (fields.length > 0) {
<br /> jcv_handleErrors(fields, focusField);
<br /> }
<br /> return isValid;
<br /> }
<br /> ]]>
<br /> </javascript>
<br /> </validator><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To understand the above code: <o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">matchname is the new validator we are creating; use can use anything you want (e.g. matchAdmin) remembering that this will be used in another file which will be described later <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">the <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">error message</span></span></a> issued in the browser has the key errors.name; you can have any name here like errors.admin; once again this will be explained later <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">the <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Java Script</span></span></a> function to call is declared in the method attribute of the validator tag; in the above it is called validateName; you can have any valid Java Script function name (e.g. validateAdmin) <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">the Java Script to process this tag is declared inside CDATA; note that the function name should match EXACTLY with the name declared in the method attribute of the validator tag <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">the field.value != "administrator" is where we actually test the value entered in the browser; you can substitute any string in the place of "administrator"; also you can do more sophisticated checking (e.g. replace all blanks; check for upper/lower case, etc.) if you are an experienced Java Script programmer <o:p></o:p></span></li></ul> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To use our matchname validator create a file validation.xml and add the following lines: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><!-- Name <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">form Validation</span></span></a>--><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><form-validation><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><formset><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><form name="AdminForm"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><field<span style=""> </span>property="name"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>depends="matchname"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><arg0 key="AddressForm.name"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span></field><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></form><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></formset><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></form-validation><o:p></o:p></span></pre> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Copy the files validation.xml and validator-rules.xml to the directory where your struts-config.xml resides. Let us say it is WEB-INF. Next we have to create the error message for errors.name. Create a <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">directory WEB</span></span></a>-INF/resources and a file in this directory with the name application.properties. Add the following lines to application.properties <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";">AdminForm.name=Name<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.name={0} should be administrator.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.required={0} is required.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.minlength={0} can not be less than {1} characters.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.maxlength={0} can not be greater than {1} characters.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.invalid={0} is invalid.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.byte={0} must be a byte.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.short={0} must be a short.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.integer={0} must be an integer.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.long={0} must be a long.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.float={0} must be a float.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.double={0} must be a double.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.date={0} is not a date.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.range={0} is not in the range {1} through {2}.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.creditcard={0} is an invalid credit card number.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">errors.<a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">email</span></span></a>={0} is an invalid e-mail address.<o:p></o:p></span></pre> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Edit struts-configuration.xml and add the following lines <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><form-bean name="AdminForm" type="test.AdminForm"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><action<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>path="/AdminFormValidation"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>type="test.AdminForm"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>name="AdminForm"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>scope="request"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>validate="true"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>input="admin.jsp"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><forward name="success" path="success.jsp"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></action><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><message-resources parameter="resources/application"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><plug-in classname="org.<a href=" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.validator.ValidatorPlugIn"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="pathnames"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></plug-in><o:p></o:p></span></pre> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create a JSP file as follows: <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ taglib uri="struts-bean.tld" prefix="bean" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><%@ taglib uri="struts-html.tld" prefix="html" %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:html><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><head><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><title>Administrator Test</title><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:base/><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></head><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><body bgcolor="white"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:form action="/AdminFormValidation" method="post" onsubmit="return validateAdminForm(this);"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><div align="left"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><p><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">This <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> shows the use of Struts Validator.<br /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">The following form contains fields that are processed by Struts Validator.<br /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Fill in the form and see how JavaScript generated by Validator Framework validates the form.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></p><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><p><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:errors/><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></p><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><table><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><td align="right"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><b>Name</b><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><td align="left"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:text property="name" size="30" maxlength="30"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><td align="right"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:submit>Save</html:submit><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><td align="left"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:cancel>Cancel</html:cancel><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></td><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></tr><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></table><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></div><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><!-- Begin Validator Javascript Function--><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><html:javascript formname="AddressForm"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><!-- End of Validator Javascript Function--><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></html:form><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></body><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></html:html><o:p></o:p></span></pre> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Then we create the success.jsp <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><% out.println("SUCCESS") %><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">Then we create the <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Java Class</span></span></a> for the AdminForm<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">package test;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import javax.servlet.http.HttpServletRequest;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import org.apache.struts.action.*;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">/**<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> * Form bean for the Admin Entry Screen.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> *<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">*/<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">public class AdminForm extends ActionForm<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">{<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>private String name=null;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>public void setName(String name){<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>this.name=name;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>public String getName(){<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>return this.name;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>/**<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>* Reset all properties to their <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">default values</span></span></a>.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>*<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>* @param mapping The mapping used to select this instance<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>* @param request The servlet request we are processing<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>*/<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>public void reset(ActionMapping mapping, HttpServletRequest request) {<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>this.name=null;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>/**<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>* Reset all properties to their default values.<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>*<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>* @param mapping The mapping used to select this instance<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>* @param request The servlet request we are processing<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>* @return errors<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>*/<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>public ActionErrors validate(<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>ActionMapping mapping, HttpServletRequest request ) {<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>ActionErrors errors = new ActionErrors();<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>if( getName() == null || getName().length() <></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>errors.add("name",new ActionMessage("error.name.required"));<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>return errors;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">}<o:p></o:p></span></pre> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create the AdminAction.java <o:p></o:p></span></p> <pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">package test;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import javax.servlet.http.HttpServletRequest;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import javax.servlet.http.HttpServletResponse;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import org.apache.struts.action.Action;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import org.apache.struts.action.ActionForm;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import org.apache.struts.action.ActionForward;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">import org.apache.struts.action.ActionMapping;<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">public class AdminAction extends Action<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">{<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>public ActionForward execute(<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>ActionMapping mapping,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>ActionForm form,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>HttpServletRequest request,<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>HttpServletResponse response) throws Exception{<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>return mapping.findForward("success");<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>}<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";">}<o:p></o:p></span></pre> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Finally compile the classes and restart the <a href="http://www.roseindia.net/struts/StrutsCustomValidator.shtml" target="_top"><span class="klink"><span style="color: windowtext;">web server</span></span></a> and view the AdminForm.jsp <o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Developing Simple Struts Tiles Application<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Introduction
<br />In this section I will show you how to develop simple Struts Tiles <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Application</span></span></a>. You will learn how to setup the Struts Tiles and create example page with it.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What is Struts Tiles?
<br />Tiles is a framework for the development user interface. Tiles is enables the developers to develop the <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">web applications</span></span></a> by assembling the reusable tiles (jsp, html, etc..). Tiles uses the concept of reuse and enables the developers to define a template for the <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">web site</span></span></a> and then use this layout to populate the content of the web site. For example, if you have to develop a web site having more that 500 page of static content and many dynamically generated pages. The layout of the web site often changes according to the business requirement. In this case you can use the Tiles framework to design the template for the web site and use this template to populate the contents. In future if there is any requirement of site layout change then you have to change the layout in one page. This will change the layout of you whole web site.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Steps To Create Tiles Application
<br />Tiles is very useful framework for the development of web applications. Here are the steps necessary for adding Tiles to your Struts application:<o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the Tiles Tag Library Descriptor (TLD) file to the web.xml. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create layout JSPs. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Develop the <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">web pages</span></span></a> using layouts. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Repackage, run and test application. <o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the Tiles TLD to web.xml file
<br />Tiles can can be used with or without Struts. Following entry is required in the web.<a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml file</span></span></a> before you can use the tiles tags in your application.<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 339.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="453"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 332.25pt;" width="443"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><taglib>
<br /> <taglib-uri>/tags/struts-tiles</taglib-uri>
<br /> <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
<br /> </taglib><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Create layout JSPs.
<br />Our web application layout is divided into four parts: To Banner, Left Navigation Bar, Content Area and Bottom of the page for copy right information. Here is the code for out template (<b>template.jsp</b>):<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 471.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="629"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 464.25pt;" width="619"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">page language</span></span></a>="java" %>
<br /> <b><%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<br /> </b><html>
<br />
<br /> <head>
<br /> <title><b><tiles:getasstring name="title" ignore="true"></b></title>
<br /> </head>
<br />
<br /> <body>
<br />
<br /> <table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolor="#000000" bgcolor="#E7FDFE">
<br /> <tr>
<br /> <td width="100%" colspan="2" valign="top"><b><tiles:insert attribute="header"></b></td>
<br /> </tr>
<br /> <tr>
<br /> <td width="23%"><b><tiles:insert attribute="menu"></b></td>
<br /> <td width="77%" valign="top" valign="top"><b><tiles:insert attribute="body"></b></td>
<br /> </tr>
<br /> <tr>
<br /> <td width="100%" colspan="2" valign="top"><b><tiles:insert attribute="bottom"></b></td>
<br /> </tr>
<br /> </table>
<br />
<br /> </body>
<br />
<br /> </html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">We have defined the structure for web application using the appropriate html and did the following things:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Referenced the /WEB-INF/struts-tiles.tld TLD. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Used the string parameters to display title using the tiles:getAsString tag. If the attribute <b>ignore="true"</b> then Tiles ignore the missing parameter. If this is true then the Tiles framework will through the exception in case the parameter is missing. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To insert the content <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">JSP</span></span></a>, the <b>tiles:insert</b> tag is used, which inserts any page or web resources that framework refers to as a title. For Example <b><tiles:insert attribute="header"> </b>inserts the header web page. <o:p></o:p></span></li></ul> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Develop the web pages using layouts
<br />Now we will use tile layout create a page to display the <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">content page</span></span></a> in the in our application. For every content page there is additional jsp file for inserting the content in the Layout, so we have to create two jsp files one for content and another for displaying the content. In our example these file are example.jsp and content.jsp. Here is the code for both the files:<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">content.jsp</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 459.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="613"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 452.25pt;" width="603"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><p align="left"><<a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">font</span></span></a> color="#000080" size="5">Welcome to the Title Tutorial</span></p>
<br /> <p align="left"><span style="font-size:180%;color:#000080;">This is the content page</span></p><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The content.jsp simply define the content of the page. The content may be dynamic or static depending on the requirements.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">example.jsp</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 339.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="453"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 332.25pt;" width="443"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ page language="java" %>
<br /> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<br />
<br /> <tiles:insert page="/tiles/template.jsp" flush="true">
<br /> <tiles:put name="title" type="string" value="Welcome">
<br /> <tiles:put name="header" value="/tiles/top.jsp">
<br /> <tiles:put name="menu" value="/tiles/left.jsp">
<br /> <tiles:put name="body" value="/tiles/content.jsp">
<br /> <tiles:put name="bottom" value="/tiles/bottom.jsp">
<br /> </tiles:insert><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The code <b><tiles:insert page="/tiles/template.jsp" flush="true"></b> specifies the tiles layout page to be used. We have set the flush attribute to true, this makes the tile file to be written to browser before the rest of the page. To specify the title of the page <b><tiles:put name="title" type="string" value="Welcome"></b> is used. The following code is used to insert the actual pages in the template.:<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <tiles:put name="header" value="/tiles/top.jsp">
<br /> <tiles:put name="menu" value="/tiles/left.jsp">
<br /> <tiles:put name="body" value="/tiles/content.jsp">
<br /> <tiles:put name="bottom" value="/tiles/bottom.jsp"> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The top.jsp will be inserted in the layout's header region. The left.jsp will be inserted in the layout's menu region. The content.jsp wil be inserted in the layout's body region and the bottom.jsp will be inserted in the bottom region.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Repackage, run and test application
<br />Add the following code in the index.jsp to test the this tile example:<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="/tiles/example.jsp">Tiles Example</html:link>
<br /><br />
<br />Example of creating first tile application.
<br /></li><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Use the ant tool to build the application and deploy on the <a href="http://www.roseindia.net/struts/struts_tiles.shtml" target="_top"><span class="klink"><span style="color: windowtext;">server</span></span></a>. To test the application go to the index.jps and click on the Tiles Example link.<o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Using tiles-defs.xml in Tiles Application<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In the last section we studied how to forward the request (call) to a jsp page which specifies which tiles layout definition should be used to apply to the content. In this section I will show you how to use the a definition in the tiles-defs.xml for generating the content. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In Tiles we can define the definition in the tiles-defs.xml which specifies the different components to "plugin" to generate the output. This eliminates the need to define extra jsp file for each content file. For example in the last section we defined example.jsp to display the content of content.jsp file. In this section I will show you how to eliminate the need of extra jsp file using tiles-defs.xml file.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Steps to Use the tiles-defs.xml</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Setup the Tiles plugin in struts-config.xml file.</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Add the following code in the struts-config.xml (If not present). This enables the TilesPlugin to use the /WEB-INF/tiles-defs.xml file.
<br /> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 394.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="526"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 387pt;" width="516"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><plug-in classname="org.apache.struts.tiles.TilesPlugin">
<br /> <!-- Path to XML definition file -->
<br /> <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml">
<br /> <!-- Set Module-awareness to true -->
<br /> <set-property property="moduleAware" value="true">
<br /> </plug-in><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defining the tiles-defs.xml</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />In this file we are defining the different components to "plugin". Here is the code:<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <definition name="Tiles.Example" page="/tiles/template.jsp">
<br /> <put name="title" type="string" value="Welcome">
<br /> <put name="header" value="/tiles/top.jsp">
<br /> <put name="menu" value="/tiles/left.jsp">
<br /> <put name="body" value="/tiles/content.jsp">
<br /> <put name="bottom" value="/tiles/bottom.jsp">
<br /> </definition><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The name of the definition is Tiles.Example, we will use this in struts-config.xml (While creating forwards in struts-config.xml file) file. The page attribute defines the template file to be used and the put tag specifies the different components to "plugin". Your tiles-defs.xml should look like:<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 394.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="526"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 387pt;" width="516"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><?xml version="1.0" encoding="ISO-8859-1" ?>
<br />
<br /> <!DOCTYPE tiles-definitions PUBLIC
<br /> "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
<br /> "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<br />
<br /> <tiles-definitions>
<br />
<br />
<br /> <definition name="Tiles.Example" page="/tiles/template.jsp">
<br /> <put name="title" type="string" value="Welcome">
<br /> <put name="header" value="/tiles/top.jsp">
<br /> <put name="menu" value="/tiles/left.jsp">
<br /> <put name="body" value="/tiles/content.jsp">
<br /> <put name="bottom" value="/tiles/bottom.jsp">
<br /> </definition>
<br />
<br /> <definition name="${YOUR_DEFINITION_HERE}">
<br /> </definition>
<br />
<br /> </tiles-definitions><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Configure the Struts Action to use Tiles Definition</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Open the struts-config.xml file and add the following code:<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 394.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="526"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 387pt;" width="516"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action path="/Tiles/Example"
<br /> forward="Tiles.Example"/><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">With Tiles, the action points to the Tiles definition, as shown in the above code. In this code we are using the <b>Tiles.Example</b> definition which we have defined in the tiles-defs.xml file. <span class="bodycopy">Without Tiles, forward and action definitions point directly to JSPs. With Tiles, they point to the page's definition in the Tiles configuration file.</span><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Testing the Application</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Create a link in index.jsp to call the Example. Code added are: <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 156) none repeat scroll 0% 0%; width: 394.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="526"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 387pt;" width="516"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /> <html:link page="/Tiles/Example.do">Using tiles-defs.xml</html:link>
<br /> <br />
<br /> Example shows you how to use tiles-defs.xml file.
<br /> </li><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To test the application build it using ant and deploy on the JBoss server. Type <a href="http://localhost:8080/strutstutorial/index.jsp"><span style="color: windowtext;">http://localhost:8080/strutstutorial/index.jsp</span></a> in the bowser and select the Using tiles-defs.xml link. Your browser should show the page.<o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts DynaActionForm<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this tutorial you will learn how to create Struts DynaActionForm. We will recreate our address form with Struts DynaActionForm. DynaActionForm is specialized subclass of ActionForm that allows the creation of form beans with dynamic sets of properties, without requiring the developer to create a <a href="http://www.roseindia.net/struts/DynaActionForm.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Java class</span></span></a> for each type of form bean. DynaActionForm eliminates the need of FormBean class and now the form bean definition can be written into the struts-config.<a href="http://www.roseindia.net/struts/DynaActionForm.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a> file. So, it makes the FormBean declarative and this helps the <a href="http://www.roseindia.net/struts/DynaActionForm.shtml" target="_top"><span class="klink"><span style="color: windowtext;">programmer</span></span></a> to reduce the development time.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this tutorial we will recreate the add form with the help of DynaActionForm. It also shows you how you can validate use input in the action class. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Adding DynaActionForm Entry in struts-config.xml</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">First we will add the necessary entry in the struts-config.xml file. <b> </b>Add the following entry in the struts-config.xml file. The form bean is of org.<a href="http://www.roseindia.net/struts/DynaActionForm.shtml" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.action.DynaActionForm type. The <b><form-property/></b> tag is used to define the property for the form bean. We have defined three properties for our dynamic form bean.<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 414.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="553"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 411.75pt;" width="549"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><form-bean name="DynaAddressForm"
<br /> type="org.apache.struts.action.DynaActionForm">
<br /> <form-property name="name" type="<a href=" target="_top"><span class="klink"><span style="color: windowtext;">java</span></span></a>.lang.String"/>
<br /> <form-property name="address" type="java.lang.String">
<br /> <form-property name="email" type="java.lang.String">
<br /> </form-bean><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Adding action mapping</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following action mapping in the struts-config.<a href="http://www.roseindia.net/struts/DynaActionForm.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml file</span></span></a>:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 411.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="549"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 408.75pt;" width="545"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action path="/DynaAddress" type="roseindia.net.AddressDynaAction"
<br /> name="DynaAddressForm"
<br /> scope="request"
<br /> validate="true"
<br /> input="/pages/DynaAddress.jsp">
<br />
<br /> <forward name="success" path="/pages/success.jsp">
<br /> <forward name="invalid" path="/pages/DynaAddress.jsp">
<br />
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating Action Class</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Code for action class is as follows:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Deepak Kumar</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email roseindia_net@yahoo.com</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.Action;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.DynaActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMessages;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMessage;</span></code>
<br />
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">AddressDynaAction <b>extends </b>Action</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward execute(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> DynaActionForm addressForm = (DynaActionForm)form;</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Create object of ActionMesssages</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMessages errors = <b>new </b>ActionMessages();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Check and collect errors</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>(((String)addressForm.get("name")).equals("")) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> errors.add("name",new ActionMessage("error.name.required"));</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>(((String)addressForm.get("address")).equals("")) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> errors.add("address",new ActionMessage("error.address.required"));</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>(((String)addressForm.get("email")).equals("")) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> errors.add("email",new ActionMessage("error.emailaddress.required"));</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Saves the error</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> saveErrors(request,errors);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Forward the page</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>(errors.isEmpty()){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("success");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }<b>else</b>{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("invalid");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating the JSP file</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">We will use the Dyna Form <b>DynaAddressForm</b> created above in the jsp file. Here is the code of the jsp(<b>DynaAddress.jsp</b>) file.<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 354pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="472"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 351pt;" width="468"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<br /> <%@ taglib uri="/tags/struts-html" prefix="html" %>
<br />
<br /> <html:html locale="true">
<br /> <head>
<br /> <title><bean:message key="welcome.title"></title>
<br /> <html:base/>
<br /> </head>
<br /> <body bgcolor="white">
<br /> <b><html:form action="/DynaAddress" method="post"></b>
<br /> <table>
<br /> <tr>
<br /> <td align="center" colspan="2">
<br /> <<a href="http://www.roseindia.net/struts/DynaActionForm.shtml" target="_top"><span class="klink"><span style="color: windowtext;">font</span></span></a> size="4">Please Enter the Following Details</span>
<br /> </tr>
<br />
<br /> <tr>
<br /> <td align="left" colspan="2">
<br /> <span style="color:red;"><html:errors/></span>
<br /> </tr>
<br />
<br />
<br />
<br /> <tr>
<br /> <td align="right">
<br /> Name
<br /> </td>
<br /> <td align="left">
<br /> <html:text property="name" size="30" maxlength="30">
<br /> </td>
<br /> </tr>
<br /> <tr>
<br /> <td align="right">
<br /> Address
<br /> </td>
<br /> <td align="left">
<br /> <html:text property="address" size="30" maxlength="30">
<br /> </td>
<br /> </tr>
<br />
<br /> <tr>
<br /> <td align="right">
<br /> E-mail address
<br /> </td>
<br /> <td align="left">
<br /> <html:text property="email" size="30" maxlength="30">
<br /> </td>
<br /> </tr>
<br />
<br /> <tr>
<br /> <td align="right">
<br /> <html:submit>Save</html:submit>
<br /> </td>
<br /> <td align="left">
<br /> <html:cancel>Cancel</html:cancel>
<br /> </td>
<br /> </tr>
<br /> </table>
<br />
<br />
<br /> </html:form>
<br /> </body>
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to call the form.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="/pages/DynaAddress.jsp">Dyna Action Form Example</html:link>
<br /><br />
<br />Example shows you how to use DynaActionForm.
<br /></li><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Building Example and Testing</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To build and deploy the application go to Struts\strutstutorial directory and type ant on the <a href="http://www.roseindia.net/struts/DynaActionForm.shtml" target="_top"><span class="klink"><span style="color: windowtext;">command prompt</span></span></a>. This will deploy the application. Open the browser and navigate to the <b>DynaAddress.jsp </b>page. Without entering anything in the form and submitting the submit button, your browser should show the following out put. <o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts File Upload Example<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this tutorial you will learn how to use Struts to write program to <a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">upload files</span></span></a>. The interface <b>org.apache.struts.upload.FormFile</b> is the heart of the struts file upload application. This interface represents a file that has been uploaded by a client. It is the only interface or class in upload package which is typically referenced directly by a Struts <a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a>.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating Form Bean</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Our form bean class contains only one property <b>theFile</b>, which is of type <b>org.apache.struts.upload.FormFile</b>. Here is the code of FormBean (StrutsUploadForm.<a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java</span></span></a>):<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.*;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.upload.FormFile;</span></code>
<br />
<br />
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Deepak Kumar</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @<a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">Email</span></span></a> roseindia_net@yahoo.com</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * Form bean for Struts File Upload.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> *</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">StrutsUploadForm <b>extends </b>ActionForm</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>private </b>FormFile theFile;</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> /**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @return Returns the theFile.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> */</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>FormFile getTheFile() {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>theFile;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> /**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @param theFile The FormFile to set.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> */</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public void </b>setTheFile(FormFile theFile) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.theFile = theFile;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating Action Class</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Our action class simply calls the <b>getTheFile()</b> function on the <b>FormBean</b> object to retrieve the reference of the uploaded file. Then the reference of the FormFile is used to get the uploaded file and its information. Here is the code of our action class(StrutsUploadAction.java):<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.<a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.struts.action.Action;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.upload.FormFile;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Deepak Kumar</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email roseindia_net@yahoo.com</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * Struts <a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">File Upload</span></span></a> Action Form.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> *</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">StrutsUploadAction <b>extends </b>Action</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward execute(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> StrutsUploadForm myForm = (StrutsUploadForm)form;</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> // Process the FormFile</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> FormFile myFile = myForm.getTheFile();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> String contentType = myFile.getContentType();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> String fileName = myFile.getFileName();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>int </b>fileSize = myFile.getFileSize();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>byte</b>[] fileData = myFile.getFileData();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("contentType: " + contentType);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("File Name: " + fileName);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("<a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">File Size</span></span></a>: " + fileSize);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("success");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defining form Bean in struts-config.xml file</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following entry in the struts-config.<a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml file</span></span></a> for defining the form bean:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 436.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="582"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 433.5pt;" width="578"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><form-bean
<br /> name="FileUpload"
<br /> type="roseindia.net.StrutsUploadForm"/><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defining Action Mapping</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following action mapping entry in the struts-config.xml file:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="400"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/FileUpload"
<br /> type="roseindia.net.StrutsUploadAction"
<br /> name="FileUpload"
<br /> scope="request"
<br /> validate="true"
<br /> input="/pages/FileUpload.jsp">
<br /> <forward name="success" path="/pages/uploadsuccess.jsp">
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing jsp page</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Code of the jsp (FileUpload.jsp) file to upload is as follows:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 448.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="598"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 445.5pt;" width="594"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<br /> <%@ taglib uri="/tags/struts-html" prefix="html" %>
<br />
<br /> <html:html locale="true">
<br /> <head>
<br /> <title>Struts File Upload Example</title>
<br /> <html:base/>
<br /> </head>
<br /> <body bgcolor="white">
<br /> <b><html:form action="/FileUpload" method="post" enctype="multipart/form-data"></b>
<br /> <table>
<br /> <tr>
<br /> <td align="center" colspan="2">
<br /> <<a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">font</span></span></a> size="4">Please Enter the Following Details</span>
<br /> </tr>
<br />
<br /> <tr>
<br /> <td align="left" colspan="2">
<br /> <span style="color:red;"><html:errors/></span>
<br /> </tr>
<br />
<br />
<br />
<br /> <tr>
<br /> <td align="right">
<br /> File Name
<br /> </td>
<br /> <td align="left">
<br /> <html:file property="theFile">
<br /> </td>
<br /> </tr>
<br />
<br />
<br /> <tr>
<br /> <td align="center" colspan="2">
<br /> <html:submit>Upload File</html:submit>
<br /> </td>
<br /> </tr>
<br /> </table>
<br />
<br />
<br /> </html:form>
<br /> </body>
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Note that we are setting the encrypt property of the form to <b>enctype="multipart/form-data".</b><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">code for the success page (uploadsuccess.jsp) is:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 153) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="400"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html>
<br />
<br /> <head>
<br /> <title>Success</title>
<br /> </head>
<br />
<br /> <body>
<br />
<br /> <p align="center"><span style="font-size:180%;color:#000080;">File Successfully Received</span></p>
<br />
<br /> </body>
<br />
<br /> </html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to call the form.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="/pages/FileUpload.jsp">Struts File Upload</html:link>
<br /><br />
<br />Example shows you how to Upload File with Struts.
<br /></li><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Building Example and Testing</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To build and deploy the application go to Struts\strutstutorial directory and type ant on the <a href="http://www.roseindia.net/struts/strutsfileupload.shtml" target="_top"><span class="klink"><span style="color: windowtext;">command prompt</span></span></a>. This will deploy the application. Open the browser and navigate to the FileUpload.jsp<b> </b>page. Your browser should display the file upload form:
<br />
<br /><!--[if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" alt="" style="'width:348.75pt;height:194.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image008.gif" href="http://www.roseindia.net/struts/strutsupload.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image008.gif" shapes="_x0000_i1030" border="0" width="465" height="259" /><!--[endif]--><o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts File Upload and Save<o:p></o:p></span></h1> <p><b><i><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">We are receiving lots of comments regarding "Struts file upload example". It does not contain any code illustrating how to save the file on the server . Now, the current example will provide you with the code to upload the file ,in the upload directory of server. </span></i></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this tutorial you will learn how to use Struts program to upload on the Server and display a link to the user to download the uploaded file . The interface <b>org.apache.struts.upload.FormFile</b> has a prime role in uploading a file in a Struts application. This interface represents a file that has been uploaded by a client. It is the only interface or class in Upload package which is referenced directly by a Struts application.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating Form Bean</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Our form bean class contains only one property <b>theFile</b>, which is of type <b>org.apache.struts.upload.FormFile</b>. Here is the code of FormBean (StrutsUploadAndSaveForm.java):<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.*;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.upload.FormFile;</span></code>
<br />
<br />
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Amit Gupta</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email struts@roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * Form bean for Struts File Upload.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> *</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">StrutsUploadAndSaveForm <b>extends </b>ActionForm</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>private </b>FormFile theFile;</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> /**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @return Returns the theFile.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> */</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>FormFile getTheFile() {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>theFile;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> /**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * @param theFile The FormFile to set.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> */</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public void </b>setTheFile(FormFile theFile) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>this</b>.theFile = theFile;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">} </span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating Action Class</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In our previous article entitled<b> "Struts File Upload Example", </b>we just had action class simply calling the <b>getTheFile()</b> function on the <b>FormBean</b> object to retrieve the reference of the uploaded file. Then the reference of the FormFile was used to get the uploaded file and its information. Now further we retrieve the Servers upload directory's real path<code><span style="font-family: "Tahoma","sans-serif";"> </span></code>using <b>ServletContext's getRealPath() </b>and saving the file.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Code of <b>StrutsUploadAndSaveAction.java</b>:<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.Action;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.upload.FormFile;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">java.io.*;</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Amit Gupta</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email struts@roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> * Struts File Upload Action Form.</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> *</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">*/</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">StrutsUploadAndSaveAction <b>extends </b>Action</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward execute(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> StrutsUploadAndSaveForm myForm = (StrutsUploadAndSaveForm)form;</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> // Process the FormFile</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> FormFile myFile = myForm.getTheFile();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> String contentType = myFile.getContentType();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Get the file name</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> String fileName = myFile.getFileName();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //int fileSize = myFile.getFileSize();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>byte</b>[] fileData = myFile.getFileData();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Get the servers upload directory real path name</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> String filePath = getServlet().getServletContext().getRealPath("/") +"upload";</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> /* Save file on the server */</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>(!fileName.equals("")){ </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("Server path:" +filePath);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Create file</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> File fileToCreate = <b>new </b>File(filePath, fileName);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //If file does not exists create file </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>if</b>(!fileToCreate.exists()){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> FileOutputStream fileOutStream = <b>new </b>FileOutputStream(fileToCreate);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> fileOutStream.write(myFile.getFileData());</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> fileOutStream.flush();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> fileOutStream.close();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> } </span></code>
<br />
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //Set file name to the request object</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> request.setAttribute("fileName",fileName);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("success");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">} </span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Defining form Bean in struts-config.xml file</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following entry in the struts-config.xml file for defining the form bean:<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 213) none repeat scroll 0% 0%; width: 342.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="457"> <tbody><tr style="height: 50.25pt;"> <td style="padding: 0in; width: 339.75pt; height: 50.25pt;" width="453"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><form-bean
<br /> name="FileUploadAndSave"
<br /> type="roseindia.net.StrutsUploadAndSaveForm"/><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <b>Defining Action Mapping</b> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following action mapping entry in the struts-config.xml file:<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 259.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="346"> <tbody><tr style=""> <td style="padding: 0in; width: 256.5pt;" width="342"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/FileUploadAndSave"
<br /> type="roseindia.net.StrutsUploadAndSaveAction"
<br /> name="FileUploadAndSave"
<br /> scope="request"
<br /> validate="true"
<br /> input="/pages/FileUploadAndSave.jsp">
<br /> <forward name="success" path="/pages/downloaduploadedfile.jsp">
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing jsp pages</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Code of the jsp (FileUploadAndSave.jsp) file to upload is as follows<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 420pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="560"> <tbody><tr style=""> <td style="padding: 0in; width: 417pt;" width="556"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<br /> <%@ taglib uri="/tags/struts-html" prefix="html" %>
<br />
<br /> <html:html locale="true">
<br /> <head>
<br /> <title>Struts File Upload and Save Example</title>
<br /> <html:base/>
<br /> </head>
<br /> <body bgcolor="white">
<br /> <html:form action="/FileUploadAndSave" method="post" enctype="multipart/form-data">
<br /> <table>
<br /> <tr>
<br /> <td align="center" colspan="2">
<br /> <span style="font-size:130%;">File Upload on Server</span>
<br /> </tr>
<br />
<br /> <tr>
<br /> <td align="left" colspan="2">
<br /> <span style="color:red;"><html:errors/></span>
<br /> </tr>
<br />
<br />
<br /> <tr>
<br /> <td align="right">
<br /> File Name
<br /> </td>
<br /> <td align="left">
<br /> <html:file property="theFile">
<br /> </td>
<br /> </tr>
<br />
<br />
<br /> <tr>
<br /> <td align="center" colspan="2">
<br /> <html:submit>Upload File</html:submit>
<br /> </td>
<br /> </tr>
<br /> </table>
<br />
<br />
<br /> </html:form>
<br /> </body>
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">code for the success page (downloaduploadedfile.jsp) is:<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 420pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="560"> <tbody><tr style=""> <td style="padding: 0in; width: 417pt;" width="556"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html>
<br />
<br /> <head>
<br /> <title>Success</title>
<br /> </head>
<br />
<br /> <body>
<br /> <%
<br /> String fileName=(String)request.getAttribute("fileName");
<br /> %>
<br />
<br /> <p align="center"><span style="font-size:180%;color:#000080;">File Successfully Received</span></p>
<br /> <p align="center"><a href="">">Click here to download</a></p>
<br /> </body>
<br />
<br /> </html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to call the form.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="/pages/FileUploadAndSave.jsp">Struts File Upload</html:link>
<br /><br />
<br />Example shows you how to Upload File with Struts.
<br /></li><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Building Example and Testing</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To build and deploy the application go to Struts\strutstutorial directory and type ant on the command prompt. This will deploy the application. Open the browser and navigate to the Struts File Upload page. Your browser should display the file upload form:
<br /> <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style=""> <td style="padding: 0in;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1031" type="#_x0000_t75" alt="" style="'width:353.25pt;height:190.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image009.gif" href="http://www.roseindia.net/struts/struts1.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image009.gif" shapes="_x0000_i1031" border="0" width="471" height="254" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; display: none;"><o:p> </o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Now , Browse the file needed to upload and click Upload File Button. Browser will display that file has successfully received on the server. <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style="height: 144.75pt;"> <td style="padding: 0in; height: 144.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1032" type="#_x0000_t75" alt="" style="'width:267pt;height:228pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image010.gif" href="http://www.roseindia.net/struts/pic-2.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image010.gif" shapes="_x0000_i1032" border="0" width="356" height="304" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Click on the hyperlink to see the uploaded content. .<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="0" width="200"> <tbody><tr style="height: 23.25pt;"> <td style="padding: 0in; height: 23.25pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1033" type="#_x0000_t75" alt="" style="'width:275.25pt;height:179.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image011.gif" href="http://www.roseindia.net/struts/pic3.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image011.gif" shapes="_x0000_i1033" border="0" width="367" height="239" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts Built-In Actions<o:p></o:p></span></h1> <p style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this section we will give a quick look to the few of built-in utility actions shipped with Struts APIs. These built-in utility actions provide different functionalities useful to diverse applications. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 593.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-left: 6.75pt; margin-right: 6.75pt;" align="left" border="1" cellpadding="0" cellspacing="1" width="791"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Actions</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Description</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.actions.DispatchAction</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It provides mechanism to collect related functions into a single action and eliminates the need of creating multiple independent actions for each function.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.actions.ForwardAction</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It enables to forward request to the specified URL.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.actions.IncludeAction</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It provides mechanism to include the contents of a specified URL.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.actions.LocaleAction</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It provides mechanism to set a user's locale and further forwarding that to a specified page.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.actions.LookupDispatchAction</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It provides mechanism to combine many similar actions into a single action class, in order to simplify the <a href="http://www.roseindia.net/struts/struts-built-in-actions.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application design</span></span></a> .Java map class is used to dispatch methods.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.actions.MappingDispatchAction</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It lets you combine many related actions into a single action class and manage through creating multiple action-mappings.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 259.7pt;" width="346"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.actions.switchAction</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> </td> <td style="padding: 0.75pt; width: 331.45pt;" width="442"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It provides a mechanism to switch between modules and then forwards control to a URI (specified in a number of possible ways) within the new module.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts Dispatch Action Example<o:p></o:p></span></h1> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts Dispatch Action</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> (org.apache.struts.actions.DispatchAction) is one of the Built-in Actions provided along with the struts framework.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <b>org.apache.struts.actions.DispatchAction</b> class enables a user to collect related functions into a single Action. It eliminates the need of
<br />creating multiple independent actions for each function. Here in this example you will learn more about Struts Dispatch Action that will help you grasping the concept better.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Let's develop <b>Dispatch_Action</b> class which is a sub class of <b>org.apache.struts.actions.DispatchAction </b>class. This class does not provide an implementation for the<b> execute()</b> method because <b>DispatchAction </b>class itself implements this method. This class manages to delegate the request to one of the methods of the derived Action class. An Action Mapping is done to select the particular method (via Struts-Configuration file). <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here the Dispatch_Action class contains multiple methods ie.. add() , edit() , search() , save(). Here all the methods are taking the same input parameters but each method returns a different <b><i>ActionForward</i></b> like<b> "add"</b> in case of <b>add() </b>method , <b>"edit"</b> in case of <b>edit()</b> etc.
<br />Each ActionForward is defined in the <b>struts-config.xml</b> file (action mapping is shown later in this page). Here is the code for Action Class.
<br /><b>
<br />Developing an Action Class (Dispatch_Action.java) </b><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 359.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="479"> <tbody><tr style="height: 317.9pt;"> <td style="padding: 0.75pt; width: 351.75pt; height: 317.9pt;" width="469"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">java.io.*;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>import </b>javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.ServletException;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.actions.DispatchAction;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">/**</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Amit Gupta</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email <a href="mailto:struts@roseindia.net"><span style="color: windowtext;">struts@roseindia.net</span><span style="color: windowtext;">
<br /> </span></a></span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">**/ </span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Dispatch_Action <b>extends </b>DispatchAction</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">{</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">public </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ActionForward add(</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in add function.");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("add");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">public </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ActionForward edit(</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception</span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> {</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in edit function.");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("edit");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> }</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">public </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ActionForward search(</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in search function");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("search");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> }</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">public </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ActionForward save(</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in save function");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("save");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> }</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing an ActionForm Class</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Our form bean class contains only one property <b>"parameter</b>" which is playing prime role in this example. Based on the parameter value appropriate function of Action class is executed. Here is the code for <b> FormBean ( DispatchActionForm.java):</b> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 317.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="423"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 309.75pt;" width="413"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">/**</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">* @author Amit Gupta</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email <a href="mailto:struts@roseindia.net"><span style="color: windowtext;">struts@roseindia.net</span><span style="color: windowtext;">
<br /> </span></a> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">**/</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">DispatchActionForm <b>extends </b>ActionForm</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> private </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">String parameter =" "; </span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>String getParameter()</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> {</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <b>return </b>parameter;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public void </b>setParameter(String parameter)</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> {</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <b>this</b>.parameter=parameter;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> }</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code><o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">}</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /><b>Defining form Bean in struts-config.xml file</b> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following entry in the struts-config.xml file for defining the form bean <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 260.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="347"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 252.75pt;" width="337"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><form-bean name="DispatchActionForm"
<br /> type="roseindia.net.DispatchActionForm"/><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /><b>Developing the Action Mapping in the struts-config.xml
<br /></b>
<br />Here, Action mapping helps to select the method from the Action class for specific requests. Note that the value specified with the <b>parameter </b>
<br /><b>attribute</b> is used to delegate request to the required method of the Dispath_Action Class. <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 319.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="426"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 312pt;" width="416"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/DispatchAction"
<br /> type="roseindia.net.Dispatch_Action"
<br /> <b>parameter="parameter"</b>
<br /> input="/pages/DispatchAction.jsp"
<br /> name="DispatchActionForm"
<br /> scope="request"
<br /> validate="false">
<br /> <forward name="add" path="/pages/DispatchActionAdd.jsp">
<br /> <forward name="edit" path="/pages/DispatchActionEdit.jsp">
<br /> <forward name="search" path="/pages/DispatchActionSearch.jsp">
<br /> <forward name="save" path="/pages/DispatchActionSave.jsp">
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing jsp page</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Code of the jsp (DispatchAction.jsp) to delegate requests to different jsp pages :<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 462.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="617"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 455.25pt;" width="607"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<br /> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<br /> <html:html locale="true">
<br /> <head>
<br /> <title>Dispatch Action Example</title>
<br /> <body>
<br />
<br /> <h3>Dispatch Action Example</h3>
<br /> <p><html:link page="/DispatchAction.do?parameter=add">Call Add Section</html:link></p>
<br /> <p><html:link page="/DispatchAction.do?parameter=edit">Call Edit Section</html:link></p>
<br /> <p><html:link page="/DispatchAction.do?parameter=search">Call Search Section</html:link></p>
<br /> <p><html:link page="/DispatchAction.do?parameter=save">Call Save Section</html:link></p>
<br />
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to call the form.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="/pages/DispatchAction.jsp">Struts File Upload</html:link>
<br /><br />
<br />Example demonstrates how DispatchAction Class works.
<br /></li><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Building and Testing the Example </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To build and deploy the application go to Struts\Strutstutorial directory and type ant on the command prompt. This will deploy the application. Open the browser and navigate to the DispatchAction.jsp<b> </b>page. Your browser displays the following DispatchAction page. <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1034" type="#_x0000_t75" alt="" style="'width:233.25pt;height:241.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image012.gif" href="http://www.roseindia.net/struts/dispatchactionexample.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image012.gif" shapes="_x0000_i1034" border="0" width="311" height="322" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Selecting <b><u>Call Add Section</u></b> displays the following <b>DispatchActionAdd.jsp </b>page<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 213pt;" border="1" cellpadding="0" cellspacing="1" width="284"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 209.25pt;" width="279"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1035" type="#_x0000_t75" alt="" style="'width:207.75pt;height:147.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image013.gif" href="http://www.roseindia.net/struts/dispatchactionadd.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image013.gif" shapes="_x0000_i1035" border="0" width="277" height="197" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Selecting <b><u>Call Edit Section</u></b> displays the following <b> DispatchActionEdit.jsp </b>page<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1036" type="#_x0000_t75" alt="" style="'width:235.5pt;height:150pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/struts/pic-3.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1036" border="0" width="314" height="200" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Selecting <b><u>Call Search Section </u></b>displays the following <b>DispatchActionSearch.jsp </b>page <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1037" type="#_x0000_t75" alt="" style="'width:230.25pt;height:146.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/struts/pic-4.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1037" border="0" width="307" height="195" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Selecting <b><u>Call Save Section </u></b> displays the following <b>DispatchActionSave.jsp </b>page<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1038" type="#_x0000_t75" alt="" style="'width:281.25pt;height:163.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/struts/pic-5.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1038" border="0" width="375" height="218" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts Forward Action Example<o:p></o:p></span></h1> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">In this section we will learn about Struts ForwardAction </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">(org.apache.struts.actions.ForwardAction). The ForwardAction is one of the Built-in Actions that is shipped with struts framework.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The <b>org.apache.struts.actions.ForwardAction</b> class enables a user to forward request to the specified URL. ForwardAction is an utility classs that is used in cases where a user simply needs to forward the control to an another JSP page. Linking directly a JSP to an another, violates the MVC principles. So we achieve this through action-mapping. Note that we do not create any action class. With ForwardAction , simply create an action mapping in the Strut Configuration and specify the location where the action will forward the request..<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here in this example you will learn more about Struts Forward Action that will help you in grasping the concept better.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">No need to develop an Action Class</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing the Action Mapping in the struts-config.xml</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create seperate action-mapping , for each page you want to link.. Note that the <b>"type"</b> attribute always take<b> "org.apache.struts.actions.ForwardAction" </b>value. Here "<b>parameter"</b> attribute specifies the<b> </b>URL to which the request is forwarded . <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 319.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="426"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 312pt;" width="416"> <p class="MsoNormal" style="margin-bottom: 12pt;"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/success"
<br /> <b>type="org.apache.struts.actions.ForwardAction"
<br /> parameter="/pages/Success.jsp"</b>
<br /> input="/pages/ForwardAction.jsp"
<br /> scope="request"
<br /> validate="false">
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing a jsp page</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Code of the jsp (ForwardAction.jsp) to forward request to a different jsp page :<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 462.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="617"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 455.25pt;" width="607"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<br /> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<br /> <html:html locale="true">
<br /> <head>
<br /> <title>Forward Action Example</title>
<br /> <body>
<br />
<br /> <h3>Forward Action Example</h3>
<br /> <p><html:link page="/success.do">Call the Success page</html:link></p>
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to call the form.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="/pages/ForwardAction.jsp">Struts Forward Action</html:link>
<br /><br />
<br />Example shows you how to use forward class to forward request to another JSP page.
<br /></li><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Building and Testing the Example </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To build and deploy the application go to Struts\Strutstutorial directory and type ant on the command prompt. This will deploy the application. Open the browser and navigate to the ForwardAction.jsp<b> </b>page. Your browser will display the following ForwardAction page. <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1039" type="#_x0000_t75" alt="" style="'width:285pt;height:141.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image017.png" href="http://www.roseindia.net/struts/forwardactionexample.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image018.jpg" shapes="_x0000_i1039" border="0" width="380" height="189" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Selecting <b><u>Call the Success page</u></b> displays the following <b>Success.jsp </b>page<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 213pt;" border="1" cellpadding="0" cellspacing="1" width="284"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 209.25pt;" width="279"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1040" type="#_x0000_t75" alt="" style="'width:370.5pt;height:138pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image019.png" href="http://www.roseindia.net/struts/forwardactionresult.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image020.jpg" shapes="_x0000_i1040" border="0" width="494" height="184" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Struts LookupDispatchAction Example<o:p></o:p></span></h1> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Struts LookupDispatch Action</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> (org.apache.struts.actions.LookupDispatchAction) is one of the Built-in Actions provided along with the struts framework.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">.The <b>org.apache.struts.actions.LookupDispatchAction </b>class.is a subclass of <b>org.apache.struts.actions.DispatchAction </b>class.This class enables a user to collect related functions into a single action class. It eliminates the need of creating multiple independent actions for each function. Here in this example you will learn more about Struts LookupDispatchAction that will help you to grasp the concept better.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Let's develop a class <b> LookupDispatch_Action </b>which is a sub class of <b>org.apache.struts.actions.LookupDispatchAction </b>class. This class does not provide an implementation for the<b> execute()</b> method because <b>DispatchAction </b>class itself implements this method. <b><i>LookupDispatchAction class is much like the DispatchAction class except that it uses a Java Map and ApplicationResource.properties file</i></b> <b><i>to dispatch methods .</i></b> At run time, this class manages to delegate the request to one of the methods of the derived Action class. Selection of a method depends on the value of the parameter passed from the incoming request. LookupDispatchAction uses this parameter value to reverse-map to a property in the Struts Resource bundle file (ie..ApplicationResource.properties). This eliminates the need of creating an instance of ActionForm class. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">LookupDispatch_Action class contains multiple methods ie.. add() , edit() , search() , save() . Here all the methods are taking the same input parameters but each method returns a different <b><i>ActionForward</i></b> like<b> "add"</b> in case of <b>add() </b>method , <b>"edit"</b> in case of <b>edit()</b> etc. Each ActionForward is defined in the <b>struts-config.xml</b> file (action mapping is shown later in this page). <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Notice the implementation of the <code><b><span style="font-family: "Tahoma","sans-serif";">getKeyMethodMap()</span></b></code><code><span style="font-family: "Tahoma","sans-serif";">method.</span></code>This method is required to map the names of the keys in the Struts Resource bundle file (ie..ApplicationResource.properties) to the methods in the class. The key values in the bundle file are matched against the value of the incoming request parameter ( which is specified in the action tag through struts-config.xml file). Then this matching key is mapped to the appropriate method to execute ,the mecahanism is implemented through the <code><span style="font-family: "Tahoma","sans-serif";">getKeyMethodMap()</span></code>and can be defined as key-to-method mapping.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Here is the code for Action Class <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing an Action Class (LookupDispatch_Action.java) </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";">/**</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @author Amit Gupta</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Web http://www.roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">* @Email struts@roseindia.net</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">**/</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">java.io.*;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">java.util.*;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.ServletException;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.actions.LookupDispatchAction;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">LookupDispatch_Action <b>extends </b>LookupDispatchAction</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>protected </b>Map getKeyMethodMap(){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> Map map = <b>new </b>HashMap();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> map.put("roseindia.net.add","add");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> map.put("roseindia.net.edit","edit");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> map.put("roseindia.net.search","search");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> map.put("roseindia.net.save","save");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>map;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward add(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in add function.");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("add");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward edit(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in edit function.");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("edit");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward search(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in search function");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("search");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> </span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward save(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("You are in save function");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("save");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">}</span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">No need to Develop an ActionForm Class </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Instead create an Application Resource Property File:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Application.properties </span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br /><code><span style="font-family: "Tahoma","sans-serif";">in the same directory structure where classes are saved. </span></code> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 150pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">roseindia.net.add=add
<br /> roseindia.net.edit=edit
<br /> roseindia.net.search=search
<br /> roseindia.net.save=save<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following, Message Resources Definitions in </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <b>struts-config.xml </b><o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 150pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><message-resources parameter="roseindia.net.ApplicationResources"><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Develop the following Action Mapping in the struts-config.xml
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Here, Action mapping helps to select the method from the Action class for specific requests. Note that the value specified with the <b>parameter </b>
<br /><b>attribute</b> is used to delegate request to the required method of the LookupDispatch_Action Class. <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 393pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="524"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 385.5pt;" width="514"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/LookupDispatchAction"
<br /> type="roseindia.net.LookupDispatch_Action"
<br /> <b>parameter="parameter"</b>
<br /> input="/pages/LookupDispatchAction.jsp"
<br /> name="LookupDispatchActionForm"
<br /> scope="request"
<br /> validate="false">
<br /> <forward name="add" path="/pages/LookupDispatchActionAdd.jsp">
<br /> <forward name="edit" path="/pages/LookupDispatchActionEdit.jsp">
<br /> <forward name="search" path="/pages/LookupDispatchActionSearch.jsp">
<br /> <forward name="save" path="/pages/LookupDispatchActionSave.jsp">
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Developing jsp page</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Code of the jsp (LookupDispatchAction.jsp) to delegate requests to different jsp pages :<o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 526.5pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="1" width="702"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 519pt;" width="692"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<br /> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<br /> <html:html locale="true">
<br /> <head>
<br /> <title>Dispatch Action Example</title>
<br /> <body>
<br />
<br /> <h3>Dispatch Action Example</h3>
<br /> <p><html:link page="/LookupDispatchAction.do?parameter=add">Call Add Section</html:link></p>
<br /> <p><html:link page="/LookupDispatchAction.do?parameter=edit">Call Edit Section</html:link></p>
<br /> <p><html:link page="/LookupDispatchAction.do?parameter=search">Call Search Section</html:link></p>
<br /> <p><html:link page="/LookupDispatchAction.do?parameter=save">Call Save Section</html:link></p>
<br />
<br /> </html:html><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Add the following line in the index.jsp to call the form.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><li>
<br /><html:link page="/pages/LookupDispatchAction.jsp">Struts File Upload</html:link>
<br /><br />
<br />Example demonstrates how LookupDispatchAction class works.
<br /></li><o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Building and Testing the Example </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">To build and deploy the application go to Struts\Strutstutorial directory and type ant on the command prompt. This will deploy the application. Open the browser and navigate to the LookupDispatchAction.jsp<b> </b>page. Your browser displays the following LookupDispatchAction page. <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1041" type="#_x0000_t75" alt="" style="'width:227.25pt;height:253.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image021.gif" href="http://www.roseindia.net/struts/pic--1.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image021.gif" shapes="_x0000_i1041" border="0" width="303" height="338" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Selecting <b><u>Call Add Section</u></b> displays the following <b>LookupDispatchActionAdd.jsp </b>page<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 213pt;" border="1" cellpadding="0" cellspacing="1" width="284"> <tbody><tr style=""> <td style="padding: 0.75pt; width: 209.25pt;" width="279"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1042" type="#_x0000_t75" alt="" style="'width:207.75pt;height:147.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image013.gif" href="http://www.roseindia.net/struts/dispatchactionadd.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image013.gif" shapes="_x0000_i1042" border="0" width="277" height="197" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Selecting <b><u>Call Edit Section</u></b> displays the following <b> LookupDispatchActionEdit.jsp </b>page<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1043" type="#_x0000_t75" alt="" style="'width:235.5pt;height:150pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image014.gif" href="http://www.roseindia.net/struts/pic-3.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.gif" shapes="_x0000_i1043" border="0" width="314" height="200" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Selecting <b><u>Call Search Section </u></b>displays the following <b>LookupDispatchActionSearch.jsp </b>page <o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1044" type="#_x0000_t75" alt="" style="'width:230.25pt;height:146.25pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.gif" href="http://www.roseindia.net/struts/pic-4.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image015.gif" shapes="_x0000_i1044" border="0" width="307" height="195" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Selecting <b><u>Call Save Section </u></b> displays the following <b>LookupDispatchActionSave.jsp </b>page<o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 150pt;" border="1" cellpadding="0" cellspacing="1" width="200"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1045" type="#_x0000_t75" alt="" style="'width:281.25pt;height:163.5pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image016.gif" href="http://www.roseindia.net/struts/pic-5.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.gif" shapes="_x0000_i1045" border="0" width="375" height="218" /><!--[endif]--><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">STRUTS ACTION - AGGREGATING ACTIONS IN STRUTS<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />If you are a Struts developer then you might have experienced the pain of writing huge number of Action classes for your project. The latest version of struts provides classes using which you can aggregate a related set of actions into a single unified action. In this article we will see how to achieve this. Struts provides four important classes for this purpose. These classes are called as Dispatchers. The important Dispatchers that struts provides includes : <b>DispatchAction</b>, <b>ActionDispatcher</b> , <b>LookupDispatchAction</b> and <b>MappingDispatchAction</b>.
<br />
<br />All these classes can be found in the package <b><i>org.apache.struts.actions</i></b>. Let us look in to each of these in detail. Our examples use the simple CRUD actions.
<br />
<br /><b>DispatchAction:</b> In this type of aggregation, the action class must extend DispatchAction class as shown.
<br />
<br />public final class CRUDDispatchAction extends DispatchAction {
<br />
<br />public ActionForward create(ActionMapping mapping,
<br />ActionForm form,
<br />HttpServletRequest request,
<br />HttpServletResponse response) throws Exception {
<br />return (mapping.findForward("success"));
<br />}
<br />...
<br />
<br />and the action mapping will be as
<br />
<br /><action path="/crudDispatchAction" type="com.companyname.projname.CRUDDispatchAction" name="formName" scope="request" input=" homeDef" parameter="methodToCall">
<br /><forward name="success" path="targetDefName">
<br /></action>
<br />
<br />in your jsp you can call this action as
<br />
<br /><html:link action="crudDispatchAction?methodToCall=create">Create</html:link>
<br />...
<br />
<br />Observe that the above class extends DispatchAction and so you cannot use this method if your class already extends your (some) super class (eg., the class where the session is validated/invalidated). Here the user has to send a query string variable (methodToCall) to set the action name to call.
<br />
<br /><b>ActionDispatcher:</b> This flavor of aggregation is same as DispatchAction except that we need not extend ActionDispatcher, so we can use this method even if our class extends a super class. The following code snippet shows this scenario.
<br />
<br />
<br />public final class CRUDActionDispatcher extends Action {
<br />
<br />protected ActionDispatcher dispatcher = new ActionDispatcher(this, ActionDispatcher.DEFAULT_FLAVOR);
<br />
<br />public ActionForward execute(ActionMapping mapping,
<br />ActionForm form,
<br />HttpServletRequest request,
<br />HttpServletResponse response) throws Exception {
<br />return dispatcher.execute(mapping, form, request, response);
<br />}
<br />
<br />The DEFAULT_FLAVOR field suggests that the default parameter is "method" if none is specified as parameter in struts-config.xml (eg,. methodToCall).
<br />ActionDispatcher flavor also needs methodToCall parameter to be set (using hidden variable or a query string) as in case of DispatchAction.
<br />
<br /><b>LookupDispatchAction:</b> This type of aggregation is useful in situations where in you have multiple submit buttons in a single form. The class must extend LookupDispatchAction. However, the great thing about this type is that its java script free. That means, you need not set any hidden variables or pass query string however, you must use submit buttons as shown.
<br />
<br /><html:submit property="submit"><bean:message key="button.create"></html: submit >
<br /><html:submit property="submit"><bean:message key="button.read"></html: submit >
<br />...
<br />The example Action class will be as follows
<br />
<br />public class CRUDLookUpDispatchAction extends LookupDispatchAction {
<br />
<br />protected Map getKeyMethodMap() {
<br />Map map = new HashMap();
<br />map.put("button.create", "create");
<br />…
<br />return map;
<br />}
<br />public ActionForward create(ActionMapping mapping,
<br />ActionForm form,
<br />HttpServletRequest request,
<br />HttpServletResponse response) throws Exception {
<br />return (mapping.findForward("success"));
<br />}
<br />Observe the getKeyMethodMap() method. The submit button names are specified in a Map and their keys comes from MessageResources file. Struts picks up the name from this file and redirects it to the value specified in the Map. The calling code in jsp however has multiple submit buttons only differing in their names.
<br />
<br /><b>MappingDispatchAction:</b> This aggregation extends MappingDispatchAction class. This is the most useful type among the four types available. But as seen in other cases, you can use this type only when your action does not extend any other action. The good thing about this type is that the action mappings can differ and so need not be the same as in all other cases. To illustrate this consider the below mappings.
<br />
<br /><action path="/createMappingAction" type="com.bodhtree.CRUDMappingDispatchAction" scope="request" input="homeDef" parameter="create">
<br /><forward name="success" path="targetDef">
<br /></action>
<br /><action path="/readMappingAction" type="com.bodhtree.CRUDMappingDispatchAction" name=" formName" scope="request" input="homeDef" parameter=" read">
<br /><forward name="success" path="targetDef">
<br /></action>
<br />
<br />Notice that in the first action mapping, there is no form bean while in the second the bean name is specified. This means that the user has the flexibility to change the mapping according to his needs and hence not been contained to use a constant mapping for all the CRUD actions. Note that in all the other types of aggregations, we must use the same mapping for all the CRUD actions.
<br />
<br /><b>Conclusion:</b> Each of these types has their own pros and cons. DispatchAction is the default type which uses java script and we must extend DispatchAction to use it, ActionDispatcher is same as DispathAction except that we do not extend any action , LookupDispatchAction gives the flexibility to use multiple submit buttons while MappingDispatchAction allows us to change the action mappings according to our need. So each one of these has a particular usage and which one to use depends on the user requirement.<o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Set the mapping name <o:p></o:p></span></h1> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">3.</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> Set the mapping name to the action attribute of html:link <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// mappingdispatchaction.jsp
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="createMappingDispatchAction"><b>C</b>reate an Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr>
<br />
<br /> <tr><td> </td></tr>
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="readMappingDispatchAction"><b>R</b>ead an Employee details</html:link>
<br />
<br /> </td>
<br />
<br /> </tr>
<br />
<br /> <tr><td> </td></tr>
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="updateMappingDispatchAction"><b>U</b>pdate Employee details</html:link>
<br />
<br /> </td>
<br />
<br /> </tr>
<br />
<br /> <tr><td> </td></tr>
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="deleteMappingDispatchAction"><b>D</b>elete Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the advantages? <o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Single action class can be used for multiple action mappings. The attribute of the action mapping can be added or removed and a new mapping can be created while the action class remains the same. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Useful in places where there are 2 actions, one of which needs a formbean while the other does not but both uses the same Action class. In such cases, two new action mappings can be created one with ‘name' attribute and one without and the same Action class name can be used. <o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the disadvantages? <o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">We still cannot extend our CRUDMappingDispatchAction from any custom <a href="http://www.roseindia.net/struts/set-mapping-name.shtml" target="_top"><span class="klink"><span style="color: windowtext;">base class</span></span></a> and have the aggregation intact. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Cannot attach events. More about this later. <o:p></o:p></span></li></ol> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">ActionDispatcher</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br />How to create one?
<br />
<br /><b>1. </b>Extend your action class from Action. Do not confuse about the inclusion of BaseAction.<a href="http://www.roseindia.net/struts/set-mapping-name.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java</span></span></a>. I have just moved the common code part to this BaseAction and extended my action class from it. <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// src/CRUDActionDispatcher.java
<br />
<br /> /**
<br />
<br /> * This is an example class for demonstrating ActionDispatcher
<br />
<br /> * functionality. Observe here that we are extending our
<br />
<br /> * action class from BaseAction where the session validation
<br />
<br /> * is done.
<br />
<br /> * <p>
<br />
<br /> * See BaseAction for more details
<br />
<br /> * <p>
<br />
<br /> * If we use any other aggregating action then we cannot
<br />
<br /> * use session validation as we cannot extend our custom class
<br />
<br /> * (BaseAction in this case). This is the biggest strength of ActionDispatcher
<br />
<br /> * type of aggregation and the biggest weakness of all other types.
<br />
<br /> *
<br />
<br /> * @author Praveen Babu Kusuma
<br />
<br /> * @version 1.0.0
<br />
<br /> *
<br />
<br /> * http://www.javahome.co.nr
<br />
<br /> * http://praveen.awardspace.com
<br />
<br /> */
<br />
<br /> public final class CRUDActionDispatcher extends BaseAction {
<br />
<br /> public ActionForward create(ActionMapping mapping,
<br />
<br /> ActionForm form,
<br />
<br /> HttpServletRequest request,
<br />
<br /> HttpServletResponse response)
<br />
<br /> <a href="http://www.roseindia.net/struts/set-mapping-name.shtml" target="_top"><span class="klink"><span style="color: windowtext;">throws Exception</span></span></a> {
<br />
<br /> // Code for Create Employee follows
<br />
<br /> System.out.println("I am in CRUDActionDispatcher - create");
<br />
<br /> return ( mapping.findForward("success") );
<br />
<br /> }
<br />
<br /> ...
<br />
<br /> } <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// src/BaseAction.java
<br />
<br /> /**
<br />
<br /> * This is an example class where session validation
<br />
<br /> * is done normally. But if you look at closely we have
<br />
<br /> * actually written our ActionDispatcher code here and
<br />
<br /> * simply extended our example class for demonstrating
<br />
<br /> * ActionDispatcher functionality from this class.
<br />
<br /> * <p>
<br />
<br /> * This is the place where every time the session is
<br />
<br /> * checked. A sample <a href="http://www.roseindia.net/struts/set-mapping-name.shtml" target="_top"><span class="klink"><span style="color: windowtext;">code snippet</span></span></a> could be :
<br />
<br /> *
<br />
<br /> * <code>
<br />
<br /> * session = request.getSession(false); // which returns the existing session
<br />
<br /> * if( session != null ) {
<br />
<br /> * // allow the user in
<br />
<br /> * } else {
<br />
<br /> * // throw him/her out to the relogin page
<br />
<br /> * }
<br />
<br /> * </code>
<br />
<br /> * <p>
<br />
<br /> * This is perhaps the most crucial part of any web <a href="http://www.roseindia.net/struts/set-mapping-name.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a>
<br />
<br /> * since this is to be done for every class or every class is to be
<br />
<br /> * extended from this kind of (Base) class.
<br />
<br /> *
<br />
<br /> * @author Praveen Babu Kusuma
<br />
<br /> * @version 1.0.0
<br />
<br /> *
<br />
<br /> * http://www.javahome.co.nr
<br />
<br /> * http://praveen.awardspace.com
<br />
<br /> */
<br />
<br /> public class BaseAction extends Action {
<br />
<br /> protected ActionDispatcher dispatcher =
<br />
<br /> new ActionDispatcher(this, ActionDispatcher.DEFAULT_FLAVOR);
<br />
<br /> public ActionForward execute(ActionMapping mapping,
<br />
<br /> ActionForm form,
<br />
<br /> HttpServletRequest request,
<br />
<br /> HttpServletResponse response)
<br />
<br /> throws Exception {
<br />
<br /> // This is a default method and is mandatory since we are
<br />
<br /> // not extending any dispatcher action class(eg, extends ActionDispatcher{ }).
<br />
<br /> // This method will handle the dispatching of the action to the appropriate method.
<br />
<br /> // Code for Session Validation follows
<br />
<br /> <a href="http://www.roseindia.net/struts/set-mapping-name.shtml" target="_top"><span class="klink"><span style="color: windowtext;">System</span></span></a>.out.println("I am in BaseAction - execute");
<br />
<br /> return dispatcher.execute(mapping, form, request, response);
<br />
<br /> }
<br />
<br /> } <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">2. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Declare a variable of type ActionDispatcher as follow (see above code snippet):
<br />
<br />protected ActionDispatcher dispatcher = new ActionDispatcher(this, ActionDispatcher.DEFAULT_FLAVOR);
<br />
<br /><b>3. </b>Add the following line as the last line of your default ‘execute' method. Note that this is not needed for other methods. (see above code snippet)
<br />
<br />return dispatcher.execute(mapping, form, request, response);
<br />
<br /><b>4. </b>Define a query string parameter or a hidden variable (‘methodToCall' in our examples) <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// actiondispatcher.jsp
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="crudActionDispatcher? methodToCall =create"><b>C</b>reate an Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">5. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Set the parameter's value to the desired function name of the action class (create, read etc). <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// actiondispatcher.jsp
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="crudActionDispatcher? methodToCall=create "><b>C</b>reate an Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr>
<br /> // actiondispatcher.jsp
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="crudActionDispatcher? methodToCall =create"><b>C</b>reate an Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the advantages? <o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Observe that we have extended our action class (CRUDActionDispatcher) from our custom base class (BaseClass) which is what we wanted in order to decouple the session validation code into the BaseClass. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Only a couple of changes to the code avoid the need to extend from a subclass. <o:p></o:p></span></li><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Easy to use. <o:p></o:p></span></li></ol> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the disadvantages? <o:p></o:p></span></p> <ol start="1" type="1"><li class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">We cannot attach events to the controls. <o:p></o:p></span></li></ol> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Event Aggregating Actions </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br />If you are familiar with swing programming you might have heard of events. An event is nothing but a piece of code that is executed when, say, a button is clicked, a linked is clicked etc. In all the above types of actions we have defined a parameter (methodToCall) which is in turn mapped to the action name. This is a good feature for <a href="http://www.roseindia.net/struts/set-mapping-name.shtml" target="_top"><span class="klink"><span style="color: windowtext;">security</span></span></a> concerns. However, we need a way to have the method name different from the actual method called, at the same time eliminating the need to define a hidden variable or a query string. This is where the Event Aggregating Actions comes into the picture.
<br />
<br />There are two important types of Event Aggregating Actions as said earlier, namely, EventDispatchAction and EventActionDispatcher
<br />
<br />Let's see each one of them in detail.
<br />
<br /><b>EventDispatchAction</b>
<br />
<br />How to create one?
<br />
<br /><b>1. </b>Extend your action from EventDispatchAction <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// CRUDEventDispatchAction.java
<br />
<br /> /**
<br />
<br /> * This is an example class for demonstrating EventDispatchAction
<br />
<br /> * functionality. Observe here that we can also extend our class from
<br />
<br /> * BaseAction class like in ActionDispatcher example and move our
<br />
<br /> * session validation to that class.
<br />
<br /> * <p>
<br />
<br /> * The EventActionDispatcher as the name suggests is used to attach
<br />
<br /> * events to the html controls. This type of aggregation eliminates the
<br />
<br /> * need to define a parameter(eg., methodToCall). We havent used any
<br />
<br /> * hidden parameters to combine an event to a method. This event-to-method
<br />
<br /> * mapping is removed using EventActionDispatcher.
<br />
<br /> *
<br />
<br /> * We can also use an Alias for the method name and map it to the method name
<br />
<br /> * as can be seen in the createAlias event.
<br />
<br /> *
<br />
<br /> * @author Praveen Babu Kusuma
<br />
<br /> * @version 1.0.0
<br />
<br /> *
<br />
<br /> * http://www.javahome.co.nr
<br />
<br /> * http://praveen.awardspace.com
<br />
<br /> */
<br />
<br /> public final class CRUDEventDispatchAction extends EventDispatchAction {
<br />
<br /> public ActionForward create(ActionMapping mapping,
<br />
<br /> ActionForm form,
<br />
<br /> HttpServletRequest request,
<br />
<br /> HttpServletResponse response) throws Exception {
<br />
<br /> // Code for Create Employee follows
<br />
<br /> System.out.println("I am in CRUDEventDispatchAction - create");
<br />
<br /> return ( mapping.findForward("success") );
<br />
<br /> }
<br />
<br /> ...
<br />
<br /> } <o:p></o:p></span></p> </td> </tr> </tbody></table> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Set the action name <o:p></o:p></span></h1> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">2. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Set the action name to the action attribute of html:link <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// eventdispatchaction.jsp <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><tr> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><td> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><html:link action="crudEventDispatchAction ?createAlias=create "><b>C</b>reate an Employee record</html:link> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"></td> <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"></tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">3. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Either directly use the method name to call as a query string parameter, or use an alias. <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// eventdispatchaction.jsp ( Direct calling )
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="crudEventDispatchAction? update "><b>U</b>pdate Employee details</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// eventdispatchaction.jsp ( Calling using an alias )
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="crudEventDispatchAction? createAlias=create"><b>C</b>reate an Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the advantages? <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">1.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Events can be attached to controls directly. <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">2.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">No need to use a separate hidden variable or a query string for mapping the method name to the actual method to call. <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">3.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Actual method to call can be aliased with a pseudo name. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the disadvantages? <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">1.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">The need to extend the class from EventDispatchAction and hence cannot extend our class from a custom base class. <o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">EventActionDispatcher</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br />How to create one? <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">1.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Extend your action from Action, similar to the case in ActionDispatcher. This is what is desirable for us. <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// CRUDEventActionDispatcher.java
<br />
<br /> /**
<br />
<br /> * This is an example class for demonstrating EventActionDispatcher
<br />
<br /> * functionality. Observe here that we can also extend our class from
<br />
<br /> * BaseAction class like in ActionDispatcher example and move our
<br />
<br /> * session validation to that class.
<br />
<br /> * <p>
<br />
<br /> * The EventActionDispatcher as the name suggests is used to attach
<br />
<br /> * events to the html controls. This type of aggregation eliminates the
<br />
<br /> * need to define a parameter(eg., methodToCall). We havent used any
<br />
<br /> * hidden parameters to combine an event to a method. This event-to-method
<br />
<br /> * mapping is removed using EventActionDispatcher.
<br />
<br /> *
<br />
<br /> * We can also use an Alias for the method name and map it to the method name
<br />
<br /> * as can be seen in the createAlias event.
<br />
<br /> *
<br />
<br /> * @author Praveen Babu Kusuma
<br />
<br /> * @version 1.0.0
<br />
<br /> *
<br />
<br /> * http://www.javahome.co.nr
<br />
<br /> * http://praveen.awardspace.com
<br />
<br /> */
<br />
<br /> public final class CRUDEventActionDispatcher extends Action {
<br />
<br /> protected ActionDispatcher dispatcher = new EventActionDispatcher(this);
<br />
<br /> public ActionForward execute(ActionMapping mapping,
<br />
<br /> ActionForm form,
<br />
<br /> HttpServletRequest request,
<br />
<br /> HttpServletResponse response) throws Exception {
<br />
<br /> // This method will handle the dispatching of the action to the appropriate method.
<br />
<br /> System.out.println("I am in CRUDEventActionDispatcher - execute");
<br />
<br /> return dispatcher.execute(mapping, form, request, response);
<br />
<br /> }
<br />
<br /> ...
<br />
<br /> } <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">2. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Set the action name to the action attribute of html:link. <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// eventactiondispatcher.jsp
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action =" crudEventActionDispatcher ?createAlias=create"><b>C</b>reate an Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">3. </span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Either directly use the method name to call as a query string parameter, or use an alias. <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// eventactiondispatcher.jsp ( Direct calling )
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="crudEventActionDispatcher? delete "><b>D</b>elete Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"> <o:p></o:p></span></p> <table class="MsoNormalTable" style="background: rgb(255, 255, 204) none repeat scroll 0% 0%; width: 90%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="0" cellpadding="0" cellspacing="0" width="90%"> <tbody><tr style=""> <td style="padding: 0in; width: 100%;" width="100%"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">// eventactiondispatcher.jsp ( Calling using an alias )
<br />
<br /> <tr>
<br />
<br /> <td>
<br />
<br /> <html:link action="crudEventActionDispatcher? createAlias=create "><b>C</b>reate an Employee record</html:link>
<br />
<br /> </td>
<br />
<br /> </tr> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the advantages? <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">1.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Events can be attached to controls directly. <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">2.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">No need to use a separate hidden variable or a query string for mapping the method name to the actual method to call. <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">3.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Actual method to call can be aliased with a pseudo name. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">What are the disadvantages?
<br />
<br /><b>1. </b>None. <o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Note that the use of true (read=true) while using the query string variable to specify the event name is optional. Also, note that this variable is different from the one we used earlier (methodToCall). Here we directly specify the event name or its alias not the variable name or the actual method to call.
<br />
<br /><b>Assumptions </b><o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">1.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It is assumed that you have the complete source code of this discussion with you.
<br /> <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">2.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">For some examples, I assume that our application is a full fledged web application wherein a user is authenticated before entry into the system and we are validating the user session in a base class. Why is this so important? Because, to use some types of aggregations, we should extend our action class from a specific subclass of Action. This restricts us from extending the action class from a custom base class. DispatchAction is an example of such an action.
<br /> <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">3.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It is assumed that all we are interested in are the Create, Read, Update and Delete operations on an entity in the database. These
<br />actions, also called CRUD actions, are the basis for all the examples of this discussion.
<br /> <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">4.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">One more assumption is that it is assumed that we are interested in attaching events to the HTML controls, which you may be familiar in JSF, where in we attach events to the controls using action and actionListener attributes.
<br /> <o:p></o:p></span></p> <p style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><span style="">5.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">It is assumed that the examples provided depict only one way of usage. You are free to experiment with the code, like for instance, replacing query string with hidden variables. <o:p></o:p></span></p> <h1><span style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">Configuring Struts DataSource Manager on Tomcat 5<o:p></o:p></span></h1> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">This tutorial shows you how you can configure Struts DataSource Manager on the Tomcat 5.5.9 <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">server</span></span></a>. We will use struts 1.2.7 in this tutorial. In this tutorial we will configure Struts DataSource Manager to use MySQL Database and use the connection provided by Struts DataSource in action class.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Downloading and Installing Tomcat 5.5.9
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Download jakarta-tomcat-5.5.9 from <a href="http://jakarta.apache.org/tomcat/"><span style="color: windowtext;">http://jakarta.apache.org/tomcat/</span></a>. Install it on your machine. Run and test the pages that comes with the tomcat.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Download Struts
<br /></span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Download Struts struts-1.2.7 from <a href="http://struts.apache.org/download.cgi"><span style="color: windowtext;">http://struts.apache.org/download.cgi</span></a> and <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">unzip</span></span></a> it to your favorite directory. Go to the struts-1.2.7\webapps directory and then unzip struts-blank.war file. We will use this file to write our tutorial.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Download MySQL JDBC Driver</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Download mysql-connector-java-3.0.16-ga-bin.jar from here <a href="http://www.roseindia.net/struts/mysql-connector-java-3.0.16-ga-bin.jar"><span style="color: windowtext;">mysql-connector-java-3.0.16-ga-bin.jar</span></a> or you can download and use the latest version of mysql <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">jdbc driver</span></span></a>. Copy the JDBC driver file (mysql-connector-java-3.0.16-ga-bin.jar or latest version) to the <b>jakarta-tomcat-5.5.9\common\lib</b> directory of your tomcat installation. This will add the MySQL JDBC driver to the tomcat server.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating MySQL Database</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />In this tutorial I am using MySQL server installed on my local machine. You can download and install <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">MySQL</span></span></a> on your local machine and use for this tutorial. If you already have MySQL server then you can use the existing MySQL server.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create database "strutsdatabase" on the MySQL server and then run the following query to create test table.<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 102) none repeat scroll 0% 0%; width: 363.75pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="485"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 360.75pt;" width="481"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">CREATE TABLE `test` (
<br /> `username` varchar(20) NOT NULL default ''
<br /> ) TYPE=MyISAM;
<br />
<br /> /*Data for the table `test` */
<br />
<br /> insert into `test` values ('rajesh'),('George'),('Vikas'),('Prakash'),('Mahesh');<o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Above query creates <b>test</b> table and then populates the table with data.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Configuring Struts Application</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Now create a directory "strutsdatabase" in the jakarta-tomcat-5.5.9\webapps\ directory and copy the content of struts-blank <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">application</span></span></a> (unzipped above) in the strutsdatabase directory.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Now start the tomcat and try to access the strutsdatabase application by typing the url <a href="http://localhost:8080/strutsdatabase"><span style="color: windowtext;">http://localhost:8080/strutsdatabase</span></a> in browser. Your browser should display the welcome page. After testing shutdown the tomcat server.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Configuring Struts DataSource Manager</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />The Struts DataSource manager makes it easy for your Action class get the <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">database</span></span></a> connection. To configure the Stuts DataSource Manager we will uncomment the <data-sources> entry in the struts-config.xml.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Uncomment and then <data-sources> entry in the struts-config.xml and then change the line "<b>org.<a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">apache</span></span></a>.commons.dbcp.BasicDataSource</b>" to "<b>org.apache.tomcat.dbcp.dbcp.BasicDataSource</b>". In <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">tomcat</span></span></a> 5.5.9 dbcp classes are packaged in <b>naming-factory-dbcp.jar</b> archieve, so we are using "org.apache.tomcat.dbcp.dbcp.BasicDataSource" instead of "org.apache.commons.dbcp.BasicDataSource". After this change the database dirver, database url and passwor in the <data-sources> tag.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You <<a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">data-source</span></span></a>> element should look like:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 102) none repeat scroll 0% 0%; width: 479.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="639"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in; width: 476.25pt;" width="635"><pre><span style="font-family: "Tahoma","sans-serif";"><data-sources><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><data-source type="">org.apache.tomcat.dbcp.dbcp.BasicDataSource</b>"><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="driverClassName"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="com.mysql.<a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">jdbc</span></span></a>.Driver" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="url"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="jdbc:mysql://localhost:3306/strutsdatabase?autoReconnect=true" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="username"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="root" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><span style=""> </span>property="password"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="maxActive"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="10" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="maxWait"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="5000" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="defaultAutoCommit"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="false" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="defaultReadOnly"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="false" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><set-property<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>property="validationQuery"<o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span>value="SELECT COUNT(*) FROM test" /><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></data-source><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"></data-sources><o:p></o:p></span></pre><pre><span style="font-family: "Tahoma","sans-serif";"><span style=""> </span><o:p></o:p></span></pre></td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Create action Class to Test the DataSource</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Now we will write the code of Action class for getting the connection form DataSource:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 102) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 2.25pt;" valign="top" nowrap="nowrap"> <p class="MsoNormal"><code><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">package </span></b></code><code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">test;</span></code><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletRequest;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">javax.servlet.http.HttpServletResponse;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.Action;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForm;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionForward;</span></code>
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">org.apache.struts.action.ActionMapping;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">import </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">java.sql.*;</span></code>
<br />
<br /> <code><b><span style="font-family: "Tahoma","sans-serif";">public class </span></b></code><code><span style="font-family: "Tahoma","sans-serif";">TestDataSource <b>extends </b>Action</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>public </b>ActionForward execute(</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionMapping mapping,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ActionForm form,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletRequest request,</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> HttpServletResponse response) <b>throws </b>Exception{</span></code>
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> javax.sql.DataSource dataSource;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">java</span></span></a>.sql.Connection myConnection=<b>null</b>;</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>try </b>{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> dataSource = getDataSource(request);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> myConnection = dataSource.getConnection();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> Statement stmt=myConnection.createStatement();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> ResultSet rst=stmt.executeQuery("select username from test");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("******************************************");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("********Out Put from TestDataSource ******");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>while</b>(rst.next()){</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> System.out.println("User Name is: " + rst.getString("username"));</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">System</span></span></a>.out.println("******************************************");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> rst.close();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> stmt.close();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> // do what you wish with myConnection</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> } <b>catch </b>(SQLException sqle) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> getServlet().log("Connection.process", sqle);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> } <b>finally </b>{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //enclose this in a finally block to make</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> //sure the connection is closed</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>try </b>{</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> myConnection.close();</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> } <b>catch </b>(SQLException e) {</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> getServlet().log("Connection.close", e);</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br />
<br />
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> <b>return </b>mapping.findForward("success");</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";"> }</span></code>
<br /> <code><span style="font-family: "Tahoma","sans-serif";">} </span></code> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Following code is used to get the data source and then connection from Struts DataSource:<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">dataSource = getDataSource(request);
<br />myConnection = dataSource.getConnection();<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Save this file(TestDataSource.java) into jakarta-tomcat-5.5.9\webapps\strutsdatabase\WEB-INF\src\java\test directory. Add the servlet API into class path. Then open dos prompt and navigate to jakarta-tomcat-5.5.9\webapps\strutsdatabase\WEB-INF\src\ directory and issue run ant. This will compile the action class (TestDataSource.java) and copy it to the classes directory of the webapplication.<o:p></o:p></span></p> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Creating Action Mapping struts-config.xml</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Now add the following action mapping into the struts-config.xml:<o:p></o:p></span></p> <table class="MsoNormalTable" style="border: 1pt outset maroon; background: rgb(255, 255, 102) none repeat scroll 0% 0%; width: 300pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0" cellspacing="0" width="400"> <tbody><tr style=""> <td style="border: 1pt inset maroon; padding: 0in;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><action
<br /> path="/DataSource"
<br /> type="test.TestDataSource">
<br /> <forward name="success" path="/success.jsp">
<br /> </action><o:p></o:p></span></p> </td> </tr> </tbody></table> <p><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Running and testing</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
<br />Start tomcat and browse the url <a href="http://localhost:8080/strutsdatabase/DataSource.do"><span style="color: windowtext;">http://localhost:8080/strutsdatabase/DataSource.do</span></a>. Your browser should show the following output.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><!--[if gte vml 1]><v:shape id="_x0000_i1046" type="#_x0000_t75" alt="" style="'width:394.5pt;height:120.75pt'"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image022.gif" href="http://www.roseindia.net/struts/datasourceexample.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image022.gif" shapes="_x0000_i1046" border="0" width="526" height="161" /><!--[endif]--><o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Now check tomcat console, it should display records fetched from database.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">You can download my struts-config.<a href="http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml" target="_top"><span class="klink"><span style="color: windowtext;">xml</span></span></a> from <a href="http://www.roseindia.net/struts/struts-config.xml"><span style="color: windowtext;">here</span></a>.<o:p></o:p></span></p> <p><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">Note: <strong><span style="font-family: "Tahoma","sans-serif";">The DataSource manager is being retained in Struts 1.x for backward compatibility but may not be retained in Struts 2.x or later.</span></strong> <o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";"><o:p> </o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-30787674203933719442008-12-11T23:27:00.000-08:002008-12-23T03:58:34.944-08:00Logical Branching & Looping in MATLAB<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Courier; panose-1:2 7 4 9 2 2 5 2 4 4; mso-font-charset:0; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:CMSY10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMR10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMMI10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMSY7; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 134676480 16 0 131073 0;} @font-face {font-family:MSAM10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMTT8; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-fareast-language:ZH-CN;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 14.5pt; font-family: "Times New Roman","serif"; color: red;">Motion Control of a Rotational Stepper Motor,<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 14.5pt; font-family: "Times New Roman","serif"; color: blue;">
<br /><o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 14.5pt; font-family: "Times New Roman","serif"; color: black;">1 Overview: Programming & Experiment Goals<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">This session is used to introduce basic (</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: blue;">MATLAB</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">) programming concepts, including<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">looping (”for” and ”while”)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">logical conditions<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">further use of script M-files<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The driving application is </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: red;">programmable motion control </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">of a stepper motor. Specific tasks include<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">estimating the arc covered in a single step from imprecise measurements<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">a priori bounds over measurement and estimate uncertainties<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">open loop planned motion<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">retrieval of sensor data<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">feedback: closed loop control of planned motion<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: blue;">Components & Equipment </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">used in this experiment include:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">A control box<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">A stepper motor on a mount<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">A flat flag, mounted on the motor shaft,<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">A protractor on the face of the mount, indicating the rotation angle of the flag<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">Two photo resistor cells, at the </span><span style="font-size: 10pt; font-family: CMR10; color: rgb(13, 205, 13);">0</span><span style="font-size: 7pt; font-family: CMSY7; color: rgb(13, 205, 13);">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">and </span><span style="font-size: 10pt; font-family: CMR10; color: rgb(13, 205, 13);">90</span><span style="font-size: 7pt; font-family: CMSY7; color: rgb(13, 205, 13);">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">positions<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">Two light emitting diodes (LEDs), mounted near the respective photo resistors<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: rgb(13, 205, 13);">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(13, 205, 13);">MATLAB software on a PC, including the Instrument Control & Data Acquisition Tool Boxes.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: red;">Experiments Outline </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The experiments involve a computer controlled rotational stepper motor. The motor receives two<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">types of commands from the computer (which are translated to voltage inputs in the control box):<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">1. A step command results with the shaft turning over a fixed arc length. The step arc length varies from motor to<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">motor, from a few degrees (you will determine how many) in this experiment, to a small fraction of a single degree,<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">in precision positioners.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">2. A direction command, determining whether subsequent steps motions are executed in the clockwise or counterclockwise<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">directions.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The motor is also equipped with two photo-resistors, used as light sensors: when the photo-resistor is exposed to<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">light its resistance is lower than when it is covered. The computer is capable of obtaining sensor readings. Thus the computer<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">can tell whether themotor shaft is at the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">0</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">or the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">90</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">positions, since there the flag is covering the respective sensors.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The experimental tasks in Lab 2 include:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">• </span><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Estimating the single step angle: </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Since the flag does not provide a precise reading of the shaft’s rotation angle,<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">a single step experiment is insufficient. You will design a multi-step experiment to obtain an accurate estimate, as<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">well as an upper bound over the residual error. This type of experimental estimates of instrument properties and the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">search for a priori error bounds are prevalent in engineering applications.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">• </span><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Open and Closed Loop Motion Planning: </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Motion planning is a principal ingredient in engineering applications<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">such as robotics and computer controlled machine tools (e.g., a programmable lathe). In <i>open loop </i>motion planning<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">one relies on machine precision and program the number of steps and direction changes that comprise the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">desired path. In <i>closed loop </i>motion planning sensors are used to determine the motor position, to correct for the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">accumulation of small errors in executed motion. Here you will utilize the available photosensors.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">In order to be able to execute these tasks we shall have to employ the important programming tools of <i>logical branching<o:p></o:p></i></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and <i>looping</i>.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 14.5pt; font-family: "Times New Roman","serif"; color: black;">2 Homework Assignments<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Pre-Lab Homework<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">– </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Read this handout carefully.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">– </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Read Chapter 7 in the textbook<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">– </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Optional: Read Section 4.2-4.3 (pp.87-93)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">– </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Do Problems 1, 5, 7(a), 10, 11, on pages 227 – 229; include printout of the MATLAB command window with<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">your answers.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">– </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Prepare an M-Files to perform all the tasks listed as <b>Pre-Lab Programming</b>, along this handout.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: blue;">Pre-Lab Programming tasks include<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">_ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Including a printout of your programs in the Pre-Lab Report that is submitted in the first session of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">lab, and<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">_ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Bringing to the lab a floppy diskette that includes these programs. You will run the programs in the lab<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and will <b>not </b>have enough time to prepare them in the lab.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">• </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Post-Lab report due one week after experiment is finished.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">3<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 14.5pt; font-family: "Times New Roman","serif"; color: black;">3 The Experiment<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 12pt; font-family: "Times New Roman","serif"; color: black;">3.1 Computer-Controlled Stepper Motor Operation & Sensor Thresholds<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The computer is connected to various instruments through input and output (I/O) ports. Those are used to receive information<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">from the stepper motor and related devices, and to issue commands to the motor, through its control box. Motion<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">actuation and data acquisition by use of MATLAB require some detailed MATLAB programs that are already stored as<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">M-Files in the lab computers. You do not need to access these detailed programs directly (nor should you attempt to<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">modify them!). For the purpose of our lab, it suffices to accept the name of each program as a MATLAB command. Once<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">you type the name of the program, it is executed to achieve the desired action. The following description concerns motion<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">actuation and related commands.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: blue;">Important: </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">On occasion you will need to rotate the stepper motor shaft manually. To be able to do so you have to first<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">switch the control box off. (Use the single on/off switch on the control box.) Remember to switch the control box ”on”<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">again when you finish such manual rotation!<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Cambria Math","serif"; color: blue;">⋆</span><span style="font-size: 10pt; font-family: MSAM10; color: blue;"> </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The command </span><span style="font-size: 10pt; font-family: Courier; color: blue;">setup rot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">initiates the necessary programs for interactions with the motor. You should issue this<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command in the command window <b>once </b>in each session. (Repeated execution may result with memory problems!)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Cambria Math","serif"; color: blue;">⋆</span><span style="font-size: 10pt; font-family: MSAM10; color: blue;"> </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The command </span><span style="font-size: 10pt; font-family: Courier; color: blue;">onerot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">executes the motion actuation signal. In our stepper motor it is a short signal of 5 Volts,<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">received at the control box step port. Each time </span><span style="font-size: 10pt; font-family: Courier; color: black;">onerot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">is executed, such an impulse is received and the motor rotates a<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">fixed angle, which we call a “step”. Motion over longer angles is achieved via a succession of steps.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Cambria Math","serif"; color: blue;">⋆</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The direction signal may take two possible voltage values: Following the execution of the command </span><span style="font-size: 10pt; font-family: Courier; color: blue;">cwrot</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">, a constant<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">10V signal is sent to the direction input port in the motor control box. Future actuation signals will then cause the motor<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">to rotate clockwise. Following the execution of the command </span><span style="font-size: 10pt; font-family: Courier; color: blue;">ccrot</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">, the direction port voltage is set to zero volts and<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">future actuation signals will cause the motor to rotate counterclockwise. The direction voltage is kept constant, until a<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">new command is issued, or until the system is disconnected. The commands </span><span style="font-size: 10pt; font-family: Courier; color: black;">cwrot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and </span><span style="font-size: 10pt; font-family: Courier; color: black;">ccrot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">do not cause any motion<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">by themselves.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Cambria Math","serif"; color: blue;">⋆</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The <i>function </i></span><span style="font-size: 10pt; font-family: Courier; color: blue;">readcell(</span><span style="font-size: 10pt; font-family: CMSY10; color: blue;">·</span><span style="font-size: 10pt; font-family: Courier; color: blue;">) </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">reads the voltage across the photo-resistors: </span><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(1) </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">reads sensor #1 and </span><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(2)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">reads sensor #2. You will have to determine, experimentally, which of the two sensors is #1 and which is #2.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">EXAMPLE: To assign the sensor #1 reading to a MATLAB variable named </span><span style="font-size: 10pt; font-family: Courier; color: black;">sensor value </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">one issues the MATLAB<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">sensor value=readcell(1)</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Note Again: </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The commands </span><span style="font-size: 10pt; font-family: Courier; color: black;">setup rot, onerot, cwrot, ccrot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and </span><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(.) </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">require special software<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and are <b>not </b>recognized byMATLAB, other than on HTT&TL computers. To test programs using these and other HTT&TL<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">special command on other computers you have to comment these commands (using %) and substitute the by “<i>dummy</i>”<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">display commands. For example, to debug a motion control program, temporarily replace “</span><span style="font-size: 10pt; font-family: Courier; color: black;">cwrot</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">” by “</span><span style="font-size: 10pt; font-family: Courier; color: black;">disp(’next<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">motion clockwise’)</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">. However, the programs you prepare in your Pre-Lab assignment must contain the original<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">HTT&TL commands.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Experiment 1: </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Test the basic motor functions, using the command window.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">1. Execute (once!) the command </span><span style="font-size: 10pt; font-family: Courier; color: black;">setup rot</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">2. Type in the command window the <i>for </i>loop<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">for k=1:10<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">onerot;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">end<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">4<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Watch the motor while you hit the </span><span style="font-size: 10pt; font-family: Courier; color: black;">return </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">key to execute the loop. You or your team mate may lightly touch the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">shaft of the motor (<b>NOT </b>the flag!) whiel the program executes. Record your observation.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">3. Type </span><span style="font-size: 10pt; font-family: Courier; color: black;">ccrot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and repeat the previous step. Record your observation.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">4. Type </span><span style="font-size: 10pt; font-family: Courier; color: black;">cwrot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and repeat the previous step. Record your observation.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">5. Switch off the control box; bring the flag to a position between the two sensors (say, at </span><span style="font-size: 10pt; font-family: CMR10; color: black;">45</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">). Execute the functions<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(1) </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and </span><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(2) </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and record in your notebook the returned values.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">6. Repeat the previous step when the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">0</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">sensor is covered.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">7. Repeat the previous step when the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">90</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">sensor is covered.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">8. Based on the previous 3 experiments, determine<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(a) What are the respective positions of sensor #1 and sensor #2<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(b) Determine what you consider as a good threshold such that<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">• </span><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(1)>threshold </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">implies that sensor #1 is covered<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMSY10; color: black;">• </span><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(1)<threshold><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">implies that sensor #1 is exposed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Is the same threshold good for sensor #2?<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Pre-Lab Task 1. </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Consider the following program and explain in detail what should be the response of the motor<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">cwrot<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">while readcell(1)<threshold<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">onerot<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">end<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Save this program in an M-file named </span><span style="font-size: 10pt; font-family: Courier; color: black;">move a while.m<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Lab Experiment 2. </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The purpose of this experiment is to test your threshold and practice the use of <i>while </i>loops.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">1. Switch the control box off, bring the flag near the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">180</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">position and switch the control box on again.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">2. Type </span><span style="font-size: 10pt; font-family: Courier; color: black;">cwrot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">in the command window<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">3. Execute </span><span style="font-size: 10pt; font-family: Courier; color: black;">move a while.m<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">4. Repeat step 1, above, and type </span><span style="font-size: 10pt; font-family: Courier; color: black;">ccrot </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">in the command window.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">5. Execute </span><span style="font-size: 10pt; font-family: Courier; color: black;">move a while.m<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">6. Record your observations<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 12pt; font-family: "Times New Roman","serif"; color: black;">3.2 Determination of A Single Step Size<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The purpose of this experiment is to determine the angle (in degrees) travelled by the flag in a single step.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(0, 0, 231);">The Challenge</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">: Since the flag is not pointed, angle reading includes an error of up to </span><span style="font-size: 10pt; font-family: CMR10; color: black;">2</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">measured angle = real angle + error<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Execution of a single step will thus yield<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">estimated step = measured terminal angle - measured initial angle<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">= real terminal angle + error2 - real initial angle - error1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">5<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and the total error may be up to <b>twice </b>the original error bound.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(0, 0, 231);">The Remedy</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">: If instead of a single step, a succession of </span><span style="font-size: 10pt; font-family: Courier; color: black;">n </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">steps is executed, the single step estimate becomes<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">estimated step </span><span style="font-size: 10pt; font-family: CMR10; color: black;">= </span><span style="font-size: 10pt; font-family: Courier; color: black;">measured terminal angle - measured initial angle<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 7pt; font-family: CMTT8; color: black;">n<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMR10; color: black;">= </span><span style="font-size: 10pt; font-family: Courier; color: black;">real terminal angle - real initial angle + error2 - error1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 7pt; font-family: CMTT8; color: black;">n<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: CMR10; color: black;">= </span><span style="font-size: 10pt; font-family: Courier; color: black;">real step size + error2 - error1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 7pt; font-family: CMTT8; color: black;">n<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(1)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">The advantage is the here the total measurement error (</span><span style="font-size: 10pt; font-family: Courier; color: black;">error1 - error2</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">) does not increase, but its effect on the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: Courier; color: black;">estimated step </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">is reduced by a factor of </span><span style="font-size: 10pt; font-family: Courier; color: black;">n</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Pre-Lab Task 2. </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Create a program named step angle estimate.m. This program should<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">1. Uses the </span><span style="font-size: 10pt; font-family: Courier; color: black;">input </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command (with a screen display of the request, see page 28-29 in the book) to request input values<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">for </span><span style="font-size: 10pt; font-family: Courier; color: black;">n </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and </span><span style="font-size: 10pt; font-family: Courier; color: black;">initial angle</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">2. Executes a <i>for </i>loop that commands </span><span style="font-size: 10pt; font-family: Courier; color: black;">n </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">counterclockwise steps (i.e., in the angle growth direction).<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">3. Uses the </span><span style="font-size: 10pt; font-family: Courier; color: black;">input </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command to request a value for </span><span style="font-size: 10pt; font-family: Courier; color: black;">terminal angle</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">4. Uses Equation (1) to estimate the step angle, and assign it to a variable named </span><span style="font-size: 10pt; font-family: Courier; color: black;">step angle</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">5. Uses either </span><span style="font-size: 10pt; font-family: Courier; color: black;">disp </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">or </span><span style="font-size: 10pt; font-family: Courier; color: black;">fprintf </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command to display the estimated step angle.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Lab Experiment 3.<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">1. Visually estimate an upper bound (in degrees) over the </span><span style="font-size: 10pt; font-family: Courier; color: black;">measured angle </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">error.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">2. Using Equation (1), compute how many steps are needed (i.e. how large should </span><span style="font-size: 10pt; font-family: Courier; color: black;">n </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">be) in order to guarantee that the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">step estimation error will be less than </span><span style="font-size: 10pt; font-family: CMR10; color: black;">0</span><span style="font-size: 10pt; font-family: CMMI10; color: black;">.</span><span style="font-size: 10pt; font-family: CMR10; color: black;">01</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">3. Estimate the step angle:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(a) Estimate the current angle of the flag.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(b) Execute step angle estimate.m with </span><span style="font-size: 10pt; font-family: Courier; color: black;">n </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">as determined in part 2.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(c) Input the values for </span><span style="font-size: 10pt; font-family: Courier; color: black;">n </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and </span><span style="font-size: 10pt; font-family: Courier; color: black;">initial angle</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(d) Watch the motor as your program executes, and count how many full rotations it completes before it stops.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(e) Estimate the terminal angle of the flag once the motor stops. Remember to add </span><span style="font-size: 10pt; font-family: CMR10; color: black;">360</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">for each complete circle<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(i.e., each time the flag passes the original angle)! For example, if the starting angle estimate is </span><span style="font-size: 10pt; font-family: CMR10; color: black;">36</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">flag completes two full circles and stops at </span><span style="font-size: 10pt; font-family: CMR10; color: black;">275</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">, the ending angle is </span><span style="font-size: 10pt; font-family: CMR10; color: black;">2 </span><span style="font-size: 10pt; font-family: CMSY10; color: black;">× </span><span style="font-size: 10pt; font-family: CMR10; color: black;">360</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: CMR10; color: black;">+ 275</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: CMR10; color: black;">= 975</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">(f) Input the value of </span><span style="font-size: 10pt; font-family: Courier; color: black;">terminal angle</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 12pt; font-family: "Times New Roman","serif"; color: black;">3.3 Open Loop Motion Planning<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Here the goal is to make the motor go through a succession of pre-assigned angle motions, using <i>for </i>loops.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Pre-Lab Task 3. </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Create a program named open loop.m to perform the following tasks<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">1. Rotate clockwise an arc of</span><span style="font-size: 7pt; font-family: "Times New Roman","serif"; color: black;">1 </span><span style="font-size: 10pt; font-family: CMR10; color: black;">70</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">2. Display the statement </span><span style="font-size: 10pt; font-family: Courier; color: black;">Arc No. 1 Completed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 6pt; font-family: "Times New Roman","serif"; color: black;">1</span><span style="font-size: 8pt; font-family: "Times New Roman","serif"; color: black;">If the assigned arc length is not an integer multiple of a single step angle, round the necessary number of steps to the nearest integer. You may use<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: "Times New Roman","serif"; color: black;">MATLAB’s </span><span style="font-size: 8pt; font-family: Courier; color: black;">round </span><span style="font-size: 8pt; font-family: "Times New Roman","serif"; color: black;">commnd (see MATLAB help).<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">6<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">3. Rotate counterclockwise </span><span style="font-size: 10pt; font-family: CMR10; color: black;">1435</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">4. Display the statement </span><span style="font-size: 10pt; font-family: Courier; color: black;">Arc No. 2 Completed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">5. Rotate clockwise </span><span style="font-size: 10pt; font-family: CMR10; color: black;">25</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">6. Display the statement </span><span style="font-size: 10pt; font-family: Courier; color: black;">Mission Completed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Lab Experiment 4. </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Debug and execute the program </span><span style="font-size: 10pt; font-family: Courier; color: black;">open loop.m</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">. Include a printout of the relevant portion of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command window in your lab report.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 12pt; font-family: "Times New Roman","serif"; color: black;">3.4 Closed Loop Motion Planning<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Here the goal is to make the motor go through a succession of pre-assigned angle motions, using sensor measurement<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">feedback and both <i>for </i>and <i>while </i>loops.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Pre-Lab Task 3. </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Create a program named closed loop.m to perform the following tasks<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">1. Uses the </span><span style="font-size: 10pt; font-family: Courier; color: black;">input </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command to obtain by user input the values of </span><span style="font-size: 10pt; font-family: Courier; color: black;">threshold</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">, </span><span style="font-size: 10pt; font-family: Courier; color: black;">num0sensor </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">= the number (1 or 2)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">of the photo resistor at the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">0</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">position, and of </span><span style="font-size: 10pt; font-family: Courier; color: black;">num90sensor </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">= the number (1 or 2) of the photo resistor at the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">90</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">position. These variables will be used in using </span><span style="font-size: 10pt; font-family: Courier; color: black;">readcell(num...) </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">and in logical conditions in what follows.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">2. Rotate clockwise till the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">0</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">position is reached.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">3. Display the statement </span><span style="font-size: 10pt; font-family: Courier; color: black;">Arc No. 1 Completed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">4. Rotate counterclockwise till the </span><span style="font-size: 10pt; font-family: CMR10; color: black;">90</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">position is reached.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">5. Display the statement </span><span style="font-size: 10pt; font-family: Courier; color: black;">Arc No. 2 Completed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">6. Continue an additional counterclockwise </span><span style="font-size: 10pt; font-family: CMR10; color: black;">425</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">7. Display the statement </span><span style="font-size: 10pt; font-family: Courier; color: black;">Arc No. 3 Completed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">8. Rotate clockwise till he </span><span style="font-size: 10pt; font-family: CMR10; color: black;">0</span><span style="font-size: 7pt; font-family: CMSY7; color: black;">◦ </span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">position is reached.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">9. Display the statement </span><span style="font-size: 10pt; font-family: Courier; color: black;">Mission Completed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: rgb(205, 13, 13);">Lab Experiment 5. </span></b><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">Debug and execute the program </span><span style="font-size: 10pt; font-family: Courier; color: black;">closed loop.m</span><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">. Include a printout of the relevant portion of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Times New Roman","serif"; color: black;">command window in your lab report.<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: "Times New Roman","serif"; color: black;">7</span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-20232843822250700612008-12-11T23:15:00.000-08:002008-12-23T03:58:34.945-08:00MATLAB programming concepts <!-- /* Font Definitions */ @font-face {font-family:Courier; panose-1:2 7 4 9 2 2 5 2 4 4; mso-font-charset:0; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:fixed; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:CMSY10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMR10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMMI8; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMR8; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMSY8; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMSY6; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMR6; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMMI10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMMI7; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMEX10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMR7; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMR5; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMMI5; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:CMSY7; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:auto; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"MS Mincho"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >This session is used to introduce basic (</span><span style=";font-family:";font-size:10;color:blue;" >MATLAB</span><span style=";font-family:";font-size:10;color:black;" >) programming concepts, including<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Variable definitions<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Arrays and array manipulations<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >2D plotting<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Script M-files<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Basic (</span><span style=";font-family:";font-size:10;color:blue;" >Engineering / Science</span><span style=";font-family:";font-size:10;color:black;" >) concepts, including<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Parameter estimation from noisy data<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Matching a mathematical model to data<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >The driving application involve </span><span style=";font-family:";font-size:10;" >estimation of the speed of sound in air </span><span style=";font-family:";font-size:7;" >1 </span><span style=";font-family:";font-size:10;color:black;" >and </span><span style=";font-family:";font-size:10;" >acoustic distance measurement </span><span style=";font-family:";font-size:10;color:black;" >to remote<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >objects. Specific tasks include<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Measuring the travel time between ultrasound transducers<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Estimating the speed of sound in air from measurement data<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Acoustic distance measurement<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >The </span><span style=";font-family:";font-size:10;" >components & equipment </span><span style=";font-family:";font-size:10;color:black;" >used in this experiment include<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Two sound wave transducers: an emitter (essentially, a small, directional loudspeaker) and a receiver (essentially, a<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >directional microphone); a mark on the basis of each transducer assembly indicates which is the emitter and which<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >is the receiver.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >The emitter is connected to a pre-programmed signal generator<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >Both transducers are connected to a digital oscilloscope<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >A measuring tape (metric), glued to the lab bench<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >A clip board<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="color: rgb(13, 205, 13);font-family:CMSY10;font-size:10;" >• </span><span style=";font-family:";font-size:10;" >MATLAB, installed on the computer.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;" >Experiment Outline: </span></b><span style=";font-family:";font-size:10;color:black;" >The emitter transducer emits a short burst of several cycles of a sound wave at a 40kHz frequency</span><span style=";font-family:";font-size:7;color:black;" >2</span><span style=";font-family:";font-size:10;color:black;" >.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >The receiver, located at a selected distance from the emitter, picks up the sound wave. The two transducers are connected<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >to the two input channels of a digital oscilloscope. The process is automatically repeated, periodically, every 10 ms. </span><span style=";font-family:";font-size:7;color:black;" >3<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >The oscilloscope displays the recorded sound waves from both transducers. Using features of the oscilloscope display<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >you will be able to measure the time it takes travel time of the sound wave from the emitter to the receiver. In principle, a<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >single measurement suffices to compute an estimate of the speed of sound:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >speed of sound </span><span style=";font-family:CMR10;font-size:10;color:black;" >=<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >travel distance<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >travel time<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(1)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >or equivalently<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >travel distance </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:";font-size:10;color:black;" >speed of sound </span><span style=";font-family:CMSY10;font-size:10;color:black;" >· </span><span style=";font-family:";font-size:10;color:black;" >travel time (2)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:6;color:black;" >1 </span><span style=";font-family:";font-size:8;color:black;" >Actually, the speed of sound varies with temperature and air pressure, and the results obtained will provide an estimate for the altitude and<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:8;color:black;" >temperature of our lab environment.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:6;color:black;" >2</span><span style=";font-family:";font-size:8;color:black;" >The frequency of 1 Hz (one Hertz) means one cycle per second; 1 kHz (one kilo-Hertz) stands for 1000 cycles per second. Thus the sound wave<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:8;color:black;" >used in our experiments is of 40,000 cycles per second.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:6;color:black;" >3</span><span style=";font-family:";font-size:8;color:black;" >The notation “ms” stands for “milisecond”, or 0.001 second. We shall later encounter also the “</span><span style=";font-family:CMMI8;font-size:8;color:black;" >μs</span><span style=";font-family:";font-size:8;color:black;" >”, standing for “microsecond”, which is </span><span style=";font-family:CMR8;font-size:8;color:black;" >1</span><span style=";font-family:CMMI8;font-size:8;color:black;" >μs </span><span style=";font-family:CMR8;font-size:8;color:black;" >=<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMR8;font-size:8;color:black;" >1 </span><span style=";font-family:CMSY8;font-size:8;color:black;" >· </span><span style=";font-family:CMR8;font-size:8;color:black;" >10</span><span style=";font-family:CMSY6;font-size:6;color:black;" >−</span><span style=";font-family:CMR6;font-size:6;color:black;" >6 </span><span style=";font-family:CMR8;font-size:8;color:black;" >= 1</span><span style=";font-family:CMMI8;font-size:8;color:black;" >e </span><span style=";font-family:CMSY8;font-size:8;color:black;" >− </span><span style=";font-family:CMR8;font-size:8;color:black;" >6 </span><span style=";font-family:CMMI8;font-size:8;color:black;" >sec</span><span style=";font-family:";font-size:8;color:black;" >.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >2<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >In practice, multiple measurements are needed to overcome measurement errors of both the travel time and the distance<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >between the transducers. Moreover, due to the physical structures of the transducers, distance measurements will be<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >biased</span><span style=";font-family:";font-size:10;color:black;" >, meaning that even without any other inaccuracies, the actual distance between transducers is different from what<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >we can measure by a fixed amount:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >measured travel distance </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:";font-size:10;color:black;" >speed of sound </span><span style=";font-family:CMSY10;font-size:10;color:black;" >· </span><span style=";font-family:";font-size:10;color:black;" >travel time </span><span style=";font-family:CMR10;font-size:10;color:black;" >+ </span><span style=";font-family:";font-size:10;color:black;" >bias (3)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >This last equation is of the general form of a linear graph<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI10;font-size:10;color:black;" >y </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:CMMI10;font-size:10;color:black;" >a x </span><span style=";font-family:CMR10;font-size:10;color:black;" >+ </span><span style=";font-family:CMMI10;font-size:10;color:black;" >b </span><span style=";font-family:";font-size:10;color:black;" >(4)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >You will conduct ten experiments and obtain ten values for distance / travel time pairs. You will then use a MATLAB<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >program to optimally fit a linear graph of the form (4) to your data. The quantity “</span><span style=";font-family:CMMI10;font-size:10;color:black;" >a</span><span style=";font-family:";font-size:10;color:black;" >” in that fit will be your estimate of<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the speed of sound, as in (3).<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Having estimated the speed of sound and the distance measurement bias, acoustic distance measurement to a remote<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >object will again use the formula (3): Now the two transducers will be placed side by side. The emitter’s sound wave will<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >travel to the target object, bounce back and be recorded by the receiver. The travel distance will thus be twice the distance<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >to the remote object. Having measured the travel time, we can thus conclude<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >distance to remote object </span><span style=";font-family:CMR10;font-size:10;color:black;" >= 0</span><span style=";font-family:CMMI10;font-size:10;color:black;" >.</span><span style=";font-family:CMR10;font-size:10;color:black;" >5 (</span><span style=";font-family:";font-size:10;color:black;" >speed of sound </span><span style=";font-family:CMSY10;font-size:10;color:black;" >· </span><span style=";font-family:";font-size:10;color:black;" >travel time </span><span style=";font-family:CMR10;font-size:10;color:black;" >+ </span><span style=";font-family:";font-size:10;color:black;" >bias</span><span style=";font-family:CMR10;font-size:10;color:black;" >) </span><span style=";font-family:";font-size:10;color:black;" >(5)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >The representation of the relationship between travel distance and travel time in the basic formula (3) is a </span><span style=";font-family:";font-size:10;" >mathematical<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >model</span><span style=";font-family:";font-size:10;color:black;" >. Your final task in this lab will be find an alternative mathematical model, relating the distance to the </span><span style=";font-family:";font-size:10;" >peak<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >amplitude </span><span style=";font-family:";font-size:10;color:black;" >of the return sound wave, instead of to the travel time.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >Programming: </span><span style=";font-family:";font-size:10;color:black;" >The data recording and processing required in this experiment require an introduction to some of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >essential building blocks of programming, in </span><span style=";font-family:";font-size:10;" >any programming language</span><span style=";font-family:";font-size:10;color:black;" >. We shall use this lab as an opportunity to<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >introduce these concepts, as explained below.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:14;color:black;" >2 Homework Assignment<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >¿From Lab 2 and on, our practice will be to go through relevant components of the text book </span><span style=";font-family:";font-size:10;" >before </span><span style=";font-family:";font-size:10;color:black;" >the lab meeting, and<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >include assigned preparatory work by then. Since this is our first meeting, the primer component of Lab 1 is included in<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the work for the final lab report. In preparation of your report<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Read this entire handout carefully.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Do the following in a Pre-Lab assignments<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >Read</span><span style=";font-family:";font-size:7;color:black;" >4 </span><span style=";font-family:";font-size:10;color:black;" >in the course text </span><span style=";font-family:";font-size:10;" >MATLAB: An Introduction with Applications<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >Chapter 1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >Chapter 2<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >Optional Section 4.3.1 (pp. 91-93) (We shall discuss the necessary material in class)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >Optional: 2D Plots, pp. 119-124 (We shall discuss the necessary material in class)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >Do the following problems (include a printout of the MATLAB command window with the solution of each<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >problem):<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >Problems 1-5 and 1-15 on pages 28, 30<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >Problems 2-1, 2-3, 2-14 on pages 53, 54<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Following completion of the Lab, write a Post-Lab report, summarizing the experiments and your findings, as explained<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >below.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:6;color:black;" >4</span><span style=";font-family:";font-size:8;color:black;" >Here and throughout, preparatory reading is </span><span style=";font-family:";font-size:8;" >essential </span><span style=";font-family:";font-size:8;color:black;" >for the understanding of class material and the ability to perform tasks in class or in the lab.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >3<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:14;color:black;" >3 Measuring The Speed of Sound: The Experiment<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >You will conduct ten experiments and record your data in your notebook. Later you will analyze these data using MATLAB.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >Attention: </span><span style=";font-family:";font-size:10;color:black;" >Make sure you record all your measurements in the standard </span><span style=";font-family:Courier;font-size:10;color:black;" >meters</span><span style=";font-family:";font-size:10;color:black;" >, </span><span style=";font-family:Courier;font-size:10;color:black;" >seconds </span><span style=";font-family:";font-size:10;color:black;" >and </span><span style=";font-family:Courier;font-size:10;color:black;" >Volts </span><span style=";font-family:";font-size:10;color:black;" >units!<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >1. Position the emitter so that its face will be directed along the measuring tape and the front of its base is flush with<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the 0 position.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >2. Position the receiver at a point of your selection along the measuring tape, anywhere between 5 - 50cm, facing the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >emitter. (The position is measured from the front of the transducer’s base.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >The oscilloscope displays both the emitter signal (Channel 1) and the receiver signal (Channel 2). You will notice the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >record of the short interval of a high amplitude emitter waveform, early on (on the left), followed by an essentially<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(close to) zero reading and then, an area of increased amplitude waveform, more to the right. This second waveform<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >is the record of the sound wave sensed by the receiver.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >3. Read the time it takes sound to travel from the emitter to the receiver:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(a) Press the </span><span style=";font-family:";font-size:10;" >curser </span><span style=";font-family:";font-size:10;color:black;" >bottom<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(b) Under the display window, select <b>t1<o:p></o:p></b></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(c) Use the “<b>entry</b>” knob to bring one vertical cursor in the oscilloscope window to the point where, by your<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >visual judgement, the emitter burst begins<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(d) Under the display window, select <b>t2<o:p></o:p></b></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(e) Use the “<b>entry</b>” knob to bring the second vertical cursor in the oscilloscope window to the beginning of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >elevation in the response, in Channel 2.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(f) The corresponding time difference - the sought travel time - appears as “</span><span style=";font-family:CMR10;font-size:10;color:black;" >_</span><b><span style=";font-family:";font-size:10;color:black;" >t</span></b><span style=";font-family:";font-size:10;color:black;" >” in the oscilloscope display<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >window. (Pay attention to the time units used: 1 ms = 1e-3 s; 1</span><span style=";font-family:CMMI10;font-size:10;color:black;" >μ</span><span style=";font-family:";font-size:10;color:black;" >s = 1e-6 s.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >4. Record the data pair, consisting of the sound travel time (</span><span style=";font-family:";font-size:10;" >in seconds!</span><span style=";font-family:";font-size:10;color:black;" >) and the distance between the fronts of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >bases of the two transducers (</span><span style=";font-family:";font-size:10;" >in meters!</span><span style=";font-family:";font-size:10;color:black;" >)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Using a calculator, estimate the speed of sound from each of the ten experiments, using the formula (1).<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >5. For later use, record also the peak-to-peak amplitude of the received sound wave<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(a) Press the </span><span style=";font-family:";font-size:10;" >curser </span><span style=";font-family:";font-size:10;color:black;" >bottom<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(b) Under the display window, select <b>v1<o:p></o:p></b></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(c) Use the “<b>entry</b>” knob to bring one horizontal cursor in the oscilloscope window to the lowest peak of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >receiver signal<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(d) Under the display window, select <b>v2<o:p></o:p></b></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(e) Use the “<b>entry</b>” knob to bring the second horizontal cursor in the oscilloscope window to the highest peak of<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the receiver signal<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >(f) The corresponding voltage difference appears as “</span><span style=";font-family:CMR10;font-size:10;color:black;" >_</span><b><span style=";font-family:";font-size:10;color:black;" >v</span></b><span style=";font-family:";font-size:10;color:black;" >” in the oscilloscope display window. (Pay attention to<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the voltage units used! Record the peak-to-peak value in Volts.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >4<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:14;color:black;" >4 Acoustic Distance Measurement: The Experiment<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Here we shall demonstrate the principles of commercially available acoustic distance measurement devices (with diverse<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >applications ranging from monitoring chemical process reactors to real estate), with our simple setup.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Place the standing clipboard at the zero position of the measuring tape, with its face facing the length of the measuring<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >tape.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Place both the receiver and the emitter, side by side, at a selected position along the measuring tape (5 - 30 cm),<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >facing the clipboard. (The front of their bases is used as the transducers’ position, just as in the previous experiment.)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Use the oscilloscope to measure the travel time of the sound wave from the emitter to the receiver. Record the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >distance and travel time in your notebook.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Repeat the experiment 2 more times, at different distances.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >In </span><span style=";font-family:CMSY10;font-size:10;color:black;" >§</span><span style=";font-family:";font-size:10;color:black;" >5.6 you will compare the actual distance with a distance estimated in terms of the travel time.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >5<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:14;color:black;" >5 Data AnalysisWith MATLAB<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >MATLAB basics will be learned, based on your assigned reading and class practice. </span><span style=";font-family:CMSY10;font-size:10;color:black;" >§</span><span style=";font-family:";font-size:10;color:black;" >5.1 and </span><span style=";font-family:CMSY10;font-size:10;color:black;" >§</span><span style=";font-family:";font-size:10;color:black;" >5.2 are included as<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >immediate reminders. The discussion of data analysis begins in </span><span style=";font-family:CMSY10;font-size:10;color:black;" >§</span><span style=";font-family:";font-size:10;color:black;" >5.3.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:12;color:black;" >5.1 Creating & Saving a New M-File on a Memory Stick<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >MATLAB computations can be executed directly from the MATLAB command window, or by use of program files.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >MATLAB programs are saved as <b>M-files </b>in an accessible directory, as explained below. Since lab computers will be used<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >by others we shall <b>never </b>save programs on the hard disk. Here and throughout, programs will be saved as M-files on a<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >memory stick and run from the appropriate directory. </span><span style=";font-family:";font-size:10;" >In what follows we refer to the directory of the memory stick as<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >“<b>E</b>”. Make sure to check which directory is actually occupied by the memory stick and substitute the correct reference for<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >“E”. </span><span style=";font-family:";font-size:10;" >Files saved on the hard disk might be erased and lost without prior notice!<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Insert a memory clip<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >In the MATLAB command window, change directory to the floppy drive<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>> cd E:</span><span style=";font-family:CMSY10;font-size:10;color:black;" >\<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Verify the current directory<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>pwd<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>> E:</span><span style=";font-family:CMSY10;font-size:10;color:black;" >\<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Under “File”, select “New M-file”<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Save the new M-file under a name of your choice, with the suffix “.m” (for example SOS Lab1.m is a good name<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >for a program used to measure the speed of sound in Lab 1). The following rules apply to names used for both<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >MATLAB variables and M-files:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >the name must begin with a letter<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >the name may contain letters, numbers and the underscore sign<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >the name may not contain other characters, or a space<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >the name may not be equal to the name of a recognized MATLAB function (such as </span><span style=";font-family:Courier;font-size:10;color:black;" >sin</span><span style=";font-family:";font-size:10;color:black;" >, </span><span style=";font-family:Courier;font-size:10;color:black;" >cos</span><span style=";font-family:";font-size:10;color:black;" >, </span><span style=";font-family:Courier;font-size:10;color:black;" >log</span><span style=";font-family:";font-size:10;color:black;" >, etc.).<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >When in doubt, do not use a suspected name for your variables and programs!<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >To run an M-file as a </span><span style=";font-family:";font-size:10;" >script program</span><span style=";font-family:";font-size:10;color:black;" >, type its name in the </span><span style=";font-family:";font-size:10;" >MATLAB workspace </span><span style=";font-family:";font-size:10;color:black;" >and hit return. Alternatively, select<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the </span><span style=";font-family:";font-size:10;" >run </span><span style=";font-family:";font-size:10;color:black;" >icon in the editor window.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:12;color:black;" >5.2 Defining MATLAB Variables<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >This part is covered in the required <b>Lab 1 </b>book reading and will be practiced in class. The following is are few highlights:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Variables are used to store data values. The name of the variable is a reference to a point in the memory.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >MATLAB will not recognize a variable before it is expressly defined.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >To see that type </span><span style=";font-family:Courier;font-size:10;color:black;" >boom </span><span style=";font-family:";font-size:10;color:black;" >in the command window. Assuming a variable </span><span style=";font-family:Courier;font-size:10;color:black;" >bum </span><span style=";font-family:";font-size:10;color:black;" >was not previously defined, the response<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >will be<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>boom<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>></span><span style="color: rgb(205, 13, 13);font-family:Courier;font-size:10;" >??? Undefined function or variable ’boom’.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >6<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >The equal sign “=” is used in MATLAB, as in most programming languages, for the <b>assignment </b>operation, acting<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >from left to right. Thus<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>moom=5<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >assigns the value </span><span style=";font-family:Courier;font-size:10;color:black;" >5 </span><span style=";font-family:";font-size:10;color:black;" >to the variable </span><span style=";font-family:Courier;font-size:10;color:black;" >moom</span><span style=";font-family:";font-size:10;color:black;" >. If </span><span style=";font-family:Courier;font-size:10;color:black;" >moom </span><span style=";font-family:";font-size:10;color:black;" >did not previously exist, it also creates this variable in the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >memory. Contrary to the usual usage of “=” in mathematics, the legal operation<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>moom=moom+1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >assigns to the existing variable </span><span style=";font-family:Courier;font-size:10;color:black;" >moom </span><span style=";font-family:";font-size:10;color:black;" >a new value, comprising its old value plus one.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >By default, each value assignment command is followed by a display of the assigned value in the MATLAB command<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >window. This is mostly undesirable, and in case of large array, will dramatically slow down you programs!<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >To prevent this and as a matter of standard practice, end each assignment command with a semicolon <b>“;”<o:p></o:p></b></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Variables may be </span><span style=";font-family:";font-size:10;" >scalars </span><span style=";font-family:";font-size:10;color:black;" >(the default), taking a single number (or character) as a value. They may also be one, two<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >or three dimensional </span><span style=";font-family:";font-size:10;" >arrays </span><span style=";font-family:";font-size:10;color:black;" >of values. Details are provided in the book (pp. 40-48).<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:12;color:black;" >5.3 Experimental Data Recording and Plotting<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >The following commands should be included in an M-file used to record and plot the data from the speed of sound<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >experiment. Your Lab report should include the M-file and a printout of the MATLAB command window were the M-file<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >is executed</span><span style=";font-family:";font-size:7;color:black;" >5<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >define three row vectors of size </span><span style=";font-family:CMR10;font-size:10;color:black;" >1 </span><span style=";font-family:CMSY10;font-size:10;color:black;" >× </span><span style=";font-family:CMR10;font-size:10;color:black;" >10 </span><span style=";font-family:";font-size:10;color:black;" >(remember to type a semicolon “;” at the end of each vector definition!):<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >A vector </span><span style=";font-family:Courier;font-size:10;color:black;" >tdistance </span><span style=";font-family:";font-size:10;color:black;" >whose entries are the 10 distances between the two transducers in your experiments<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >A vector </span><span style=";font-family:Courier;font-size:10;color:black;" >ttime </span><span style=";font-family:";font-size:10;color:black;" >whose entries are the corresponding measured travel times<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >– </span></b><span style=";font-family:";font-size:10;color:black;" >A vector </span><span style=";font-family:Courier;font-size:10;color:black;" >amplitude </span><span style=";font-family:";font-size:10;color:black;" >whose entries are the corresponding measured maximal peak-to-peak amplitudes of<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the receiver signal<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Create a </span><span style=";font-family:CMR10;font-size:10;color:black;" >3 </span><span style=";font-family:CMSY10;font-size:10;color:black;" >× </span><span style=";font-family:CMR10;font-size:10;color:black;" >10 </span><span style=";font-family:";font-size:10;color:black;" >matrix named </span><span style=";font-family:Courier;font-size:10;color:black;" >sosdata </span><span style=";font-family:";font-size:10;color:black;" >whose first row comprises the vector </span><span style=";font-family:Courier;font-size:10;color:black;" >tdistance</span><span style=";font-family:";font-size:10;color:black;" >, the second row is the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >vector </span><span style=";font-family:Courier;font-size:10;color:black;" >ttime </span><span style=";font-family:";font-size:10;color:black;" >and the third row is </span><span style=";font-family:Courier;font-size:10;color:black;" >amplitude</span><span style=";font-family:";font-size:10;color:black;" >.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Use the </span><span style=";font-family:Courier;font-size:10;color:black;" >disp </span><span style=";font-family:";font-size:10;color:black;" >command to display the tabulated data in the matrix </span><span style=";font-family:Courier;font-size:10;color:black;" >sosdata</span><span style=";font-family:";font-size:10;color:black;" >.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Include a command to </span><span style=";font-family:";font-size:10;" >discrete plot </span><span style=";font-family:";font-size:10;color:black;" >of the travel distance (vertical axis) as a function of the travel time (horizontal<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >axis), using black asterisks for data points<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >plot(ttime,tdistance,’k*’)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >Following the plot command, include the title “Speed of Sound Data: </span><span style=";font-family:CMMI10;font-size:10;color:black;" ><</span><span style=";font-family:";font-size:10;color:black;" >your team names</span><span style=";font-family:CMMI10;font-size:10;color:black;" >></span><span style=";font-family:";font-size:10;color:black;" >”, and axis titles “travel<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >time” and “travel distance”:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>title(’Speed of Sound Data: ...’)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>xlabel(’travel time’)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>ylabel(’travel distance’)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Save and run theM-file. Your lab report will include the printedM-file and printed output of the final version of theM-file.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:6;color:black;" >5</span><span style=";font-family:";font-size:8;color:black;" >The simplest way to print a portion of the command window is to use the mouse to highlight that section, then selecting </span><span style=";font-family:Courier;font-size:8;color:black;" >Print Selection<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:8;color:black;" >under the </span><span style=";font-family:Courier;font-size:8;color:black;" >File </span><span style=";font-family:";font-size:8;color:black;" >menu.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >7<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:12;color:black;" >5.4 Polynomial Curve Fitting - General<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Our goal here is to fit the data in the vectors </span><span style=";font-family:Courier;font-size:10;color:black;" >tdistance </span><span style=";font-family:";font-size:10;color:black;" >and </span><span style=";font-family:Courier;font-size:10;color:black;" >ttime </span><span style=";font-family:";font-size:10;color:black;" >with an equation of of the form (3):<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >tdistance </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:";font-size:10;color:black;" >speed of sound </span><span style=";font-family:CMSY10;font-size:10;color:black;" >· </span><span style=";font-family:Courier;font-size:10;color:black;" >ttime </span><span style=";font-family:CMR10;font-size:10;color:black;" >+ </span><span style=";font-family:";font-size:10;color:black;" >bias (6)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Referring to this form, we are trying to estimate the values of the coefficients </span><span style=";font-family:Courier;font-size:10;color:black;" >a=speed of sound </span><span style=";font-family:";font-size:10;color:black;" >and </span><span style=";font-family:Courier;font-size:10;color:black;" >b=bias </span><span style=";font-family:";font-size:10;color:black;" >of a<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >first order polynomial that best fit our recorded data. Here we shall use two MATLAB functions that are introduced only<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >much later in the book (search the index):<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >TheMATLAB function </span><span style="color: rgb(13, 205, 13);font-family:Courier;font-size:10;" >polyfit </span><span style=";font-family:";font-size:10;color:black;" >is used to fit data with a polynomial curve. We shall be interested in the spacial case of<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >a first order (linear) polynomial of the form (4)-(6). Following is a general description of </span><span style=";font-family:Courier;font-size:10;color:black;" >polyfit </span><span style=";font-family:";font-size:10;color:black;" >and the way it is used:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Given same size vectors </span><span style=";font-family:Courier;font-size:10;color:black;" >x=[x(1),...,x(N)] </span><span style=";font-family:";font-size:10;color:black;" >and </span><span style=";font-family:Courier;font-size:10;color:black;" >y=[y(1),...,y(N)] </span><span style=";font-family:";font-size:10;color:black;" >and a prescribed polynomial order </span><span style=";font-family:Courier;font-size:10;color:black;" >M</span><span style=";font-family:";font-size:10;color:black;" >,<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the objective of </span><span style=";font-family:Courier;font-size:10;color:black;" >polyfit </span><span style=";font-family:";font-size:10;color:black;" >is to find the polynomial<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI10;font-size:10;color:black;" >p</span><span style=";font-family:CMR10;font-size:10;color:black;" >(</span><span style=";font-family:CMMI10;font-size:10;color:black;" >u</span><span style=";font-family:CMR10;font-size:10;color:black;" >) =<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >N<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMEX10;font-size:10;color:black;" >X<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >k</span><span style=";font-family:CMR7;font-size:7;color:black;" >=0<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI10;font-size:10;color:black;" >a</span><span style=";font-family:CMMI7;font-size:7;color:black;" >k</span><span style=";font-family:CMMI10;font-size:10;color:black;" >u</span><span style=";font-family:CMMI7;font-size:7;color:black;" >k </span><span style=";font-family:";font-size:10;color:black;" >(7)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >that solves the approximation problem<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMR10;font-size:10;color:black;" >min<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >a</span><span style=";font-family:CMR5;font-size:180%;color:black;" >0</span><span style=";font-family:CMMI7;font-size:7;color:black;" >,...,a</span><span style=";font-family:CMMI5;font-size:180%;color:black;" >M<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >N<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMEX10;font-size:10;color:black;" >X<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >l</span><span style=";font-family:CMR7;font-size:7;color:black;" >=1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMR10;font-size:10;color:black;" >(</span><span style=";font-family:CMMI10;font-size:10;color:black;" >y</span><span style=";font-family:CMR10;font-size:10;color:black;" >(</span><span style=";font-family:CMMI10;font-size:10;color:black;" >l</span><span style=";font-family:CMR10;font-size:10;color:black;" >) </span><span style=";font-family:CMSY10;font-size:10;color:black;" >− </span><span style=";font-family:CMMI10;font-size:10;color:black;" >p</span><span style=";font-family:CMR10;font-size:10;color:black;" >(</span><span style=";font-family:CMMI10;font-size:10;color:black;" >x</span><span style=";font-family:CMR10;font-size:10;color:black;" >(</span><span style=";font-family:CMMI10;font-size:10;color:black;" >l</span><span style=";font-family:CMR10;font-size:10;color:black;" >)))</span><span style=";font-family:CMR7;font-size:7;color:black;" >2 </span><span style=";font-family:";font-size:10;color:black;" >(8)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >That is, the graph of the polynomial </span><span style=";font-family:Courier;font-size:10;color:black;" >p(u) </span><span style=";font-family:";font-size:10;color:black;" >has to best approximate the graph of the data pairs </span><span style=";font-family:Courier;font-size:10;color:black;" >(x(k),y(k)) </span><span style=";font-family:";font-size:10;color:black;" >in the </span><span style=";font-family:";font-size:10;" >least<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >mean squares </span><span style=";font-family:";font-size:10;color:black;" >sense. The general syntax of </span><span style=";font-family:Courier;font-size:10;color:black;" >polyfit </span><span style=";font-family:";font-size:10;color:black;" >is:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>p=polyfit(x,y,M)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >where, in the notations of (7), we identify “</span><span style=";font-family:Courier;font-size:10;color:black;" >p</span><span style=";font-family:";font-size:10;color:black;" >” with the coefficients’ vector </span><span style=";font-family:CMMI10;font-size:10;color:black;" >p </span><span style=";font-family:CMR10;font-size:10;color:black;" >= [</span><span style=";font-family:CMMI10;font-size:10;color:black;" >a</span><span style=";font-family:CMMI7;font-size:7;color:black;" >M</span><span style=";font-family:CMMI10;font-size:10;color:black;" >, a</span><span style=";font-family:CMMI7;font-size:7;color:black;" >M</span><span style=";font-family:CMSY7;font-size:7;color:black;" >−</span><span style=";font-family:CMR7;font-size:7;color:black;" >1</span><span style=";font-family:CMMI10;font-size:10;color:black;" >, . . . , a</span><span style=";font-family:CMR7;font-size:7;color:black;" >1</span><span style=";font-family:CMMI10;font-size:10;color:black;" >, a</span><span style=";font-family:CMR7;font-size:7;color:black;" >0</span><span style=";font-family:CMR10;font-size:10;color:black;" >]</span><span style=";font-family:";font-size:10;color:black;" >.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:";font-size:10;color:black;" >The MATLAB function </span><span style="color: rgb(13, 205, 13);font-family:Courier;font-size:10;" >polyval </span><span style=";font-family:";font-size:10;color:black;" >is used to evaluate a polynomial </span><span style=";font-family:Courier;font-size:10;color:black;" >v=p(u) </span><span style=";font-family:";font-size:10;color:black;" >at a point, or list of points </span><span style=";font-family:Courier;font-size:10;color:black;" >x</span><span style=";font-family:";font-size:10;color:black;" >. The syntax<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >is<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>y=polyval(p,x)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >where the interpretation of </span><span style=";font-family:CMMI10;font-size:10;color:black;" >p </span><span style=";font-family:CMR10;font-size:10;color:black;" >= [</span><span style=";font-family:CMMI10;font-size:10;color:black;" >a</span><span style=";font-family:CMMI7;font-size:7;color:black;" >M</span><span style=";font-family:CMMI10;font-size:10;color:black;" >, . . . , a</span><span style=";font-family:CMR7;font-size:7;color:black;" >1</span><span style=";font-family:CMMI10;font-size:10;color:black;" >, a</span><span style=";font-family:CMR7;font-size:7;color:black;" >0</span><span style=";font-family:CMR10;font-size:10;color:black;" >] </span><span style=";font-family:";font-size:10;color:black;" >is as above, and where </span><span style=";font-family:Courier;font-size:10;color:black;" >x </span><span style=";font-family:";font-size:10;color:black;" >is a single variable or an array. The returned<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >value(s) </span><span style=";font-family:Courier;font-size:10;color:black;" >y=p(x) </span><span style=";font-family:";font-size:10;color:black;" >are stored in an array </span><span style=";font-family:Courier;font-size:10;color:black;" >y </span><span style=";font-family:";font-size:10;color:black;" >whose size is the same size as that of </span><span style=";font-family:Courier;font-size:10;color:black;" >x</span><span style=";font-family:";font-size:10;color:black;" >.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:12;color:black;" >5.5 Linear Fitting of The Speed of Sound Experiment<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >As stated above, our goal is to fit the data pairs </span><span style=";font-family:Courier;font-size:10;color:black;" >(ttime,tdistance) </span><span style=";font-family:";font-size:10;color:black;" >by a straight line, as in (6). You should therefore<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >include in your M-file the command<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>est=polyfit(ttime,tdistance,1)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >In accordancewith the notations of (6), the returned vectorwill be the best estimate of </span><span style=";font-family:Courier;font-size:10;color:black;" >est=[est(1),est(2)]=[speed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >of sound, bias]</span><span style=";font-family:";font-size:10;color:black;" >. If we want to see how good this estimate is, we should substitute the estimated coefficients and<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the entries of </span><span style=";font-family:Courier;font-size:10;color:black;" >ttime </span><span style=";font-family:";font-size:10;color:black;" >in the right hand side of (3). This is done with the command<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>polyval(est,ttime)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >For a visual comparison you will therefore include in your program a plot command that compares the raw data with the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >linear estimate<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >8<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>plot(ttime,tdistance,’k*’,ttime,polyval(est,ttime))<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Notice that here we allow a continuous plot of the linear approximation. Add a title (including name of team members)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >and axes labels commands.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >To evaluate the quality of your estimate of the speed of sound, search the web for “speed of sound” and compare your<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >estimate to what you find in the web. The site http://hyperphysics.phy-astr.gsu.edu/hbase/sound/souspe.html is one option.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:12;color:black;" >5.6 Acoustic Distance Measurement<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >Here you will compute the estimated distance from the transducers to the clipboard in the experiments carried in </span><span style=";font-family:CMSY10;font-size:10;color:black;" >§</span><span style=";font-family:";font-size:10;color:black;" >4. The<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >estimated distance is given by Equation 5, where you have to use your estimates of the speed of sound and the bias term.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >That is, you have to use theMATLAB function </span><span style=";font-family:Courier;font-size:10;color:black;" >polyval </span><span style=";font-family:";font-size:10;color:black;" >and the linear polynomial </span><span style=";font-family:Courier;font-size:10;color:black;" >est=[est(1),est(2)]=[speed<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >of sound, bias]</span><span style=";font-family:";font-size:10;color:black;" >. In your report compare the distance estimate with the actual distance, as recorded in the experiment.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:14;color:black;" >6 An Alternative model<o:p></o:p></span></b></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >As an alternative to the model (3), you will seek a representation of the distance as a function of the maximal peak-to-peak<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >amplitude of the receiver signal. We expect a reverse relation: the longer the distance, the smaller the amplitude. Therefore<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the sought model will be a function of the variable </span><span style=";font-family:CMMI10;font-size:10;color:black;" >x </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:CMR7;font-size:7;color:black;" >1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >amplitude </span><span style=";font-family:";font-size:10;color:black;" >. You are allowed to use the </span><span style=";font-family:Courier;font-size:10;color:black;" >polyfit </span><span style=";font-family:";font-size:10;color:black;" >function to test<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >polynomial approximations of the form<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >travel distance </span><span style=";font-family:CMSY10;font-size:10;color:black;" >_<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >M<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMEX10;font-size:10;color:black;" >X<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >l</span><span style=";font-family:CMR7;font-size:7;color:black;" >=0<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI10;font-size:10;color:black;" >a</span><span style=";font-family:CMMI7;font-size:7;color:black;" >l</span><span style=";font-family:CMMI10;font-size:10;color:black;" >x</span><span style=";font-family:CMMI7;font-size:7;color:black;" >l </span><span style=";font-family:";font-size:10;color:black;" >(9)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >with various levels of the degree </span><span style=";font-family:CMMI10;font-size:10;color:black;" >M</span><span style=";font-family:";font-size:10;color:black;" >. At this point you may rely on visual inspection to evaluate the quality of the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >approximation. Clearly, the higher the degree </span><span style=";font-family:CMMI10;font-size:10;color:black;" >M </span><span style=";font-family:";font-size:10;color:black;" >you allow, the better the fit can be. However, we want the simplest<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >possible formula, and will stop increasing </span><span style=";font-family:CMMI10;font-size:10;color:black;" >M </span><span style=";font-family:";font-size:10;color:black;" >if there is no noticeable improvement. The findings in your report should<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >include:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >The values of the optimal coefficients and polynomial degree<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMSY10;font-size:10;color:black;" >• </span><span style=";font-family:";font-size:10;color:black;" >A plot, comparing the discrete data pairs </span><span style=";font-family:Courier;font-size:10;color:black;" >ttime,amplitude </span><span style=";font-family:";font-size:10;color:black;" >with the plot of the approximating function (9) that<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >you identified. The plot must include a title (with your name) and axes labels.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >Hint: </span></b><span style=";font-family:";font-size:10;color:black;" >To create the data vector </span><span style=";font-family:CMMI10;font-size:10;color:black;" >x </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:CMR7;font-size:7;color:black;" >1<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:CMMI7;font-size:7;color:black;" >amplitude </span><span style=";font-family:";font-size:10;color:black;" >from the data vector </span><span style=";font-family:Courier;font-size:10;color:black;" >amplitude</span><span style=";font-family:";font-size:10;color:black;" >, you use the place-by-place vector<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >division command<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>> x=1./amplitude;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >If you expect the amplitude to vary with the distance according to a power law, (</span><span style=";font-family:CMMI10;font-size:10;color:black;" >amplitude </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:CMMI10;font-size:10;color:black;" >constant </span><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:CMMI10;font-size:10;color:black;" >distance</span><span style=";font-family:CMMI7;font-size:7;color:black;" >n</span><span style=";font-family:";font-size:10;color:black;" >)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >you can try another way to fit the data: Taking the logarithm of both sides of the equation above, you get the following<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >equation:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >>>log (amplitude) = log (constant) + n log(distance)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >If you then define new variables:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >u=log(amplitude)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >v=log(distance)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >L=log(constant)<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >you get the equation:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >u = L + n * v<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >9<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >This is a linear equation and you can do a least squares fit to the data to get he best fit value for n (the slope) and L (the<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >y-intercept). Using the data you took for amplitude vs. distance, use MATLAB to create the new variables u and v. Then<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >use </span><span style=";font-family:Courier;font-size:10;color:black;" >polyfit </span><span style=";font-family:";font-size:10;color:black;" >to get the best fit values for the slope and y intercept. Finally, convert your results back to get the best fit<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >values for </span><span style=";font-family:Courier;font-size:10;color:black;" >constant </span><span style=";font-family:";font-size:10;color:black;" >and </span><span style=";font-family:Courier;font-size:10;color:black;" >n </span><span style=";font-family:";font-size:10;color:black;" >in the equation above: </span><span style=";font-family:CMMI10;font-size:10;color:black;" >amplitude </span><span style=";font-family:CMR10;font-size:10;color:black;" >= </span><span style=";font-family:CMMI10;font-size:10;color:black;" >constant </span><span style=";font-family:CMSY10;font-size:10;color:black;" >_ </span><span style=";font-family:CMMI10;font-size:10;color:black;" >distance</span><span style=";font-family:CMMI7;font-size:7;color:black;" >n</span><span style=";font-family:";font-size:10;color:black;" >.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style=";font-family:";font-size:10;color:black;" >Question </span></b><span style=";font-family:";font-size:10;color:black;" >(answer in your lab report):<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >1. How does your best fit values for constant and </span><span style=";font-family:Courier;font-size:10;color:black;" >n </span><span style=";font-family:";font-size:10;color:black;" >compare with the values from your Power Law fit in Excel?<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >2. How do you think that Excel gets its Power Law fit?<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >3. How could you use polyfit and a linear straight line fit to find the best fit values of </span><span style=";font-family:CMMI10;font-size:10;color:black;" >y</span><span style=";font-family:CMMI7;font-size:7;color:black;" >o </span><span style=";font-family:";font-size:10;color:black;" >and </span><span style=";font-family:CMMI10;font-size:10;color:black;" >a </span><span style=";font-family:";font-size:10;color:black;" >from </span><span style=";font-family:CMR10;font-size:10;color:black;" >(</span><span style=";font-family:CMMI10;font-size:10;color:black;" >x, y</span><span style=";font-family:CMR10;font-size:10;color:black;" >) </span><span style=";font-family:";font-size:10;color:black;" >data that fits<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:black;" >the following exponential equation:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:Courier;font-size:10;color:black;" >y = y o * exp (a *x)<o:p></o:p></span></p> <p class="MsoNormal"><span style="line-height: 115%;font-family:";font-size:10;color:black;" >10</span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-55325985645226172802008-12-11T07:08:00.000-08:002008-12-23T03:58:34.945-08:00ADA Syntax rulesChapter 2<br />1 pragma ::= pragma identifier [(argument_association<br />{, argument_association})];<br />2 argument_association ::=<br />[argument_identifier =>] name<br /> [argument_identifier =>] expression<br />Chapter 3<br />3 graphic_character ::= basic_graphic_character<br /> lower_case_letter other_special_character<br />4 basic_graphic_character ::= upper_case_letter digit<br /> special_character space_character<br />5 basic_character ::= basic_graphic_character format_effector<br />6 identifier ::= letter {[underline] letter_or_digit}<br />7 letter_or_digit ::= letter digit<br />8 letter ::= upper_case_letter lower_case_letter<br />9 numeric_literal ::= decimal_literal based_literal<br />10 decimal_literal ::= integer [. integer] [exponent]<br />11 integer ::= digit {[underline] digit}<br />12 exponent ::= E [+] integer E - integer<br />13 based_literal ::=<br />base # based_integer [. based_integer] # [exponent]<br />14 base ::= integer<br />15 based_integer ::= extended_digit {[underline] extended_digit}<br />16 extended_digit ::= digit letter<br />17 character_literal ::= 'graphic_character'<br />18 string_literal ::= "{graphic_character}"<br />Chapter 4<br />19 basic_declaration ::=<br />object_declaration number_declaration<br /> type_declaration subtype_declaration<br /> subprogram_declaration package_declaration<br /> task_declaration generic_declaration<br /> exception_declaration generic_instantiation<br /> renaming_declaration deferred_constant_declaration<br />20 object_declaration ::=<br />identifier_list : [constant] subtype_indication<br />[:= expression];<br /> identifier_list : [constant] constrained_array_definition<br />[:= expression];<br />21 number_declaration ::=<br />identifier_list : constant := universal_static_expression;<br />22 identifier_list ::= identifier {, identifier}<br />23 assignment_statement ::= variable_name := expression;<br />24 block_statement ::= [block_simple_name :]<br />[declare<br />declarative_part]<br />begin<br />sequence_of_statements<br />[exception<br />exception_handler<br />{exception_handler}<br />end [block_simple_name];<br />25 type_declaration ::=<br />full_type_declaration<br /> incomplete_type_declaration<br /> private_type_declaration<br />26 full_type_declaration ::=<br />type identifier [discriminant_part] is type_definition;<br />27 type_definition ::=<br />enumeration_type_definition integer_type_definition<br /> real_type_definition array_type_definition<br /> record_type_definition access_type_definition<br /> derived_type_definition<br />28 subtype_declaration ::=<br />subtype identifier is subtype_indication;<br />29 subtype_indication ::= type_mark [constraint]<br />30 type_mark ::= type_name subtype_name<br />31 constraint ::= range_constraint floating_point_constraint<br /> fixed_point_constraint index_constraint<br /> discriminant_constraint<br />32 range_constraint ::= range range<br />33 range ::=<br />range_attribute simple_expression .. simple_expression<br />34 enumeration_type_definition ::=<br />(enumeration_literal_specification<br />{, enumeration_literal_specification})<br />35 enumeration_literal_specification ::= enumeration_literal<br />36 enumeration_literal ::= identifier character_literal<br />37 name ::= simple_name character_literal operator_symbol<br /> indexed_component slice selected_component<br /> attribute<br />38 simple_name ::= identifier<br />39 prefix ::= name function_call<br />40 attribute ::= prefix ' attribute_designator<br />41 attribute_designator ::=<br />simple_name [(universal_static_expression)]<br />42 expression ::=<br />relation {and relation}<br /> relation {and then relation}<br /> relation {or relation}<br /> relation {or else relation}<br /> relation {xor relation}<br />43 relation ::=<br />simple_expression [relational_operator simple_expression]<br /> simple_expression [not] in range<br /> simple_expression [not] in type_mark<br />44 simple_expression ::=<br />[unary_adding_operator] term {binary_adding_operator term}<br />45 term ::= factor {multiplying_operator factor}<br />46 factor ::= primary [** primary] abs primary not primary<br />47 primary ::= numeric_literal null aggregate<br /> string_literal name<br /> allocator function_call type_conversion<br /> qualified_expression (expression)<br />48 logical_operator ::= and or xor<br />49 relational_operator ::= = /= < <= > >=<br />50 binary_adding_operator ::= + - &<br />51 unary_adding_operator ::= + -<br />52 multiplying_operator ::= * / mod rem<br />53 highest_precedence_operator ::= ** abs not<br />54 type_conversion ::= type_mark (expression)<br />55 qualified_expression ::=<br />type_mark ' (expression) type_mark ' aggregate<br />Chapter 5<br />56 sequence_of_statements ::= statement {statement}<br />57 statement ::= {label} simple_statement<br /> {label} compound_statement<br />58 simple_statement ::=<br />null_statement assignment_statement<br /> procedure_call_statement exit_statement<br /> return_statement goto_statement<br /> entry_call_statement delay_statement<br /> abort_statement raise_statement<br /> code_statement<br />59 compound_statement ::=<br />if_statement case_statement<br /> loop_statement block_statement<br /> accept_statement select_statement<br />60 label ::= <<label_simple_name>><br />61 null_statement ::= null;<br />62 if_statement ::=<br />if condition then<br />sequence_of_statements<br />{elsif condition then<br />sequence_of_statements}<br />[else<br />sequence_of_statements]<br />end if;<br />63 condition ::= boolean_expression<br />64 case_statement ::=<br />case expression is<br />case_statement_alternative<br />{case_statement_alternative}<br />end case;<br />65 case_statement_alternative ::=<br />when choice { choice} => sequence_of_statements<br />66 choice ::= simple_expression discrete_range others<br /> component_simple_name<br />67 discrete_range ::= discrete_subtype_indication range<br />68 loop_statement ::= [loop_simple_name :]<br />[iteration_scheme] loop<br />sequence_of_statements<br />end loop [loop_simple_name];<br />69 iteration_scheme ::=<br />while condition for loop_parameter_specification<br />70 loop_parameter_specification ::=<br />identifier in [reverse] discrete_range<br />71 exit_statement ::= exit [loop_name] [when condition];<br />72 goto_statement ::= goto label_name;<br />Chapter 6<br />73 array_type_definition ::=<br />unconstrained_array_definition<br /> constrained_array_definition<br />74 unconstrained_array_definition ::=<br />array (index_subtype_definition {,<br />index_subtype_definition}) of<br />component_subtype_indication<br />75 constrained_array_definition ::=<br />array index_constraint of component_subtype_indication<br />76 index_subtype_definition ::= type_mark range <><br />77 index_constraint ::= (discrete_range {, discrete_range})<br />78 indexed_component ::= prefix (expression {, expression})<br />79 slice ::= prefix (discrete_range)<br />80 aggregate ::= (component_association {, component_association})<br />81 component_association ::= [choice { choice} => ] expression<br />82 record_type_definition ::=<br />record<br />component_list<br />end record<br />83 component_list ::=<br />component_declaration {component_declaration}<br /> {component_declaration} variant_part<br /> null;<br />84 component_declaration ::=<br />identifier_list : component_subtype_definition [:=<br />expression];<br />85 component_subtype_definition ::= subtype_indication<br />86 selected_component ::= prefix . selector<br />87 selector ::=<br />simple_name character_literal operator_symbol all<br />Chapter 7<br />88 subprogram_declaration ::= subprogram_specification;<br />89 subprogram_specification ::=<br />procedure identifier [formal_part]<br /> function designator [formal_part] return type_mark<br />90 designator ::= identifier operator_symbol<br />91 operator_symbol ::= string_literal<br />92 formal_part ::= (parameter_specification {;<br />parameter_specification})<br />93 parameter_specification ::=<br />identifier_list : mode type_mark [:= expression]<br />94 mode ::= [in] in out out<br />95 subprogram_body ::=<br />subprogram_specification is<br />[declarative_part]<br />begin<br />sequence_of_statements<br />[exception<br />exception_handler<br />{exception_handler}]<br />end [designator];<br />96 procedure_call_statement ::=<br />procedure_name [actual_parameter_part];<br />97 function_call ::= function_name [actual_parameter_part]<br />98 actual_parameter_part ::=<br />(parameter_association {, parameter_association})<br />99 parameter_association ::=<br />[formal_parameter =>] actual_parameter<br />100 formal_parameter ::= parameter_simple_name<br />101 actual_parameter ::=<br />expression variable_name type_mark (variable_name)<br />102 return_statement ::= return [expression];<br />Chapter 8<br />103 package_declaration ::= package_specification;<br />104 package_specification ::=<br />package identifier is<br />{basic_declarative_item}<br />[private<br />{basic_declarative_item}]<br />end [package_simple_name]<br />105 package_body ::=<br />package body package_simple_name is<br />[declarative_part]<br />[begin<br />sequence_of_statements<br />[exception<br />exception_handler<br />{exception_handler}]]<br />end [package_simple_name];<br />106 declarative_part ::=<br />{basic_declarative_item} {later_declarative_item}<br />107 basic_declarative_item ::=<br />basic_declaration representation_clause use_clause<br />108 later_declarative_item ::=<br />body subprogram_declaration<br /> package_declaration task_declaration<br /> generic_declaration use_clause<br /> generic_instantiation<br />109 body ::= proper_body body_stub<br />110 proper_body ::= subprogram_body package_body task_body<br />111 use_clause ::= use package_name {, package_name};<br />112 compilation ::= {compilation_unit}<br />113 compilation_unit ::=<br />context_clause library_unit<br /> context_clause secondary_unit<br />114 library_unit ::=<br />subprogram_declaration package_declaration<br /> generic_declaration generic_instantiation<br /> subprogram_body<br />115 secondary_unit ::= library_unit_body subunit<br />116 library_unit_body ::= subprogram_body package_body<br />117 context_clause ::= {with_clause {use_clause}}<br />118 with_clause ::= with unit_simple_name {, unit_simple_name};<br />119 body_stub ::=<br />subprogram_specification is separate;<br /> package body package_simple_name is separate;<br /> task body task_simple_name is separate;<br />120 subunit ::= separate (parent_unit_name) proper_body<br />121 renaming_declaration ::=<br />identifier : type_mark renames object_name;<br /> identifier : exception renames exception_name;<br /> package identifier renames package_name;<br /> subprogram_specification renames subprogram_or_entry_name;<br />Chapter 9<br />122 private_type_declaration ::=<br />type identifier [discriminant_part] is [limited] private;<br />123 deferred_constant_declaration ::=<br />identifier_list : constant type_mark;<br />Chapter 10<br />124 exception_handler ::=<br />when exception_choice { exception_choice} =><br />sequence_of_statements<br />125 exception_choice ::= exception_name others<br />126 exception_declaration ::= identifier_list : exception;<br />127 raise_statement ::= raise [exception_name];<br />Chapter 11<br />128 discriminant_part ::=<br />(discriminant_specification {;<br />discriminant_specification})<br />129 discriminant_specification ::=<br />identifier_list : type_mark [:= expression]<br />130 discriminant_constraint ::=<br />(discriminant_association {, discriminant_association})<br />131 discriminant_association ::=<br />[discriminant_simple_name { discriminant_simple_name}<br />=>] expression<br />132 variant_part ::=<br />case discriminant_simple_name is<br />variant<br />{variant}<br />end case;<br />133 variant ::= when choice { choice} => component_list<br />134 access_type_definition ::= access subtype_indication<br />135 incomplete_type_declaration ::=<br />type identifier [discriminant_part];<br />136 allocator ::= new subtype_indication new qualified_expression<br />137 derived_type_definition ::= new subtype_indication<br />Chapter 12<br />138 integer_type_definition ::= range_constraint<br />139 real_type_definition ::=<br />floating_point_constraint fixed_point_constraint<br />140 floating_point_constraint ::=<br />floating_accuracy_definition [range_constraint]<br />141 floating_accuracy_definition ::=<br />digits static_simple_expression<br />142 fixed_point_constraint ::=<br />fixed_accuracy_definition [range_constraint]<br />143 fixed_accuracy_definition ::= delta static_simple_expression<br />Chapter 13<br />144 generic_declaration ::= generic_specification;<br />145 generic_specification ::=<br />generic_formal_part subprogram_specification<br /> generic_formal_part package_specification<br />146 generic_formal_part ::= generic {generic_parameter_declaration}<br />147 generic_parameter_declaration ::=<br />identifier_list : [in [out]] type_mark [:= expression];<br /> type identifier is generic_type_definition;<br /> private_type_declaration<br /> with subprogram_specification [is name];<br /> with subprogram_specification [is <>];<br />148 generic_type_definition ::=<br />(<>) range <> digits <> delta <><br /> array_type_definition access_type_definition<br />149 generic_instantiation ::=<br />package identifier is<br />new generic_package_name [generic_actual_part];<br /> procedure identifier is<br />new generic_procedure_name [generic_actual_part];<br /> function designator is<br />new generic_function_name [generic_actual_part];<br />150 generic_actual_part ::=<br />(generic_association {, generic_association})<br />151 generic_association ::=<br />[generic_formal_parameter =>] generic_actual_parameter<br />152 generic_formal_parameter ::=<br />parameter_simple_name operator_symbol<br />153 generic_actual_parameter ::= expression variable_name<br /> subprogram_name entry_name type_mark<br />Chapter 14<br />154 task_declaration ::= task_specification;<br />155 task_specification ::=<br />task [type] identifier [is<br />{entry_declaration}<br />{representation_clause}<br />end [task_simple_name]]<br />156 task_body ::=<br />task body task_simple_name is<br />[declarative_part]<br />begin<br />sequence_of_statements<br />[exception<br />exception_handler<br />{exception_handler}]<br />end [task_simple_name];<br />157 entry_declaration ::=<br />entry identifier [(discrete_range)] [formal_part];<br />158 entry_call_statement ::= entry_name [actual_parameter_part];<br />159 accept_statement ::=<br />accept entry_simple_name [(entry_index)] [formal_part] [do<br />sequence_of_statements<br />end [entry_simple_name]];<br />160 entry_index ::= expression<br />161 delay_statement ::= delay simple_expression;<br />162 select_statement ::= selective_wait conditional_entry_call<br /> timed_entry_call<br />163 selective_wait ::=<br />select<br />select_alternative<br />{or<br />select_alternative}<br />[else<br />sequence_of_statements]<br />end select;<br />164 select_alternative ::=<br />[when condition =>] selective_wait_alternative<br />165 selective_wait_alternative ::= accept_alternative<br /> delay_alternative terminate_alternative<br />166 accept_alternative ::=<br />accept_statement [sequence_of_statements]<br />167 delay_alternative ::= delay_statement [sequence_of_statements]<br />168 terminate_alternative ::= terminate;<br />169 conditional_entry_call ::=<br />select<br />entry_call_statement<br />[sequence_of_statements]<br />else<br />sequence_of_statements<br />end_select;<br />170 timed_entry_call ::=<br />select<br />entry_call_statement<br />[sequence_of_statements]<br />or<br />delay_alternative<br />end select;<br />171 abort_statement ::= abort task_name {, task_name};<br />Chapter 15<br />172 representation_clause ::=<br />type_representation_clause address_clause<br />173 type_representation_clause ::= length_clause<br /> enumeration_representation_clause<br /> record_representation_clause<br />174 length_clause ::= for attribute use simple_expression;<br />175 enumeration_representation_clause ::=<br />for type_simple_name use aggregate;<br />176 record_representation_clause ::=<br />for type_simple_name use<br />record [alignment_clause]<br />{component_clause}<br />end record;<br />177 alignment_clause ::= at mod static_simple_expression;<br />178 component_clause ::= component_name at<br />static_simple_expression range static_range;<br />179 address_clause ::= for simple_name use at simple_expression;<br />180 code_statement ::= type_mark ' record_aggregate;<br />A4.3 Syntax rules for Ada 9X<br />Chapter 2<br />1* pragma ::= pragma identifier [(pragma_argument_association<br />{, pragma_argument_association})];<br />2* pragma_argument_association ::=<br />[pragma_argument_identifier =>] name<br /> [pragma_argument_identifier =>] expression<br />Chapter 3<br />4* graphic_character ::= letter digit<br /> space_character special_character<br />5* character ::= graphic_character format_effector<br /> other_control_function<br />6* identifier ::= identifier_letter {[underline] letter_or_digit}<br />7* letter_or_digit ::= identifier_letter digit<br />9 numeric_literal ::= decimal_literal based_literal<br />10* decimal_literal ::= numeral [. numeral] [exponent]<br />11* numeral ::= digit {[underline] digit}<br />12* exponent ::= E [+] numeral E - numeral<br />13* based_literal ::=<br />base # based_numeral [. based_numeral] # [exponent]<br />14* base ::= numeral<br />15* based_numeral ::= extended_digit {[underline] extended_digit}<br />16* extended_digit ::= digit A B C D E F<br />17 character_literal ::= 'graphic_character'<br />18* string_literal ::= "{string_element}"<br />18a string_element ::= "" non_qotation_mark_graphic_character<br />18b comment ::= -- {non_end_of_line_character}<br />Chapter 4<br />19* basic_declaration ::=<br />object_declaration number_declaration<br /> type_declaration subtype_declaration<br /> subprogram_declaration package_declaration<br /> generic_declaration exception_declaration<br /> generic_instantiation renaming_declaration<br /> abstract_subprogram_declaration<br />20* object_declaration ::=<br />defining_identifier_list : [aliased] [constant]<br />subtype_indication [:= expression];<br /> defining_identifier_list : [aliased] [constant]<br />array_type_definition [:= expression];<br /> single_task_declaration<br /> single_protected_declaration<br />21* number_declaration ::=<br />defining_identifier_list : constant := static_expression;<br />22* defining_identifier_list ::=<br />defining_identifier {, defining_identifier}<br />22a defining_identifier ::= identifier<br />23 assignment_statement ::= variable_name := expression;<br />24* block_statement ::= [block_statement_identifier :]<br />[declare<br />declarative_part]<br />begin<br />handled_sequence_of_statements<br />end [block_identifier];<br />24a statement_identifier ::= direct_name<br />25* type_declaration ::=<br />full_type_declaration<br /> incomplete_type_declaration<br /> private_type_declaration<br /> private_extension_declaration<br />26* full_type_declaration ::=<br />type defining_identifier [known_discriminant_part]<br />is type_definition;<br /> task_type_declaration<br /> protected_type_declaration<br />27 type_definition ::=<br />enumeration_type_definition integer_type_definition<br /> real_type_definition array_type_definition<br /> record_type_definition access_type_definition<br /> derived_type_definition<br />28* subtype_declaration ::=<br />subtype defining_identifier is subtype_indication;<br />29* subtype_indication ::= subtype_mark [constraint]<br />30* subtype_mark ::= subtype_name<br />31* constraint ::= scalar_constraint composite_constraint<br />31a scalar_constraint ::=<br />range_constraint digits_constraint delta_constraint<br />31b composite_constraint ::=<br />index_constraint discriminant_constraint<br />32 range_constraint ::= range range<br />33* range ::= range_attribute_reference<br /> simple_expression .. simple_expression<br />34 enumeration_type_definition ::=<br />(enumeration_literal_specification<br />{, enumeration_literal_specification})<br />35* enumeration_literal_specification ::=<br />defining_identifier defining character_literal<br />35a defining_character_literal ::= character_literal<br />37* name ::= direct_name explicit_dereference indexed_component<br /> slice selected_component attribute_reference<br /> type_conversion function_call character_literal<br />38* direct_name ::= identifier operator_symbol<br />39* prefix ::= name implicit_dereference<br />39a explicit_dereference ::= name . all<br />39b implicit_dereference ::= name<br />40* attribute_reference ::= prefix ' attribute_designator<br />40a range_attribute_reference ::=<br />prefix ' range_attribute_designator<br />41* attribute_designator ::= identifier [(static_expression)]<br /> Access Delta Digits<br />41a range_attribute_designator ::= Range [(static_expression)]<br />42 expression ::=<br />relation {and relation}<br /> relation {and then relation}<br /> relation {or relation}<br /> relation {or else relation}<br /> relation {xor relation}<br />43* relation ::=<br />simple_expression [relational_operator simple_expression]<br /> simple_expression [not] in range<br /> simple_expression [not] in subtype_mark<br />44 simple_expression ::=<br />[unary_adding_operator] term {binary_adding_operator term}<br />45 term ::= factor {multiplying_operator factor}<br />46 factor ::= primary [** primary] abs primary not primary<br />47* primary ::= numeric_literal null aggregate<br /> string_literal name<br /> allocator qualified_expression (expression)<br />48 logical_operator ::= and or xor<br />49 relational_operator ::= = /= < <= > >=<br />50 binary_adding_operator ::= + - &<br />51 unary_adding_operator ::= + -<br />52 multiplying_operator ::= * / mod rem<br />53 highest_precedence_operator ::= ** abs not<br />54* type_conversion ::=<br />subtype_mark (expression) subtype_mark (name)<br />55* qualified_expression ::=<br />subtype_mark ' (expression) subtype_mark ' aggregate<br />Chapter 5<br />56 sequence_of_statements ::= statement {statement}<br />57 statement ::= {label} simple_statement<br /> {label} compound_statement<br />58* simple_statement ::=<br />null_statement assignment_statement<br /> procedure_call_statement exit_statement<br /> return_statement goto_statement<br /> entry_call_statement delay_statement<br /> abort_statement raise_statement<br /> code_statement requeue_statement<br />59 compound_statement ::=<br />if_statement case_statement<br /> loop_statement block_statement<br /> accept_statement select_statement<br />60* label ::= <<label_statement_identifier>><br />61 null_statement ::= null;<br />62 if_statement ::=<br />if condition then<br />sequence_of_statements<br />{elsif condition then<br />sequence_of_statements}<br />[else<br />sequence_of_statements]<br />end if;<br />63 condition ::= boolean_expression<br />64 case_statement ::=<br />case expression is<br />case_statement_alternative<br />{case_statement_alternative}<br />end case;<br />65* case_statement_alternative ::=<br />when discrete_choice_list => sequence_of_statements<br />65a discrete_choice_list ::= discrete_choice { discrete_choice}<br />66* discrete_choice ::= expression discrete_range others<br />67 discrete_range ::= discrete_subtype_indication range<br />68* loop_statement ::= [loop_statement_identifier :]<br />[iteration_scheme] loop<br />sequence_of_statements<br />end loop [loop_identifier];<br />69 iteration_scheme ::=<br />while condition for loop_parameter_specification<br />70* loop_parameter_specification ::=<br />defining_identifier in [reverse] discrete_subtype_definition<br />71 exit_statement ::= exit [loop_name] [when condition];<br />72 goto_statement ::= goto label_name;<br />Chapter 6<br />73 array_type_definition ::=<br />unconstrained_array_definition<br />constrained_array_definition<br />74* unconstrained_array_definition ::=<br />array (index_subtype_definition {,<br />index_subtype_definition}) of component_definition<br />75* constrained_array_definition ::=<br />array (discrete_subtype_definition {,<br />discrete_subtype_definition}) of component_definition<br />76* index_subtype_definition ::= subtype_mark range <><br />76a discrete_subtype_definition ::=<br />discrete_subtype_indication range<br />76b component_definition ::= [aliased] subtype_indication<br />77 index_constraint ::= (discrete_range {, discrete_range})<br />78 indexed_component ::= prefix (expression {, expression})<br />79 slice ::= prefix (discrete_range)<br />80* aggregate ::=<br />record_aggregate extension_aggregate array_aggregate<br />80a record_aggregate ::= (record_component_association_list)<br />80b record_component_association_list ::=<br />record_component_association<br />{, record_component_association}<br /> null record<br />80c record_component_association ::=<br />[component_choice_list =>] expression<br />80d component_choice_list ::=<br />component_selector_name{ component_selector_name}<br /> others<br />80e array_aggregate ::=<br />positional_array_aggregate named_array_aggregate<br />80f positional_array_aggregate ::=<br />(expression , expression {, expression})<br /> (expression {, expression} , others => expression)<br />80g named_array_aggregate ::=<br />(array_component_association {, array_component_association})<br />80h array_component_association ::=<br />discrete_choice_list => expression<br />82* record_type_definition ::=<br />[[abstract] tagged] [limited] record_definition<br />82a record_definition ::=<br />record<br />component_list<br />end record<br /> null record<br />83* component_list ::=<br />component_item {component_item}<br /> {component_item} variant_part<br /> null;<br />83a component_item ::=<br />component_declaration representation_clause<br />84* component_declaration ::=<br />defining_identifier_list : component_definition<br />[:= default_expression];<br />84a default_expression ::= expression<br />86* selected_component ::= prefix . selector_name<br />87* selector_name ::= identifier character_literal<br />operator_symbol<br />Chapter 7<br />88 subprogram_declaration ::= subprogram_specification;<br />89* subprogram_specification ::=<br />procedure defining_program_unit_name parameter_profile<br /> function defining_designator parameter_and_result_profile<br />89a parameter_profile ::= [formal_part]<br />89b parameter_and_result_profile ::=<br />[formal_part] return subtype_mark<br />90* designator ::=<br />[parent_unit_name . ] identifier operator_symbol<br />90a defining_designator ::=<br />defining_program_unit_name defining_operator_symbol<br />90b defining_program_unit_name ::=<br />[parent_unit_name . ] defining_identifier<br />90c parent_unit_name ::= name<br />91 operator_symbol ::= string_literal<br />91a defining_operator_symbol ::= operator_symbol<br />92 formal_part ::=<br />(parameter_specification {; parameter_specification})<br />93* parameter_specification ::=<br />defining_identifier_list : mode subtype_mark<br />[:= default_expression]<br /> defining_identifier_list : access_definition<br />[:= default_expression]<br />94 mode ::= [in] in out out<br />95* subprogram_body ::=<br />subprogram_specification is<br />declarative_part<br />begin<br />handled_sequence_of_statements<br />end [designator];<br />96* procedure_call_statement ::=<br />procedure_name; procedure_prefix actual_parameter_part;<br />97* function_call ::=<br />function_name function_prefix actual_parameter_part<br />98 actual_parameter_part ::=<br />(parameter_association {, parameter_association})<br />99* parameter_association ::=<br />[formal_parameter_selector_name =>] explicit_actual_parameter<br />101* explicit_actual_parameter ::=<br />expression variable_name<br />102 return_statement ::= return [expression];<br />Chapter 8<br />103 package_declaration ::= package_specification;<br />104* package_specification ::=<br />package defining_program_unit_name is<br />{basic_declarative_item}<br />[private<br />{basic_declarative_item}]<br />end [[parent_unit_name . ] identifier]<br />105* package_body ::=<br />package body defining_program_unit_name is<br />declarative_part<br />[begin<br />handled_sequence_of_statements]<br />end [[parent_unit_name . ] identifier];<br />106* declarative_part ::= {declarative_item}<br />107 basic_declarative_item ::=<br />basic_declaration representation_clause use_clause<br />108* declarative_item ::= basic_declarative_item body<br />109 body ::= proper_body body_stub<br />110* proper_body ::= subprogram_body package_body task_body<br /> protected_body<br />111* use_clause ::= use_package_clause use_type_clause<br />111a use_package_clause ::= use package_name {, package_name};<br />111b use_type_clause ::= use type subtype_mark {, subtype_mark};<br />112 compilation ::= {compilation_unit}<br />113* compilation_unit ::=<br />context_clause library_item<br /> context_clause subunit<br />113a library_item ::=<br />[private] library_unit_declaration library_unit_body<br /> [private] library_unit_renaming_declaration<br />114* library_unit_declaration ::=<br />subprogram_declaration package_declaration<br /> generic_declaration generic_instantiation<br />114a library_unit_renaming_declaration ::=<br />package_renaming_declaration<br /> generic_renaming_declaration<br /> subprogram_renaming_declaration<br />116 library_unit_body ::= subprogram_body package_body<br />117* context_clause ::= {context_item}<br />117a context_item ::= with_clause use_clause<br />118* with_clause ::= with library_unit_name {, library_unit_name};<br />119* body_stub ::= subprogram_body_stub package_body_stub<br /> task_body_stub protected_body_stub<br />119a subprogram_body_stub ::= subprogram_specification is separate;<br />119b package_body_stub ::=<br />package body defining_identifier is separate;<br />119c task_body_stub ::=<br />task body defining_identifier is separate;<br />119d protected_body_stub ::=<br />protected body defining_identifier is separate;<br />120* subunit ::= separate (parent_unit_name) proper_body<br />121* renaming_declaration ::=<br />object_renaming_declaration<br /> exception_renaming_declaration<br /> package_renaming_declaration<br /> subprogram_renaming_declaration<br /> generic_renaming_declaration<br />121a object_renaming_declaration ::=<br />defining_identifier : subtype_mark renames object_name;<br />121b exception_renaming_declaration ::=<br />defining_identifier : exception renames exception_name;<br />121c package_renaming_declaration ::=<br />package defining_program_unit_name renames package_name;<br />121d subprogram_renaming_declaration ::=<br />subprogram_specification renames callable_entity_name;<br />121e generic_renaming_declaration ::=<br />generic package defining_program_unit_name<br />renames generic_package_name;<br /> generic procedure defining_program_unit_name<br />renames generic_procedure_name;<br /> generic function defining_program_unit_name<br />renames generic_function_name;<br />Chapter 9<br />122* private_type_declaration ::=<br />type defining_identifier [discriminant_part] is<br />[[abstract] tagged] [limited] private;<br />Chapter 10<br />124* exception_handler ::=<br />when [choice_parameter_specification :]<br />exception_choice { exception_choice} =><br />sequence_of_statements<br />124a handled_sequence_of_statements ::=<br />sequence_of_statements<br />[exception<br />exception_handler<br />{exception_handler}]<br />124b choice_parameter_specification ::= defining_identifier<br />125 exception_choice ::= exception_name others<br />126* exception_declaration ::= defining_identifier_list : exception;<br />127 raise_statement ::= raise [exception_name];<br />Chapter 11<br />128* discriminant_part ::=<br />unknown_discriminant_part known_discriminant_part<br />128a unknown_discriminant_part ::= (<>)<br />128b known_discriminant_part ::=<br />(discriminant_specification {; discriminant_specification})<br />129* discriminant_specification ::=<br />defining_identifier_list : subtype_mark [:=<br />default_expression]<br /> defining_identifier_list : access_definition [:=<br />default_expression]<br />130 discriminant_constraint ::=<br />(discriminant_association {, discriminant_association})<br />131* discriminant_association ::=<br />[discriminant_selector_name { discriminant_selector_name}<br />=>] expression<br />132* variant_part ::=<br />case discriminant_direct_name is<br />variant<br />{variant}<br />end case;<br />133* variant ::= when discrete_choice_list => component_list<br />134* access_type_definition ::=<br />access_to_object_definition<br /> access_to_subprogram_definition<br />134a access_to_object_definition ::=<br />access [general_access_modifier] subtype_indication<br />134b general_access_modifier ::= all constant<br />134c access_to_subprogram_definition ::=<br />access [protected] procedure parameter_profile<br /> access [protected] function parameter_and_result_profile<br />134d access_definition ::= access subtype_mark<br />135* incomplete_type_declaration ::=<br />type defining_identifier [discriminant_part];<br />136 allocator ::= new subtype_indication new qualified_expression<br />137* derived_type_definition ::=<br />[abstract] new parent_subtype_indication<br />[record_extension_part]<br />Chapter 12<br />138* integer_type_definition ::=<br />signed_integer_type_definition modular_type_definition<br />138a signed_integer_type_definition ::=<br />range static_simple_expression .. static_simple_expression<br />138b modular_type_definition ::= mod static_expression<br />139* real_type_definition ::=<br />floating_point_definition fixed_point_definition<br />140* floating_point_definition ::=<br />digits static_expression [real_range_specification]<br />140a real_range_specification ::=<br />range static_simple_expression .. static_simple_expression<br />142* fixed_point_definition ::= ordinary_fixed_point_definition<br /> decimal_fixed_point_definition<br />142a ordinary_fixed_point_definition ::=<br />delta static_expression real_range_specification<br />142b decimal_fixed_point_definition ::=<br />delta static_expression digits static_expression<br />[real_range_specification]<br />142c digits_constraint ::=<br />digits static_expression [range_constraint]<br />142d delta_constraint ::= delta static_expression [range_constraint]<br />Chapter 13<br />144* generic_declaration ::=<br />generic_subprogram_declaration<br /> generic_package_declaration<br />144a generic_subprogram_declaration ::=<br />generic_formal_part subprogram_specification;<br />144b generic_package_declaration ::=<br />generic_formal_part package_specification;<br />146* generic_formal_part ::=<br />generic {generic_formal_parameter_declaration<br /> use_clause}<br />147* generic_formal_parameter_declaration ::=<br />formal_object_declaration<br /> formal_type_declaration<br /> formal_subprogram_declaration<br /> formal_package_declaration<br />147a formal_object_declaration ::=<br />defining_identifier_list : mode subtype_mark<br />[:= default_expression];<br />147b formal_type_declaration ::=<br />type defining_identifier [discriminant_part] is<br />formal_type_definition;<br />147c formal_type_definition ::=<br />formal_private_type_definition<br /> formal_derived_type_definition<br /> formal_discrete_type_definition<br /> formal_signed_integer_type_definition<br /> formal_modular_type_definition<br /> formal_floating_point_definition<br /> formal_ordinary_fixed_point_definition<br /> formal_decimal_fixed_point_definition<br /> formal_array_type_definition<br /> formal_access_type_definition<br />147d formal_private_type_definition ::=<br />[[abstract] tagged] [limited] private<br />147e formal_derived_type_definition ::=<br />[abstract] new subtype_mark [with private]<br />147f formal_discrete_type_definition ::= (<>)<br />147g formal_signed_integer_type_definition ::= range <><br />147h formal_modular_type_definition ::= mod <><br />147i formal_floating_point_definition ::= digits <><br />147j formal_ordinary_fixed_point_definition ::= delta <><br />147k formal_decimal_fixed_point_definition ::= delta <> digits <><br />147l formal_array_type_definition ::= array_type_definition<br />147m formal_access_type_definition ::= access_type_definition<br />147n formal_subprogram_declaration ::=<br />with subprogram_specification [is subprogram_default];<br />147o subprogram_default ::= default_name <><br />147p default_name ::= name<br />147q formal_package_declaration ::= with package defining_identifier<br />is new generic_package_name formal_package_actual_part;<br />147r formal_package_actual_part ::= (<>) [generic_actual_part]<br />149* generic_instantiation ::=<br />package defining_program_unit_name is<br />new generic_package_name [generic_actual_part];<br /> procedure defining_program_unit_name is<br />new generic_procedure_name [generic_actual_part];<br /> function defining_designator is<br />new generic_function_name [generic_actual_part];<br />150 generic_actual_part ::=<br />(generic_association {, generic_association})<br />151* generic_association ::=<br />[generic_formal_parameter_selector_name =>]<br />explicit_generic_actual_parameter<br />153* explicit_generic_actual_parameter ::=<br />expression variable_name<br /> subprogram_name entry_name subtype_mark<br /> package_instance_name<br />Chapter 14<br />154* task_type_declaration ::=<br />task type defining_identifier [known_discriminant_part]<br />[is task_definition];<br />154a single_task_declaration ::=<br />task defining_identifier [is task_definition];<br />155* task_definition ::=<br />{task_item}<br />[private<br />{task_item}]<br />end [task_identifier]<br />155a task_item ::= entry_declaration representation_clause<br />156* task_body ::=<br />task body defining_identifier is<br />declarative_part<br />begin<br />handled_sequence_of_statements<br />end [task_identifier];<br />157* entry_declaration ::=<br />entry defining_identifier [(discrete_subtype_definition)]<br />parameter_profile;<br />158 entry_call_statement ::= entry_name [actual_parameter_part];<br />159* accept_statement ::=<br />accept entry_direct_name<br />[(entry_index)] parameter_profile [do<br />handled_sequence_of_statements<br />end [entry_identifier]];<br />160 entry_index ::= expression<br />161* delay_statement ::= delay_until_statement<br /> delay_relative_statement<br />161a delay_until_statement ::= delay until delay_expression;<br />161b delay_relative_statement ::= delay delay_expression;<br />162* select_statement ::= selective_accept conditional_entry_call<br /> timed_entry_call asynchronous_select<br />163* selective_accept ::=<br />select<br />[guard]<br />select_alternative<br />{or<br />[guard]<br />select_alternative}<br />[else<br />sequence_of_statements]<br />end select;<br />163a guard ::= when condition =><br />164* select_alternative ::= accept_alternative<br /> delay_alternative terminate_alternative<br />166 accept_alternative ::=<br />accept_statement [sequence_of_statements]<br />167 delay_alternative ::= delay_statement [sequence_of_statements]<br />168 terminate_alternative ::= terminate;<br />169* conditional_entry_call ::=<br />select<br />entry_call_alternative<br />else<br />sequence_of_statements<br />end_select;<br />169a entry_call_alternative ::=<br />entry_call_statement [sequence_of_statements]<br />170* timed_entry_call ::=<br />select<br />entry_call_alternative<br />or<br />delay_alternative<br />end select;<br />171 abort_statement ::= abort task_name {, task_name};<br />Chapter 15<br />172* representation_clause ::=<br />attribute_definition_clause<br /> enumeration_representation_clause<br /> record_representation_clause<br /> at_clause<br />172a local_name ::= direct_name direct_name ' attribute_designator<br /> library_unit_name<br />174* attribute_definition_clause ::=<br />for local_name ' attribute_designator use expression;<br /> for local_name ' attribute_designator use name;<br />175* enumeration_representation_clause ::=<br />for first_subtype_local_name use enumeration_aggregate;<br />175a enumeration_aggregate ::= array_aggregate<br />176* record_representation_clause ::=<br />for first_subtype_local_name use<br />record [mod_clause]<br />{component_clause}<br />end record;<br />177* mod_clause ::= at mod static_expression;<br />178 component_clause ::= component_local_name at<br />position range first_bit .. last_bit;<br />178a position ::= static_expression<br />178b first_bit ::= static_simple_expression<br />178c last_bit ::= static_simple_expression<br />179* at_clause ::= for local_name use at expression;<br />180* code_statement ::= qualified_expression;<br />Chapter 17<br />1X record_extension_part ::= with record_definition<br />2X extension_aggregate ::=<br />(ancestor_part with record_component_association_list)<br />3X ancestor_part ::= expression subtype_mark<br />4X abstract_subprogram_declaration ::=<br />subprogram_specification is abstract;<br />5X private_extension_declaration ::=<br />type defining_identifier [discriminant_part] is<br />[abstract] new ancestor_subtype_indication with private;<br />6X protected_type_declaration ::=<br />protected type defining_identifier<br />[known_discriminant_part] is protected_definition;<br />7X single_protected_definition ::=<br />protected defining_identifier is protected_definition;<br />8X protected_definition ::=<br />{protected_operation_declaration}<br />[private<br />{protected_element_declaration}]<br />end [protected_identifier]<br />9X protected_operation_declaration ::= subprogram_declaration<br /> entry_declaration representation_clause<br />10X protected_element_declaration ::=<br />protected_operation_declaration component_declaration<br />11X protected_body ::=<br />protected body defining_identifier is<br />{protected_operation_item}<br />end [protected_identifier];<br />12X protected_operation_item ::= subprogram_declaration<br /> subprogram_body entry_body representation_clause<br />13X entry_body ::=<br />entry defining_identifier entry_body_formal_part<br />entry_barrier is<br />declarative_part<br />begin<br />handled_sequence_of_statements<br />end [entry_identifier];<br />14X entry_body_formal_part ::=<br />[(entry_index_specification)] parameter_profile<br />15X entry_barrier ::= when condition<br />16X entry_index_specification ::=<br />for defining_identifier in discrete_subtype_definition<br />17X requeue_statement ::= requeue entry_name [with abort];<br />18X asynchronous_select ::=<br />select<br />triggering_alternative<br />then abort<br />abortable_part<br />end select;<br />19X triggering_alternative ::=<br />triggering_statement [sequence_of_statements]<br />20X triggering_statement ::= entry_call_statement delay_statement<br />21X abortable_part ::= sequence_of_statementsSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-34214709714201763392008-12-11T06:56:00.001-08:002008-12-23T03:58:34.945-08:00HTML Resources<a href="http://www.internetvalley.com/intvalold.html">History of the Web</a>All the way from how the internet came into existence to statistics on the growth of the internet. <a href="http://www.w3.org/People/Berners-Lee">Berners-Lee</a> An interview, biography and more. <a href="http://jefferson.village.virginia.edu/elab/hfl0034.html">Vannevar Bush </a>A short biography. This is <a href="http://www.isg.sfu.ca/~duchier/misc/vbush/">the 1945 article</a> that first introduced the idea of hyperlinks. <a href="http://www.si.edu/resource/tours/comphist/ma1.html">Andreessen</a> Another interview and the story of how he founded Netscape.<br />Historical Stuff<br /><a href="http://www.ncsa.uiuc.edu/General/Internet/WWW/HTMLPrimer.html">HTML tutorial: "NCSA (at UIUC) Beginner's Guide to HTML."</a> This is the original and probably still the best introduction. <a href="http://www.idocs.com/tags/index.html">Another HTML tutorial</a> A very nice web site. Nice graphics and good information. <a href="http://builder.cnet.com/Authoring/CSS/">CSS tutorial:</a> elementary. <a href="http://www.idocs.com/tags/frames/frames.html">Frames tutorial </a>Very professionally done. Good information and easy to follow.<br />TutorialsBasic Information<br /><a href="http://home.netscape.com/download/index.html">Download Netscape's browser </a>Here's where you can download the latest version of Netscape Navigator or Netscape Communicator. <a href="http://microsoft.com/ie/">Download Microsoft's browser </a>Follow the links to download the latest version of Internet Explorer for your computer.<br />Browsers<br /><a href="http://www.webreference.com/">Web Reference </a>Lots of good material on the latest features of HTML, CSS, etc. Link to experts in specific topics such as Web page design. <a href="http://www.stars.com/">Another site </a>with references to tutorials and lots of information for web developers. <a href="http://www.stack.nl/htmlhelp/">The Web Design Group </a>is a valuable source of information. Get a European perspective. <a href="http://www.sandia.gov/sci_compute/iso_symbol.html">meta characters in HTML </a>Here's a list of all the codes that are used to represent metacharacters in HTML. <a href="http://www.ippa.org/">Web Design </a>The Internet Professional Publishers Association Check the general web developer sites, but this one is devoted specifically to design and has some excellent work. <a href="http://hoohoo.ncsa.uiuc.edu/docs/tutorials/imagemapping.html">NCSA server-side image map file formats. </a>This is a tutorial on making server-side image maps for NCSA formats. <a href="http://www.holonet.net/support/holowww/htimage.html">CERN server-side image maps. </a>This shows how to build server-side image maps using CERN formats. <a href="http://www.developer.com/directories/pages/dir.java.html/">gamelan.com </a>This is the place to search for useful Java applets by category. <a href="http://validator.w3.org/">HTML validator </a>From the people who write the standards. <a href="http://www.benedict.com/">Copyright law </a>They bill themselves as "The Copyright Website". <a href="http://www.patents.com/copyrigh.sht">More about copyright law.</a> Here's a page with links to more information than you may want to know about copyright law.<br />Web Developer InformationDesignImage maps Copyright Law<br /><a href="ftp://ftp.aw.com/graphics/colorTable.html">Color Table</a> Here are 216 "safe" colors that should display equally well in all browsers. <a href="http://www.iconbazaar.com/">Icon images </a>Lots of different kinds of images including small images, icons, bars. <a href="http://www.stars.com/Vlib/Providers/Images_and_Icons.html">Graphical images you can download. </a>A wealth of free graphical downloads that can be used with your Web documents. Includes icons, background textures and more. <a href="http://www.dcs.ed.ac.uk/~mxr/gfx/">Graphics file formats.</a> You may never need to know how graphics files are put together. But if you ever do, this is where to get the informationSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-61628057340328421812008-11-19T21:59:00.000-08:002008-12-23T03:58:34.945-08:00INFRARED PHOTOGRAPHY<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"></o:smarttagtype><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves>false</w:TrackMoves> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" semihidden="false" unhidewhenused="false" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" unhidewhenused="false" name="toc 1"> <w:lsdexception locked="false" unhidewhenused="false" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" unhidewhenused="false" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" unhidewhenused="false" name="Body Text 2"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page Section1 {size:8.5in 11.0in; margin:1.0in 10.1pt 1.0in 10.1pt; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults ext="edit" spidmax="2050"> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout ext="edit"> <o:idmap ext="edit" data="1"> </o:shapelayout></xml><![endif]--> <p class="MsoNormal" style="text-align: center;" align="center"><b style=""><span style="font-size: 26pt;">
<br /><o:p></o:p></span></b></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Welcome to my tutorial on Infrared Photography.<span style=""> </span>I hope to be able to show you in this tutorial the joys of Infrared Photography.<span style=""> </span>It is a technique that is either loved or hated by many and you don’t see a great deal of it out there for that reason.<span style=""> </span>Some people say you can find out if your camera can do Infrared Photography simply by pointing a TV remote at the lens, pressing a button and if you are able to see a red light through the viewfinder then you are able to use that camera for Infrared Photography.<span style=""> </span>However, I do have a camera here that A) I have not been able to see that light, but B) I have been able to use for Infrared Photography, although that camera is not my preferred choice.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">I originally started out doing Infrared Photography with my Sony DSC F828.<span style=""> </span>I loved the technique, so I went on to buy the Nikon D70s.<span style=""> </span>From that I was able to do the colored version of Infrared Photography where you see almost a fantasy feel to the image of blue skies, white foliage and white grass with a tinge of red and yellow throughout the rest of the image.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Again, it is not everybody’s cup of tea but if you want to try Infrared Photography go for it.<span style=""> </span>You can get your camera converted to do Infrared Photography permanently but it is expensive and that camera can no longer be used for normal photography without the aid of a filter.<span style=""> </span>That is why I have one camera I mainly use for Infrared work and the rest of my cameras for normal work.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">So in front of you, you can see there is a few different images, all Infrared images and yet they all seem to have a different result.<span style=""> </span>We will go through them one by one.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: center;" align="center">__________________________________________________________________________</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Okay, so let’s start.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:formulas> <v:path extrusionok="f" gradientshapeok="t" connecttype="rect"> <o:lock ext="edit" aspectratio="t"> </v:shapetype><v:shape id="_x0000_s1027" type="#_x0000_t75" style="'position:absolute;" wrapcoords="-50 0 -50 21532 21600 21532 21600 0 -50 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.jpg" title="DSC08517-Original-800"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image002.jpg" shapes="_x0000_s1027" align="left" width="372" height="274" hspace="12" /><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1026" type="#_x0000_t75" style="'position:absolute;margin-left:297pt;" wrapcoords="-51 0 -51 21531 21600 21531 21600 0 -51 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image003.jpg" title="Road Through Dreams"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image004.jpg" shapes="_x0000_s1026" align="left" width="372" height="275" hspace="12" /><!--[endif]-->Here, you can see I have two images.<span style=""> </span>The first one, this one on the left here, the greenish style image, is the original, just resized from the Sony DSC F828.<span style=""> </span>I used a standard Infrared filter, it wasn’t a Hoya, but it was very suitable for that camera.<span style=""> </span>The image was handheld facing towards cotton fields.<span style=""> </span>Cotton fields are green, but as you can see, with the help of the filter and with the cameras ability, the cotton fields have come up white.<span style=""> </span>Now I then took that particular image into Adobe and played around with the Levels as well as Hue & Saturation and I formed this (above right).</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1028" type="#_x0000_t75" style="'position:absolute;margin-left:-.35pt;margin-top:13.4pt;width:297.35pt;" wrapcoords="-45 0 -45 21542 21600 21542 21600 0 -45 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image005.jpg" title="HS 1"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image006.jpg" shapes="_x0000_s1028" align="left" width="396" height="311" hspace="12" /><!--[endif]-->Now it’s very simply how you get that from the green, just your Hue & Saturation Adjustment layer as you can see here.<span style=""> </span>And by ticking colorize, you can then play around with your different colors as you can see where they are coming in there.<span style=""> </span>And then by playing around with your actual amount of saturation etc, you can form different effects within the image.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The image went on to take a blue ribbon on DPC and has since been sold exclusively for a CD cover.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1031" type="#_x0000_t75" style="'position:absolute;margin-left:396pt;margin-top:20.45pt;width:199.35pt;" wrapcoords="-73 0 -73 21551 21600 21551 21600 0 -73 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image007.jpg" title="DSC_0881-01-800-CM"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image008.jpg" shapes="_x0000_s1031" align="left" width="266" height="396" hspace="12" /><!--[endif]-->Now we move onto the Nikon D70s. I have three images here in front of us.<span style=""> </span></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1029" type="#_x0000_t75" style="'position:absolute;margin-left:198pt;margin-top:6.65pt;width:196.45pt;" wrapcoords="-72 0 -72 21552 21600 21552 21600 0 -72 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image009.jpg" title="DSC_0881-01-800"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image010.jpg" shapes="_x0000_s1029" align="left" width="262" height="396" hspace="12" /><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1030" type="#_x0000_t75" style="'position:absolute;margin-left:0;" wrapcoords="-71 0 -71 21553 21600 21553 21600 0 -71 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image011.jpg" title="DSC_0879-01-800"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image012.jpg" shapes="_x0000_s1030" align="left" width="263" height="396" hspace="12" /><!--[endif]--></p> <p class="MsoNormal">The first one was simply the Nikon D70s with a Hoya R72 filter.<span style=""> </span>Now you might have heard people speak of doing a Custom White Balance.<span style=""> </span>That is crucial when you are dealing with this type of Infrared Photography.<span style=""> </span>This red image is with the camera just set to Auto White Balance.<span style=""> </span>And you can see it comes out quite red which is recognized as Infrared Photography but it is not the form that I like myself and I think a lot of you out there prefer the more colored version.<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">So all you do is get your camera with the filter on it and I hand point the camera at the grass.<span style=""> </span>I do a Custom White Balance of that.<span style=""> </span>I then stand the tripod back up.<span style=""> </span>I always use a remote for my Infrared work as you are looking at long shutter speeds so you really have to alleviate any movement within the camera itself.<span style=""> </span>Once I have done my Custom White Balance, that is generally what I will use for my White Balance for the rest of the shoot unless of course I am changing locations etc.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">I will then remove the filter; I will use Manual Focus, which is essential as I find that through the dark filter the camera is just not able to focus on what you want it to focus on.<span style=""> </span>So I stick purely with my Manual focusing.<span style=""> </span>I compose my shot within the viewfinder.<span style=""> </span>Once I have the focus and the composition how I want in general, I will carefully replace the filter and I will take the shot and that’s where we come to this one here (image on left).<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1033" type="#_x0000_t75" style="'position:absolute;margin-left:347.65pt;margin-top:4.2pt;width:247.7pt;" wrapcoords="-73 0 -73 21551 21600 21551 21600 0 -73 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image007.jpg" title="DSC_0881-01-800-CM"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image013.jpg" shapes="_x0000_s1033" align="left" width="330" height="492" hspace="12" /><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1032" type="#_x0000_t75" style="'position:absolute;margin-left:0;" wrapcoords="-72 0 -72 21552 21600 21552 21600 0 -72 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image009.jpg" title="DSC_0881-01-800"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image014.jpg" shapes="_x0000_s1032" align="left" width="325" height="492" hspace="12" /><!--[endif]-->You can see the shot is quite different to the one without the Custom White Balance.<span style=""> </span>You can see the sky is a brownish/reddish color, the foliage is white.<span style=""> </span>There is quite a good deal of contrast within this image.<span style=""> </span>This image has just been resized for the purpose of this tutorial.<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">From there I then create this (image on right) and I will take you through step-by-step on how to get it from the brown skies to the blue skies.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Okay, let’s start by working on this image.<span style=""> </span>You can see this image is quite a good image to start with but it does need a bit of help.<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1035" type="#_x0000_t75" style="'position:absolute;margin-left:369pt;margin-top:12.6pt;width:205.6pt;" wrapcoords="-41 0 -41 21557 21600 21557 21600 0 -41 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image015.jpg" title="CM 1"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image016.jpg" shapes="_x0000_s1035" align="left" width="274" height="262" hspace="12" /><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_s1034" type="#_x0000_t75" style="'position:absolute;margin-left:9pt;" wrapcoords="-63 0 -63 21547 21600 21547 21600 0 -63 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image017.jpg" title="Adjustment Layer 1"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image018.jpg" shapes="_x0000_s1034" align="left" width="194" height="231" hspace="12" /><!--[endif]--></p> <p class="MsoNormal">We’ll start by swapping the channels which is purely either clicking down here to your Adjustment Layers and going up to the Channel Mixer, or, you could go to Layer/New Adjustment/Channel Mixer.<span style=""> </span>Now from here you can see that you’ve got your Output Channels, Red, Green and Blue.<span style=""> </span>Start with your Red and highlight your value and change that to ‘0’.<span style=""> </span>Go down to your Blue and type in ‘100’.<span style=""> </span>It’s changed it to Green.<span style=""> </span>We haven’t finished yet.<span style=""> </span>Go to your Blue Channel, in the Red type in ‘100’ and in the Blue take that down to ‘0’.<span style=""> </span>Okay, now we are getting somewhere.<span style=""> </span>Click OK.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now that is your most crucial step in this type of processing.<span style=""> </span>As you can see when I turn the layer on and off, you can see the difference.<span style=""> </span>It has swapped the channels around.<span style=""> </span>What was red is now blue and what was blue is now red.<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">From there we need to start doing a little bit of tweaking and this is where it is going to vary depending on what image you are actually going to be working with.<span style=""> </span>We will go to Hue & Saturation.<span style=""> </span>Again make an Adjustment Layer; this gives you a little bit more flexibility down the track.<span style=""> </span>Now we will look at our Blues for starters and we will increase it up to say ‘35’.<span style=""> </span>Again each image is different.<span style=""> </span>Our Cyan’s, which are quite predominant in the sky, we’ll take up to ‘19’.<span style=""> </span>If you want to see how you are going just click the preview on and off.<span style=""> </span>Now it is only subtle but we have more work to do yet. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1036" type="#_x0000_t75" style="'position:absolute;margin-left:0;margin-top:4.85pt;width:234pt;height:182.45pt;" wrapcoords="-34 0 -34 21557 21600 21557 21600 0 -34 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image019.jpg" title="HS 2"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image020.jpg" shapes="_x0000_s1036" align="left" width="312" height="243" hspace="12" /><!--[endif]--><span style=""> </span>Now some people like to leave the red and yellow hue that you can see in the image where my eyedropper is pointing over his shirt, in the tree, there is a tinge just across here, so what we can do is click on the reds or the yellows.<span style=""> </span>Now when we have clicked on the yellow on the drop down menu, we will then take our eyedropper over to our image and we will click.<span style=""> </span>And you can see up here it has now changed to blues and it’s shown you in the scale down here where that color is.<span style=""> </span>So if I click on his shirt it’s changed it to yellows and you can see down here it is in the yellow area.<span style=""> </span>So we will look at the yellows and we will drop the saturation.<span style=""> </span>Now you watch his shirt.<span style=""> </span>It is suddenly going down.<span style=""> </span>Now you might find there are other little areas that are showing a bit of color that you don’t want within the image.<span style=""> </span>Simply grab your ‘plus’ eyedropper and as you can see it says ‘Add to sample’.<span style=""> </span>Click on that.<span style=""> </span>Now just click around different areas and it will show you.<span style=""> </span>See how it is changing the image?<span style=""> </span>So we will just hit ‘Alt’ and that will put reset.<span style=""> </span>That will take it back to what it was.<span style=""> </span>So now we will quickly type, put these back in.<span style=""> </span>Back up to ‘19’ and we will go to our yellows.<span style=""> </span>Click our sample and drop that down.<span style=""> </span>Okay.<span style=""> </span>So again, all I have done is I have increased the Blue and the Cyan but I have removed the yellow.<span style=""> </span>Now as I said there might be other colors in it.<span style=""> </span>You can actually see a little bit of color here, I will just zoom into that so you can see it a bit easier.<span style=""> </span>Can you see that yellow that is still showing up on the bike?<span style=""> </span>Alright, so if I reopen my Hue & Saturation by double clicking on the icon, I will go to my yellows and I will click on the ‘Add’ and I will click on there (front of the bike) on that bit of yellow and you can see how it is removed, before and after (clicking on the preview).<span style=""> </span>So I will click OK.<span style=""> </span>So now we are down to basically a blue and white image which is a good starting point.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now this image really does need a bit of contrast, so, we will make an Adjustment Layer/Brightness & Contrast and we will increase it up to ‘10’.<span style=""> </span>Again before and after.<span style=""> </span>Starting to make shape.<span style=""> </span>Now to me, I am pretty pedantic and that blue really does need a little bit more punch to it.<span style=""> </span></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1037" type="#_x0000_t75" style="'position:absolute;margin-left:0;margin-top:10.8pt;width:261pt;height:238.6pt;" wrapcoords="-41 0 -41 21555 21600 21555 21600 0 -41 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image021.jpg" title="SC 1"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image022.jpg" shapes="_x0000_s1037" align="left" width="348" height="318" hspace="12" /><!--[endif]--></p> <p class="MsoNormal">So we will go to Selective Color Adjustment Layer.<span style=""> </span>Go to our Cyan’s and start playing with the sliders.<span style=""> </span>Now this particular image I know will take a ‘+50’ in the Cyan as you can see, below and above.<span style=""> </span>So we will put in the ‘+50’.<span style=""> </span>And it will take a ‘+50’ in the Magenta. <span style=""> </span>And it will take a ‘-22’ in the Yellow as you can see.<span style=""> </span>Now we are starting to get somewhere.<span style=""> </span>I will also go to my Blues as that is really the only other color within this image.<span style=""> </span>From here I will go to ‘-33’ (Cyan’s) and this one I will take to ‘+41’ (Magentas).<span style=""> </span>The Yellow, by changing it around as you can see, it is only a subtle change but by adding Yellow it seems to give it a flat appearance.<span style=""> </span>By putting it up here (in the Negative) it gives that little bit more punch.<span style=""> </span>I will just take it to ‘-33’, I don’t like taking it to far.<span style=""> </span>Okay.<span style=""> </span>So we click okay.<span style=""> </span>Now, before the Selective Color, and after (clicking the eye on and off).<span style=""> </span>Makes a big difference.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now we are going to add a little bit of Levels to give it that little bit more punch.<span style=""> </span>So, get our Levels and we will slide this (the black triangle) down to about there ‘4’.<span style=""> </span>Okay.<span style=""> </span>And we will take this one (white triangle) just up a little bit ‘250’.<span style=""> </span>Alright.<span style=""> </span>Again it is only very subtle but it just, if you can look on that tree trunk it just makes that little bit of difference.<span style=""> </span>Okay.<span style=""> </span>Detail is everything when you are working on images like this.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now, I like the image so far but I feel there are just some details within the bike that are lost.<span style=""> </span>So I am going to duplicate my background layer and I am going to call it Highlight/Shadow.<span style=""> </span>And here I am going to add Highlight/Shadow which can be found in Image/Adjustments/Shadow & Highlight.<span style=""> </span>Okay.<span style=""> </span>Now as you can see just by turning that feature on it has made a difference.<span style=""> </span>When I click the preview on and off you watch the bike details.<span style=""> </span>Can you see how it comes out a little bit more?<span style=""> </span>I am not too worried about the rest of the image I am just looking at the bike detail.<span style=""> </span>Okay.<span style=""> </span>So I am going to click okay on that.<span style=""> </span>But as I said I don’t really want it too affect the entire image, just the actual bike.<span style=""> </span>So I am just going to bring up my Tool Bar here.<span style=""> </span>And I am going to put a mask on this layer.<span style=""> </span>Okay.<span style=""> </span>So you can see your background layer and there is the Highlight/Shadow.<span style=""> </span>And when I turn it on and off you can see the difference it makes.<span style=""> </span>But I am going to add a mask to it.<span style=""> </span>I am going to flood that mask entirely with black to hide it.<span style=""> </span>Making sure my opacity up here is set to ‘100’ I just click once (on the image) and it has hidden the entire layer.<span style=""> </span>Now by taking my brush and making my foreground white, I am going to paint white over the areas that I want that layer to have an effect on.<span style=""> </span>In this case it is the bike.<span style=""> </span>As you can see I am starting to bring up the details now.<span style=""> </span>Now you watch when I click the layer off and back on.<span style=""> </span>It has only affected the actual bike.<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1038" type="#_x0000_t75" style="'position:absolute;margin-left:0;margin-top:18pt;width:174.15pt;" wrapcoords="-73 0 -73 21555 21600 21555 21600 0 -73 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image023.jpg" title="Layers 1"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image023.jpg" shapes="_x0000_s1038" align="left" width="232" height="374" hspace="12" /><!--[endif]-->Now, I am going to add a little bit more Brightness & Contrast here.<span style=""> </span>There is still a couple of little areas that need tweaking to my satisfaction.<span style=""> </span>So, I am going to add Brightness & Contrast.<span style=""> </span>Can you see how it makes a difference on the tree and the clouds and the bike?<span style=""> </span>But, as you can see, it has blown a bit of the other areas, a little bit too much. Okay.<span style=""> </span>So we will click OK and you can see it has already got its own built in mask.<span style=""> </span>But, we don’t want it to effect the entire areas and instead of just painting black the areas we don’t want it to effect, it’s actually going to be easier this way to paint in the areas we want it to effect.<span style=""> </span>So, again, we will flood the mask with black.<span style=""> </span>So we have hidden the entire layer.<span style=""> </span>Now, using our brush and white, we are going to paint in the areas we want it to effect.<span style=""> </span>So using a brush and as you can see I always tend to use a good soft brush.<span style=""> </span>That way I haven’t got any hard edges to it.<span style=""> </span>I will increase my brush size and I will paint the areas I want to affect.<span style=""> </span>In this case, the bike, the man, the trunk of the tree and a bit of these clouds at the back here.<span style=""> </span>Okay.<span style=""> </span>Just a little dab here and there just to give that little bit of punch, okay.<span style=""> </span>Now, you watch when I turn this layer off and back on again.<span style=""> </span>I feel there is a little bit too much over his face, so I will change my foreground color to black, lower my brush size and remove that over the face.<span style=""> </span>Right.<span style=""> </span>Again, before and after. <span style=""> </span>Makes quite a difference.<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now as you can see there is a little bit over here so really that just needs to be flattened and then cropped.<span style=""> </span>As you can see I am just going to remove that bit off the bottom, alright.<span style=""> </span>Now let’s zoom in a little bit and you can see it has made quite a difference.<span style=""> </span>Right, you can see nice detail around the bike; you can even see his shoe.<span style=""> </span>You can see some reflections in the water.<span style=""> </span>And yes, some of the leaves are blurred slightly.<span style=""> </span>Because you are working with long shutter speeds, the slightest bit of breeze is going to be affecting the image and as we were standing on the edge of a cliff this was unfortunately part of the parcel.<span style=""> </span>But, I can see a sensor spot here so I am just going to grab my Healing Brush and just dab it once on there to remove that.<span style=""> </span>Okay.</p> <p class="MsoNormal"><!--[if gte vml 1]><v:shape id="_x0000_s1039" type="#_x0000_t75" style="'position:absolute;margin-left:0;margin-top:10.25pt;width:261.35pt;" wrapcoords="-27 0 -27 21571 21600 21571 21600 0 -27 0"> <v:imagedata src="file:///D:\USERPR~1\sshende\LOCALS~1\Temp\msohtmlclip1\01\clip_image024.jpg" title="SFW 1"> <w:wrap type="tight"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/USERPR%7E1/sshende/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image025.jpg" shapes="_x0000_s1039" align="left" width="348" height="333" hspace="12" /><!--[endif]--></p> <p class="MsoNormal">Now, let’s resize it to ‘800’.<span style=""> </span>I am going to Save For Web, so I am not going to worry about dropping it to ‘72’ as Save For Web will generally do that for me.<span style=""> </span>Just zooming in a bit, as this was taken in RAW; no sharpening had been applied to the image.<span style=""> </span>Okay.<span style=""> </span>So, I am going to apply some sharpening with my Smart Sharpen.<span style=""> </span>Now as you can see on my web sized images I tend to just use ‘.5’ radius, and the amount will be determined according to the image.<span style=""> </span>On a small amount to a large amount as you can see.<span style=""> </span>It’s quite a huge range there.<span style=""> </span>I think probably about there will be fine.<span style=""> </span>You can click on and off to see before and after.<span style=""> </span>It’s quite a difference around the bike and the man.<span style=""> </span>Click OK.<span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Do Save For Web, it brings you up to here and for DPC for my portfolio images I generally put at 200kb.<span style=""> </span>So Optimize to File Size which you can find behind that triangle, type in your desired file size there and click OK.<span style=""> </span>Then you can just click Save and save wherever you need to.<span style=""> </span>Alright.<span style=""> </span>So that’s the finished product.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">So as you can see there is quite a difference between the beginning and the end of that type of photography.<span style=""> </span>People say, ‘yes, it is all digital art’ but it is a combination of the processing as well as the technology within the camera.<span style=""> </span>Nothing that is done in digital could not have been done in film photography; it’s just a different way of doing it.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">So let’s go and have a look at some of the other type’s images you can achieve through this same style of photography.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Okay, these two particular images were taken in different towns and on different days, but, again different images, different effects.<span style=""> </span>Now, this one here, surprisingly enough was taken on a very cold day, in <st1:place st="on">Central Queensland</st1:place>, but, the water that’s hiding behind the sign that says ‘Danger No Swimming’ is actually a sewerage treatment pond.<span style=""> </span>Behind it you can see the lights overlooking a Little Athletics Field, where children do athletics.<span style=""> </span>And yet to look at it you wouldn’t think so and anybody living in this area has not been able to recognize it as such.<span style=""> </span>So you can turn quite a dull, boring scene as something very pretty.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This particular one over here was done for another challenge on DPC but I didn’t enter this particular one.<span style=""> </span>But I loved the moody effect the clouds gave it with the Sepia feel to it.<span style=""> </span>And really those are basically the colors from the camera.<span style=""> </span>There was a small amount of tweaking done as you can see in a couple of little areas but nothing dramatic.<span style=""> </span>I tended to prefer this effect rather than swapping the channels to give the sky the blue hue.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now, we have a couple of others here.<span style=""> </span>You can see these two.<span style=""> </span>This particular one was just of a grandfather and a child playing in a water channel after recent rain.<span style=""> </span>And by swapping the hues it gives that fantasy effect.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now, this one here was just a matter of playing with the White Balance in Raw Shooter.<span style=""> </span>That is the program I use for my Nikon RAWs.<span style=""> </span>And then playing with the <st1:place st="on"><st1:city st="on">Hue</st1:city></st1:place>.<span style=""> </span>And again, it gives a completely different feel to the image.<span style=""> </span>It’s just a river in our town and yet you can create quite a unique feel to it.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">And then there’s this one.<span style=""> </span>Just basically of my daughter, sitting under a palm tree.<span style=""> </span>She was in a green dress and again I played around with the channels, darkened the edges, tweaked a little bit here and there’s a different effect again.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">So basically, what I am saying is, just like in standard photography, there is not just one direction you can go to with this type of field.<span style=""> </span>It is purely up to your own imagination and individual tweaking to your own settings.<span style=""> </span>Follow your own style and you will find you will achieve more and more than what you thought.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">I hope you enjoyed this tutorial and I hope to be able to produce many more for you.<span style=""> </span>Thanks for your time.</p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-68582272888781804112008-11-19T21:43:00.000-08:002008-12-23T03:58:34.946-08:00Introduction to JavaScript<h2><br /></h2> <p>JavaScript is a programming language that can be included on web pages to make them more interactive. You can use it to check or modify the contents of forms, change images, open new windows and write dynamic page content. You can even use it with CSS to make DHTML (Dynamic HyperText Markup Language). This allows you to make parts of your web pages appear or disappear or move around on the page. JavaScripts only execute on the page(s) that are on your browser window at any set time. When the user stops viewing that page, any scripts that were running on it are immediately stopped. The only exception is a cookie, which can be used by many pages to pass information between them, even after the pages have been closed.</p> <p>Before we go any further, let me say; JavaScript has nothing to do with Java. If we are honest, JavaScript, originally nicknamed LiveWire and then LiveScript when it was created by Netscape, should in fact be called ECMAscript as it was renamed when Netscape passed it to the ECMA for standardisation.</p> <p>JavaScript is a client side, interpreted, object oriented, high level scripting language, while Java is a client side, compiled, object oriented high level language. Now after that mouthful, here's what it means.</p> <dl><dt>Client side </dt><dd>Programs are passed to the computer that the browser is on, and that computer runs them. The alternative is server side, where the program is run on the server and only the results are passed to the computer that the browser is on. Examples of this would be PHP, Perl, ASP, JSP etc. </dd><dt>Interpreted </dt><dd>The program is passed as source code with all the programming language visible. It is then converted into machine code as it is being used. Compiled languages are converted into machine code first then passed around, so you never get to see the original programming language. Java is actually dual half compiled, meaning it is half compiled (to 'byte code') before it is passed, then executed in a virtual machine which converts it to fully compiled code just before use, in order to execute it on the computer's processor. Interpreted languages are generally less fussy about syntax and if you have made mistakes in a part they never use, the mistake usually will not cause you any problems. </dd><dt>Scripting </dt><dt><br /></dt><dd>This is a little harder to define. Scripting languages are often used for performing repetitive tasks. Although they may be complete programming languages, they do not usually go into the depths of complex programs, such as thread and memory management. They may use another program to do the work and simply tell it what to do. They often do not create their own user interfaces, and instead will rely on the other programs to create an interface for them. This is quite accurate for JavaScript. We do not have to tell the browser exactly what to put on the screen for every pixel, we just tell it that we want it to change the document, and it does it. The browser will also take care of the memory management and thread management, leaving JavaScript free to get on with the things it wants to do. </dd><dt>High level </dt><dd>Written in words that are as close to english as possible. The contrast would be with assembly code, where each command can be directly translated into machine code. </dd><dt>Object oriented </dt><dd>See the section on '<a href="objectoriented">object oriented programming</a>' for details. </dd></dl> <h2>How is JavaScript constructed</h2> <p>The basic part of a script is a variable, literal or object. A variable is a word that represents a piece of text, a number, a boolean true or false value or an object. A literal is the actual number or piece of text or boolean value that the variable represents. An object is a collection of variables held together by a parent variable, or a document component.</p> <p>The next most important part of a script is an operator. Operators assign literal values to variables or say what type of tests to perform.</p> <p>The next most important part of a script is a control structure. Control structures say what scripts should be run if a test is satisfied.</p> <p>Functions collect control structures, actions and assignments together and can be told to run those pieces of script as and when necessary.</p> <p>The most obvious parts of a script are the actions it performs. Some of these are done with operators but most are done using methods. Methods are a special kind of function and may do things like submitting forms, writing pages or displaying messages.</p> <p>Events can be used to detect actions, usually created by the user, such as moving or clicking the mouse, pressing a key or resetting a form. When triggered, events can be used to run functions.</p> <p>Lastly and not quite so obvious is referencing. This is about working out what to write to access the contents of objects or even the objects themselves.</p> <p>As an example, think of the following situation. A person clicks a submit button on a form. When they click the button, we want to check if they have filled out their name in a text box and if they have, we want to submit the form. So, we tell the form to detect the submit event. When the event is triggered, we tell it to run the function that holds together the tests and actions. The function contains a control structure that uses a comparison operator to test the text box to see that it is not empty. Of course we have to work out how to reference the text box first. The text box is an object. One of the variables it holds is the text that is written in the text box. The text written in it is a literal. If the text box is not empty, a method is used that submits the form.</p>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-48000852692492002442008-11-19T21:41:00.001-08:002008-12-23T03:58:34.946-08:00BusinessObjects and Oracle9i OLAP<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>JA</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" semihidden="false" unhidewhenused="false" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" unhidewhenused="false" name="toc 1"> <w:lsdexception locked="false" unhidewhenused="false" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" unhidewhenused="false" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" unhidewhenused="false" name="Body Text 2"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"MIAACJ+Arial\,Bold"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:Arial; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:MIAAIP+Arial; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:Arial; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"MIABDB+TimesNewRoman\,Bold"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:"Times New Roman"; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:MIAABD+TimesNewRoman; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:"Times New Roman"; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:MIACHP+CourierNewPSMT; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:"Courier New PSMT"; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"Courier Std"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:"Courier New"; mso-font-charset:0; mso-generic-font-family:modern; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:MIACKJ+CourierNewPS; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:"Courier New PS"; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"MIADAP+TimesNewRoman\,Italic"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-alt:"Times New Roman"; mso-font-charset:0; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} p.MsoBodyText, li.MsoBodyText, div.MsoBodyText {mso-style-priority:99; mso-style-unhide:no; mso-style-link:"Body Text Char"; mso-style-next:Normal; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; mso-layout-grid-align:none; text-autospace:none; font-size:12.0pt; font-family:"MIAACJ+Arial,Bold","sans-serif"; mso-fareast-font-family:SimSun; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} span.BodyTextChar {mso-style-name:"Body Text Char"; mso-style-priority:99; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"Body Text"; mso-ansi-font-size:12.0pt; mso-bidi-font-size:12.0pt; font-family:"MIAACJ+Arial,Bold","sans-serif"; mso-ascii-font-family:"MIAACJ+Arial\,Bold"; mso-hansi-font-family:"MIAACJ+Arial\,Bold";} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:ZH-CN;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-fareast-language:ZH-CN;} </style> <![endif]--><b><span style="font-size: 20pt; font-family: "MIAACJ+Arial,Bold","sans-serif"; color: black;"><o:p> </o:p></span></b> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal; page-break-before: always;"><span style="font-size: 8pt; font-family: "MIAAIP+Arial","sans-serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";">Introduction </span></b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">The release of Oracle9i AW (Analytical Workspace) makes it possible for the Business Objects semantic layer to integrate closely with Oracle OLAP technology. This is because AW allows Oracle OLAP data to be queried using standard SQL. Business Objects’ patented semantic layer, which enables users to create complex SQL queries using visual objects, is already the industry-leading SQL generation technology. As a result, Business Objects users can benefit from the performance and calculation power of Oracle OLAP without leaving the familiar BusinessObjects query-building environment. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">Oracle relational views also make it possible for Business Objects to exploit several trends in the OLAP market place. OLAP is moving away from pure multidimensional databases, and hybrid OLAP/relational solutions are becoming much more common. A Business Objects solution can hold both multidimensional and relational data in a manner that is completely hidden from the end user. Furthermore, the focus is moving away from proprietary OLAP APIs and query languages towards languages that are already industry standards. SQL is a prime example of this—with a Business Objects/Oracle solution you can query your multidimensional data using the most common database query language. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";">Advantages </span></b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">Accessing Oracle cubes through the Business Object semantic layer has three big advantages: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">• Performance. For common-size data sets, OLAP cubes provide better performance because they contain aggregated, pre-computed data that is instantly available to the query tool; <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">• Advanced OLAP calculations (see <u>Using Oracle OLAP functions</u>). The Oracle OLAP cube provides pre-calculated data and also allows users to compute advanced calculations such as growth ratios or trends on the fly; <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">• Transparent drill through from the cube to relational data (see <u>Drilling outside the cube</u>). With this solution, a single universe can encompass a cube and relational tables. This means that ausers can drill from aggregates to details within the same query-building environment. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";">Oracle9i and OLAP cubes </span></b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">Oracle9i AW exposes Oracle OLAP cubes as relational views, which can be queried using standard SQL. Oracle exposes dimensions and rollups in a relational view. For BusinessObjects users to be able to profit from this capability, the BusinessObjects administrator must design a BusinessObjects universe (which transforms a visual query to SQL) around the cube view. The universe must handle rollups correctly, which imposes a non-standard approach to universe design. The next sections discuss the way in which the universe must be designed. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";">Universe design principles </span></b><span style="font-size: 11.5pt; font-family: "MIABDB+TimesNewRoman,Bold","serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: "MIAAIP+Arial","sans-serif";">BusinessObjects and Oracle 9i OLAP 4 of 15 <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal; page-break-before: always;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">In the example used throughout this paper, the view, </span><span style="font-size: 10pt; font-family: "MIACHP+CourierNewPSMT","serif";">OLAPCUBE</span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">, is derived from an Oracle cube using an AW query. The relational view contains Revenue (the measure) and two hierarchies—Time (Year, Quarter, Month) and Geography (Country, Region, City). The revenue in the Revenue column is aggregated according to the level, which means that any SQL statement returning data from the view must filter according to the values in the </span><span style="font-size: 10pt; font-family: "Courier Std";">time_level </span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">and </span><span style="font-size: 10pt; font-family: "Courier Std";">geo_level </span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">columns: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-size: 8pt; font-family: "MIACKJ+CourierNewPS","serif";">YEAR QTR TIME_LEVEL COUNTRY REGION GEO_LEVEL REVENUE </span></b><span style="font-size: 8pt; font-family: "MIACKJ+CourierNewPS","serif";"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: "MIACHP+CourierNewPSMT","serif";">ALL ALL 5000 <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: "MIACHP+CourierNewPSMT","serif";">2002 YEAR ALL 2000 <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: "MIACHP+CourierNewPSMT","serif";">2003 YEAR ALL 3000 <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: "MIACHP+CourierNewPSMT","serif";">2002 Q1 QTR ALL 500 <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: "MIACHP+CourierNewPSMT","serif";">2002 Q2 QTR ALL 500 <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">The problem that needs to be overcome occurs because the cube contains rolled-up data, and BusinessObjects generates SQL per object, whereas to handle rollups it needs to generate per </span><span style="font-size: 11.5pt; font-family: "MIADAP+TimesNewRoman,Italic","serif";">object combination</span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">. For example, if you create a Year object (based on the </span><span style="font-size: 10pt; font-family: "MIACHP+CourierNewPSMT","serif";">year </span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">column in the table) and place it in a query, BusinessObjects builds a </span><span style="font-size: 10pt; font-family: "MIACHP+CourierNewPSMT","serif";">WHERE </span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">clause that restricts time_level to ‘</span><span style="font-size: 10pt; font-family: "MIACHP+CourierNewPSMT","serif";">YEAR</span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">’ (</span><span style="font-size: 10pt; font-family: "Courier Std";">WHERE time_level = ‘YEAR’</span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">). But if you include the Year and Quarter objects, you want BusinessObjects to restrict </span><span style="font-size: 10pt; font-family: "Courier Std";">time_level </span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">to ‘</span><span style="font-size: 10pt; font-family: "MIACHP+CourierNewPSMT","serif";">QUARTER</span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">’ (</span><span style="font-size: 10pt; font-family: "Courier Std";">WHERE time_level = ‘QTR’</span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">). BusinessObjects default behaviour is to create a </span><span style="font-size: 10pt; font-family: "MIACHP+CourierNewPSMT","serif";">WHERE </span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">clause that returns no rows (</span><span style="font-size: 10pt; font-family: "Courier Std";">WHERE time_level = ‘YEAR’ AND time_level = ‘QTR’</span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">). <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.05pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">To solve this you treat the cube view as the fact table in a snowflake schema, and surround it with dimension tables. You are not interested in the data in these dimension tables: they exist solely to force BusinessObjects to generate the correct SQL to filter the </span><span style="font-size: 10pt; font-family: "MIACHP+CourierNewPSMT","serif";">OLAPCUBE </span><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">table. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">The following sections: <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">• describe how to set up the universe; <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">• give examples of the SQL that the universe generates; <o:p></o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">• explain how this SQL relates to the universe design. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 11.5pt; font-family: "MIAABD+TimesNewRoman","serif";">You carry out the following tasks when designing the universe: <o:p></o:p></span></p> <table class="MsoNormalTable" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style="height: 15.6pt;"> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 15.6pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-family: "MIAACJ+Arial,Bold","sans-serif"; color: black;">Task </span></b><span style="font-family: "MIAACJ+Arial,Bold","sans-serif"; color: black;"><o:p></o:p></span></p> </td> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 15.6pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><b><span style="font-family: "MIAACJ+Arial,Bold","sans-serif"; color: black;">Purpose </span></b><span style="font-family: "MIAACJ+Arial,Bold","sans-serif"; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style="height: 25.1pt;"> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 25.1pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">Include the relational view in the universe. <o:p></o:p></span></p> </td> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 25.1pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">You access the OLAP cube data through the relational view. <o:p></o:p></span></p> </td> </tr> <tr style="height: 48.1pt;"> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 48.1pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">Create tables hierarchies that correspond to the dimensional hierarchies in the cube. These hierarchies are build from Designer aliases on the SYS.DUAL table. <o:p></o:p></span></p> </td> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 48.1pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">The dimension tables are used to generate the join conditions that restrict data in the relational view. <o:p></o:p></span></p> </td> </tr> <tr style="height: 36.6pt;"> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 36.6pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">Join the dimension tables hierarchically using regular joins. <o:p></o:p></span></p> </td> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 36.6pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">The joins between the dimension tables are used to generate the join conditions that restrict data in the relational view. <o:p></o:p></span></p> </td> </tr> <tr style="height: 36.65pt;"> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 36.65pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">Join the dimension tables to the relational view using shortcut joins. <o:p></o:p></span></p> </td> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 36.65pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">The shortcut joins are used to generate the join conditions that restrict data in the relational view. <o:p></o:p></span></p> </td> </tr> <tr style="height: 25.1pt;"> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 25.1pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">Create dimension and measure objects <o:p></o:p></span></p> </td> <td style="border: medium none ; padding: 0in 5.4pt; width: 208.45pt; height: 25.1pt;" valign="top" width="278"> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "MIAAIP+Arial","sans-serif"; color: black;">The user builds queries in the Query Panel using these objects <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-82632343975452016762008-11-19T21:37:00.001-08:002008-12-23T03:58:34.946-08:00CSS PropertiesFONT PROPERTIES<br /><br /><br />4P:problems, 4M:Mac only, 4W:Windows only<br /><br />ASSIGNING ALL FONT ATTRIBUTES AT ONCE<br /><br />An example of a typical font definition would be:<br /><br /><br /><br />But since all font attributes can actually be expressed with the font property we could actually write it this way:<br /><br /><br /><br />The above is obviously a shorter way to specify font settings - but in reality it is less useful than one might think. The reason is that you'd be assigning the same font face to all your styles, for example, while you'd want different font weights and sizes for headers and content areas etc.<br /><br /><br /><br />TEXT PROPERTIES<br /><br />Despite the font properties listed above there are some options for defining text properties such as alignments, underlines, etc.<br /><br /><br />4P:problems, 4M:Mac only, 4W:Windows only<br /><br /><br /><br /><br /><br />The official CSS standard provided by W3C also includes properties for word spacing, letter spacing and vertical align, but these aren't supported by today's browsers.<br /><br /><br /><br /><br />COLORS<br /><br />As you can see, the above CSS properties can replace all text formatting that can be done with plain HTML with one exception: the color.<br /><br />The color is not part of the font collection in CSS - rather it has its own definition.<br /><br />If you want to add a color to the text in the above example you'd do it this way:<br /><br /><br /><br />CSS has several options for defining colors of both text and background areas on your pages.<br /><br />These options can entirely replace the color attributes in plain HTML. In addition, you get new options that you just didn't have in plain HTML.<br /><br />For example, in plain HTML, when you wanted to create an area with a specific color you were forced to include a table. With CSS, you can define an area to have a specific color without that area being part of a table.<br /><br />Or even more useful, in plain HTML when working with tables, you had to specify font attributes and colors etc. for each and every table cell. With CSS you can simply refer to a certain class in your tags.<br /><br /><br /><br /><br />COLOR PROPERTIES<br /><br /><br />4P:problems, 4M:Mac only, 4W:Windows only<br /><br /><br /><br />Setting colors<br /><br />Basically you have three color options with CSS:<br /><br />1: Setting the foreground color for contents<br />2: Setting the background color for an area<br />3: Setting a background image to fill out an area<br /><br />In the next section we will list the different properties that let you<br />do that.<br /><br />In plain HTML, colors can either be entered by name (red, blue etc.) or by a hexadecimal color code (for example: #FF9900).<br /><br />With CSS you have these options:<br /><br /><br /><br /><br /><br />Setting background colors<br /><br />Background colors are defined similar to the colors mentioned above. For example you can set the background color of the entire page using the BODY selector:<br /><br /><br /><br />Setting a background image<br />CSS lets you set a background image for both the page and single elements on the page.<br /><br />In addition, CSS offers several positioning methods for background images.<br /><br />You can define the background image for the page like this:<br /><br /><br /><br />You can control the repetition of the image with the background-repeat property.<br /><br /><br /><br /><br /><br />Positioning a background<br />Background positioning is done by entering a value for the left position and top position separated by a space.<br /><br />In this example the image is positioned 75 pixels from the upper left corner of the page:<br /><br /><br /><br />Note: Background positioning is not supported by Netscape 4 browsers.<br /><br /><br /><br />Fixing a background<br />You can fixate an image at a certain position so that it doesn't move when scrolling occurs.<br /><br /><br />Note: Background fixation is not supported by Netscape 4 browsers.<br /><br /><br />Setting multiple background values<br />Rather than defining each background property with its own property you can assign them all with the use of the background property.<br /><br />Look at this example:<br /><br /><br /><br /><br />The CSS font properties allow you to change the font family, boldness, size, and the style of a text.<br />Note: In CSS1 fonts are identified by a font name. If a browser does not support the specified font, it will use a default font.<br />Browser support: IE: Internet Explorer, F: Firefox, N: Netscape.<br />W3C: The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).<br />Property<br />Description<br />Values<br />IE<br />F<br />N<br />W3C<br />font<br />A shorthand property for setting all of the properties for a font in one declaration<br />font-style<br />font-variant<br />font-weight<br />font-size/line-height<br />font-family<br />caption<br />icon<br />menu<br />message-box<br />small-caption<br />status-bar<br />4<br />1<br />4<br />1<br />font-family<br />A prioritized list of font family names and/or generic family names for an element<br />family-name<br />generic-family<br />3<br />1<br />4<br />1<br />font-size<br />Sets the size of a font<br />xx-small<br />x-small<br />small<br />medium<br />large<br />x-large<br />xx-large<br />smaller<br />larger<br />length<br />%<br />3<br />1<br />4<br />1<br />font-size-adjust<br />Specifies an aspect value for an element that will preserve the x-height of the first-choice font<br />none<br />number<br />-<br />-<br />-<br />2<br />font-stretch<br />Condenses or expands the current font-family<br />normal<br />wider<br />narrower<br />ultra-condensed<br />extra-condensed<br />condensed<br />semi-condensed<br />semi-expanded<br />expanded<br />extra-expanded<br />ultra-expanded<br />-<br />-<br />-<br />2<br />font-style<br />Sets the style of the font<br />normal<br />italic<br />oblique<br />4<br />1<br />4<br />1<br />font-variant<br />Displays text in a small-caps font or a normal font<br />normal<br />small-caps<br />4<br />1<br />6<br />1<br />font-weight<br />Sets the weight of a font<br />normal<br />bold<br />bolder<br />lighter<br />100<br />200<br />300<br />400<br />500<br />600<br />700<br />800<br />900<br />4<br />1<br />4<br />1Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-8553308360367166330.post-16129761074582399032008-09-06T06:58:00.000-07:002008-12-23T03:58:34.946-08:00CSS TutorialCSS stands for Cascading Style Sheets. It is a way to divide the content from the layout on web pages.
<br />
<br />How it works:
<br />
<br />A style is a definition of fonts, colors, etc.
<br />
<br />Each style has a unique name: a selector.
<br />
<br />The selectors and their styles are defined in one place.
<br />
<br />In your HTML contents you simply refer to the selectors whenever you want to activate a certain style.
<br />
<br />For example:
<br />
<br />Instead of defining fonts and colors each time you start a new table cell, you can define a style and then, simply refer to that style in your table cells.
<br />
<br />Compare the following examples of a simple table:
<br />
<br />Classic HTML
<br />
<br />
<br />
<br />With CSS (assuming that a selector called subtext is defined)
<br />
<br />
<br />While CSS lets you separate the layout from the content, it also lets you define the layout much more powerfully than you could with classic HTML.
<br />
<br />
<br />With CSS, you will be able to:
<br />
<br />- define the look of your pages in one place rather than repeating yourself over and over again throughout your site. (Ever get tired of defining colors and fonts each time you start a new cell in a table? Those days are over with CSS!)
<br />
<br />- easily change the look of your pages even after they're created. Since the styles are defined in one place you can change the look of the entire site at once. (Ever get tired of replacing tags throughout your site when you want to change the look of a certain element? Those days are over with CSS!)
<br />
<br />- define font sizes and similar attributes with the same accuracy as you have with a word processor - not being limited to just the seven different font sizes defined in HTML.
<br />
<br />- position the content of your pages with pixel precision.
<br />
<br />- redefine entire HTML tags. Say for example, if you wanted the bold tag to be red using a special font - this can be done easily with CSS.
<br />
<br />- define customized styles for links - such as getting rid of the underline.
<br />
<br />- define layers that can be positioned on top of each other (often used for menus that pop up).
<br />
<br />Your pages will load faster, since they aren't filled with tags that define the look. The style definitions are kept in a single CSS document that is only loaded once when a visitor enters your site.
<br />
<br />
<br />The one disadvantage is:
<br />
<br />- these will only work on version 4 browsers or newer. However, more than 95% of all browsers live up to that.
<br />
<br />
<br />Syntax:
<br />The CSS syntax is made up of three parts: a selector, a property and a value:
<br />selector {property: value}
<br />The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to change, and each property can take a value. The property and value are separated by a colon and surrounded by curly braces:
<br />body {color: black}
<br />If the value is multiple words, put quotes around the value:
<br />p {font-family: "sans serif"}
<br />Note: If you wish to specify more than one property, you must separate each property with a semi-colon. The example below shows how to define a center aligned paragraph, with a red text color:
<br />p {text-align:center;color:red}
<br />To make the style definitions more readable, you can describe one property on each line, like this:
<br />p
<br /> {
<br /> text-align: center;
<br /> color: black;
<br /> font-family: arial
<br /> }
<br />
<br />
<br />Grouping:
<br />You can group selectors. Separate each selector with a comma. In the example below we have grouped all the header elements. All header elements will be green:
<br />h1,h2,h3,h4,h5,h6
<br /> {
<br /> color: green
<br /> }
<br />
<br />
<br />Class Selector:
<br />With the class selector you can define different styles for the same type of HTML element. Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one center-aligned paragraph. Here is how you can do it with styles:
<br />p.right {text-align: right}
<br /> p.center {text-align: center}
<br />You have to use the class attribute in your HTML document:
<br /><p class="right">
<br /> This paragraph will be right-aligned.
<br /> </p>This paragraph will be center-aligned.
<br />
<br />Note: Only one class attribute can be specified per HTML element! The example below is wrong:
<br /><p class="right">
<br /> This is a paragraph.
<br /> </p>
<br />You can also omit the tag name in the selector to define a style that will be used by all HTML elements that have a certain class. In the example below, all HTML elements with class="center" will be center-aligned:
<br />.center {text-align: center}
<br />In the code below both the h1 element and the p element have class="center". This means that both elements will follow the rules in the ".center" selector:
<br /><h1 class="center">This heading will be center-aligned
<br /> </h1>This paragraph will also be center-aligned.
<br />
<br />Do NOT start a class name with a number! It will not work in Mozilla/Firefox.
<br />
<br />
<br />id Selector:
<br />With the id selector you can define the same style for different HTML elements.
<br />The style rule below will match any element that has an id attribute with a value of "green":
<br />#green {color: green}
<br />The rule above will match both the h1 and the p element:
<br /><h1 id="green">Some text</h1>Some text
<br />The style rule below will match a p element that has an id with a value of "para1":
<br />p#para1
<br /> {
<br /> text-align: center;
<br /> color: red
<br /> }
<br />The style rule below will match any p element that has an id attribute with a value of "green":
<br />p#green {color: green}
<br />The rule above will not match an h1 element:
<br /><h1 id="green">Some text</h1>
<br />Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.
<br />
<br />CSS Comments:
<br />You can insert comments into CSS to explain your code, which can help you when you edit the source code at a later date. A comment will be ignored by the browser. A CSS comment begins with "/*", and ends with "*/", like this:
<br />/* This is a comment */
<br /> p
<br /> {
<br /> text-align: center;
<br /> /* This is another comment */
<br /> color: black;
<br /> font-family: arial
<br /> }
<br />
<br />
<br />Selectors are the names that you give to your different styles.
<br />
<br />In the style definition you define how each selector should work (font, color etc.).
<br />
<br />Then, in the body of your pages, you refer to these selectors to activate the styles.
<br />
<br />For example:
<br />
<br />
<br />
<br />In this case B.headline is the selector.
<br />
<br />The above example would result in this output:
<br />
<br />
<br />There are three types of selectors:
<br />
<br />
<br />
<br />The general syntax for an HTML selector is:
<br />
<br />HTML selectors {Property:Value;}
<br />
<br />For example:
<br />
<br />HTML selectors are used when you want to redefine the general look for an entire HTML tag.
<br />
<br />
<br />The general syntax for a Class selector is:
<br />
<br />.ClassSelector {Property:Value;}
<br />
<br />For example:
<br />
<br />Class selectors are used when you want to define a style that does not redefine an HTML tag entirely.
<br />
<br />When referring to a Class selector you simply add the class to an HTML tag like in the above example (class="headline").
<br />
<br />
<br />
<br />
<br />SPAN and DIV as carriers
<br />
<br />Two tags are particularly useful in combination with class selectors: <span> and <div>.
<br />
<br />Both are "dummy" tags that don't do anything in themselves. Therefore, they are excellent for carrying CSS styles.
<br />
<br />
<br /><div> has a particular importance for layers. Since layers are separate blocks of information. <div> is an obvious choice when defining layers on your pages.
<br />
<br />
<br />The general syntax for an ID selector is:
<br />
<br />#IDSelector {Property:Value;}
<br />
<br />For example:
<br />
<br />ID selectors are used when you want to define a style relating to an object with a unique ID.
<br />
<br />This selector is most widely used with layers (as in the above example), since layers are always defined with a unique ID.
<br />
<br />
<br />Grouped Selector
<br />
<br />Most often selectors will share some of the same styles, for example, being based on the same font.
<br />In these cases, rather than defining the font for each and every selector, one by one, you can group them, and thus assign the font to all the selectors at once.
<br />
<br />Look at this example, made without grouping:
<br />
<br />As you can see, the only style that varies is the font-size.
<br />In the next example we have grouped the selectors, and defined the common styles at once.
<br />
<br />
<br />Less to type, easier to change and guaranteed to be the same for all styles.
<br />
<br />
<br />CSS can be added to your pages at 3 different levels.
<br />
<br />It is possible to create CSS styles that only work for the single tag it is defined for.
<br />
<br />Single tag CSS is used when the style is used in a single place on the entire site.
<br />
<br />Usually a certain style appears more than once on your pages, and thus you should use the second technique: adding styles that are defined once for the entire page.
<br />
<br />If, however, that certain style is used on more than a single page, you should use the third - and most powerful - technique described: adding styles that are defined once for the entire site.
<br />
<br />The following Sections will explain each of these techniques....
<br />
<br />Single Tags / Inline Style Sheet
<br />
<br />CSS can be defined for single tags by simply adding style="styledefinition:styleattribute;" to the tags.
<br />
<br />Look at this example:
<br />
<br />
<br />You should limit your use of single tag CSS.
<br />
<br />If you define your styles for each and every tag they're used on, you will lose much of the power associated with CSS.
<br />
<br />For example, you will have to define the style over and over again whenever it's used, rather than just defining it once and then referring to that one definition whenever it's used.
<br />
<br />Furthermore, if you wanted to change a certain style, you'd have to change it all over in your document, rather than in one place.
<br />
<br />
<br />Single Pages / Internal Style Sheet
<br />
<br />CSS can be defined for entire pages by simply adding a style definition to the head section.
<br />
<br />Look at this example:
<br />
<br />
<br />
<br />In the above example, although we used the sublines style twice, we only had to define it once: in the section.
<br />
<br />By defining styles for entire pages, you will gain the freedom to easily change the styles even after the entire page has been made.
<br />
<br />This is an obvious advantage for you as a designer. But the advantage is on the visitors side as well.
<br />
<br />Since the styles are only defined in one place, the page size will be smaller, and thus faster to load.
<br />
<br />There is a way to emphasize these advantages even more: using external CSS styles that work for entire sites.
<br />
<br />
<br />Entire Sites / External Style Sheet
<br />
<br />CSS can be defined for entire sites by simply writing the CSS definitions in a plain text file that is referred to from each of the pages in the site.
<br />
<br />Rather than writing the entire CSS definition on each page, as in the previous examples, you can write it to a text file that is only loaded on the first page that a visitor sees at your site.
<br />When the visitor jumps to other pages, the CSS text file will be cached and thus doesn't have to be transferred via the internet for subsequent pages.
<br />
<br />This means that your pages will load faster while at the same time you will have extreme flexibility to change the style for your entire site even after it has been made.
<br />
<br />Look at this example:
<br />
<br />File: example.html
<br />
<br />
<br />
<br />The above example is the exact same as we used for CSS defined for entire pages, with one important exception:
<br />There is no style definition on the page. Instead we added a reference to an external style sheet:
<br />
<br />
<br />
<br />This means that the browser will look for a file called whatever.css and insert it at the place where the reference was found in the
<br />html document.
<br />
<br />So in order to complete our example we need to have a file called whatever.css that looks like this:
<br />
<br />File: whatever.css
<br />
<br />
<br />
<br />Now if you just add the line <link rel="stylesheet" href="whatever.css" type="text/css"> to the of all your pages, then the one style definition will be in effect for your entire site.
<br />
<br />Imagine the power and flexibility this gives you to make changes to the layout even after the site is done.
<br />But also realize how using an external style sheet will guarantee that all pages are following the same thread.
<br />There won't be single pages that you forgot to update when you decided to change the style for your headers.
<br />
<br />
<br />
<br />
<br />At this point of the tutorial you should know:
<br />
<br />
<br />
<br />All we need now is a walkthrough of the various style attributes that can be assigned.
<br />
<br />We will divide them into three categories:
<br />
<br />
<br />CSS has several options for defining the styles of text.
<br />
<br />These options can entirely replace the <span> tag, but there's even more. CSS allows you to define these styles much more powerfully than you could ever do with plain HTML.
<br />
<br />
<br /></span></div></div></div></span>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0