JSP Tutorial

2y ago
53 Views
2 Downloads
1.25 MB
48 Pages
Last View : 17d ago
Last Download : 3m ago
Upload by : Sasha Niles
Transcription

JSPAbout the TutorialJava Server Pages (JSP) is a server-side programming technology that enables thecreation of dynamic, platform-independent method for building Web-based applications.JSP have access to the entire family of Java APIs, including the JDBC API to accessenterprise databases. This tutorial will teach you how to use Java Server Pages to developyour web applications in simple and easy steps.AudienceThis tutorial has been prepared for the beginners to help them understand basicfunctionality of Java Server Pages (JSP) to develop your web applications. After completingthis tutorial you will find yourself at a moderate level of expertise in using JSP from whereyou can take yourself to next levels.PrerequisitesWe assume you have little knowledge of how web applications work over HTTP, what isweb server and what is web browsers. It will be great if you have some knowledge of webapplication development using any programming language.Copyright & Disclaimer Copyright 2017 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I)Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republishany contents or a part of contents of this e-book in any manner without written consentof the publisher.We strive to update the contents of our website and tutorials as timely and as precisely aspossible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of ourwebsite or its contents including this tutorial. If you discover any errors on our website orin this tutorial, please notify us at contact@tutorialspoint.comi

JSPTable of ContentsAbout the Tutorial . iAudience . iPrerequisites . iCopyright & Disclaimer. iTable of Contents . iiJSP OVERVIEW . 1What is JavaServer Pages? . 1Why Use JSP? . 1Advantages of JSP . 2What is Next? . 2JSP — ENVIRONMENT SETUP . 3Setting up Java Development Kit . 3Setting up Web Server: Tomcat . 3Setting up CLASSPATH . 6JSP ARCHITECTURE . 7JSP Processing . 7JSP LIFECYCLE . 9Paths Followed By JSP . 9JSP SYNTAX . 12Elements of JSP . 12JSP DIRECTIVES . 23The page Directive . 23JSP - The page Directive. 25ii

JSPThe include Directive . 29JSP - Include Directive . 30The taglib Directive . 32JSP - The taglib Directive . 32JSP ACTIONS . 34Common Attributes. 34The jsp:include Action . 35The jsp:useBean Action . 36The jsp:setProperty Action . 37The jsp:getProperty Action . 38The jsp:forward Action . 40The jsp:plugin Action . 41The jsp:text Action . 42JSP IMPLICIT OBJECTS . 44JSP CLIENT REQUEST. 48JSP SERVER RESPONSE . 54JSP HTTP STATUS CODES . 60Methods to Set HTTP Status Code . 64HTTP Status Code Example . 64JSP FORM PROCESSING . 66The Methods in Form Processing . 66Reading Form Data using JSP . 66GET Method Example Using URL . 67GET Method Example Using Form . 68POST Method Example Using Form . 68iii

JSPPassing Checkbox Data to JSP Program . 70Reading All Form Parameters . 72JSP FILTERS . 74Servlet Filter Methods . 74JSP Filter Example . 75JSP Filter Mapping in Web.xml . 76Using Multiple Filters . 77Filters Application Order . 78JSP — COOKIES HANDLING . 79The Anatomy of a Cookie . 79Servlet Cookies Methods . 80Setting Cookies with JSP . 81Reading Cookies with JSP . 83Delete Cookies with JSP . 85JSP — SESSION TRACKING . 87Maintaining Session Between Web Client And Server . 87The session Object . 88Deleting Session Data . 92JSP — FILE UPLOADING . 94Creating a File Upload Form . 94Writing Backend JSP Script . 95JSP — HANDLING DATE . 99Getting Current Date & Time . 100Date Comparison . 101Date Formatting using SimpleDateFormat . 101iv

JSPSimple DateFormat Format Codes . 102JSP PAGE REDIRECTING . 104JSP HITS COUNTER . 106Hit Counter Resets . 107JSP AUTO REFRESH . 108Auto Page Refresh Example . 108JSP SENDING EMAIL . 110Send a Simple Email . 110Send an HTML Email . 112Send Attachment in Email . 114User Authentication Part. 117Using Forms to Send Email . 117JSP STANDARD TAG LIBRARY (JSTL) TUTORIAL . 119Install JSTL Library . 119Classification of The JSTL Tags . 119Core Tags. 119JSTL Core c:out Tag . 121JSTL Core c:set Tag . 121JSTL Core c:remove Tag . 122JSTL Core c:catch Tag . 124JSTL Core c:if Tag . 125JSTL Core c:choose , c:when , c:otherwise Tag . 125JSTL Core c:choose , c:when , c:otherwise Tag . 127JSTL Core c:choose , c:when , c:otherwise Tag . 128JSTL Core c:import Tag . 129v

JSPJSTL Core c:forEach , c:forTokens Tag . 130JSTL Core c:forEach , c:forTokens Tag . 132JSTL Core c:param Tag . 134JSTL Core c:redirect Tag . 135JSTL Core c:url Tag . 136Formatting Tags . 137JSTL Core fmt:formatNumber Tag . 138JSTL Core fmt:parseNumber Tag . 141JSTL Core fmt:formatDate Tag . 143JSTL Core fmt:parseDate Tag . 146JSTL Core fmt:bundle Tag . 148JSTL Core fmt:setLocale Tag . 151JSTL Core fmt:setBundle Tag . 153JSTL Core fmt:timeZone Tag . 154JSTL Core fmt:setTimeZone Tag . 156JSTL Core fmt:message Tag . 157JSTL Core fmt:requestEncoding Tag . 159SQL tags . 160JSTL SQL sql:setDataSource Tag . 161JSTL SQL sql:query Tag . 163Create Data Records . 164JSTL SQL sql:update Tag . 166Create Data Records . 167JSTL SQL sql:param Tag. 169Create Data Records . 171JSTL SQL sql:dateParam Tag . 173Create Data Records . 174vi

JSPJSTL SQL sql:transaction Tag . 176Create Data Records . 178XML Tags . 180JSTL XML x:out Tag . 182JSTL XML x:parse Tag . 183JSTL XML x:set Tag . 185JSTL XML x:if Tag . 187JSTL XML x:forEach Tag . 188JSTL XML x:choose , x:when , x:otherwise Tags . 190JSTL XML x:choose , x:when , x:otherwise Tags . 192JSTL XML x:choose , x:when , x:otherwise Tags . 194JSTL XML x:transform Tag . 196JSTL XML x:param Tag . 199JSTL Functions . 201JSTL fn:contains() Function . 203JSTL fn:containsIgnoreCase() Function . 204JSTL fn:endsWith() Function . 205JSTL fn:escapeXml() Function . 206JSTL fn:indexOf() Function . 207JSTL fn:join() Function . 208JSTL fn:length() Function . 209JSTL fn:replace() Function. 210JSTL fn:split() Function . 210JSTL fn:startsWith() Function. 211JSTL fn:substring() Function . 212JSTL fn:substringAfter() Function . 213JSTL fn:substringBefore() Function . 214vii

JSPJSTL fn:toLowerCase() Function . 215JSTL fn:toUpperCase() Function . 216JSTL fn:trim() Function . 216JSP DATABASE ACCESS . 218Create Table . 218Create Data Records . 219SELECT Operation . 219INSERT Operation . 221DELETE Operation . 222UPDATE Operation . 224JSP XML DATA . 226Sending XML from a JSP . 226Processing XML in JSP . 226Formatting XML with JSP. 228JSP JAVABEANS . 231JavaBeans Properties . 231JavaBeans Example . 231Accessing JavaBeans . 232Accessing JavaBeans Properties . 233JSP CUSTOM TAGS . 235Create "Hello" Tag. 235Accessing the Tag Body . 236Custom Tag Attributes . 238viii

JSPJSP — EXPRESSION LANGUAGE (EL). 242Simple Syntax . 242Basic Operators in EL . 243Functions in JSP EL . 244JSP EL Implicit Objects . 245The pageContext Object . 245The Scope Objects . 246The param and paramValues Objects . 246header and headerValues Objects . 247JSP EXCEPTION HANDLING . 248Using Exception Object . 248Using JSTL Tags for Error Page . 250Using Try.Catch Block . 252JSP — DEBUGGING . 253Using System.out.println() . 253Using the JDB Logger . 254Debugging Tools . 256Using JDB Debugger . 257Using Comments . 257Client and Server Headers . 257JSP — SECURITY. 258Role Based Authentication . 258Form Based Authentication .

JSP i About the Tutorial Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. JSP have access to the entire family of Java APIs, including the JDBC API to access enterprise databases.

Related Documents:

JSF has nothing to do with JSP per se. JSF works with JSP through a JSP tag library bridge. However, the life cycle of JSF is very different from the life cycle of JSP. Facelets fits JSF much better than JSP because Facelets was designed with JSF in mind, whereas integrating JSF and JSP has

1 Difference between Servlets and JSP 2 Basic JSP Architecture 3 Life Cycle of JSP 4 JSP Tags and Expressions 5 Scriptlets, Declarations, Expressions & Directives 6 Action Tags and Implicit Objects 7 JSP to Servlets & Servlets to JSP . 11 St

Podemos editar más de una clase o página JSP en la ventana de edición, cada una en su propio panel, como se muestra en la figura 4.13 en la que tenemos en la ventana de edición de NetBeans dos páginas JSP: index.jsp y control.jsp. Las pestañas en la parte superior nos permiten seleccionar la clase o página JSP que se desea editar. Figura .

JSP page is a simple web page which contains the JSP elements and template text. The template text can be scripting code such as Html, Xml or a simple plain text. Various Jsp elements can be action tags, custom tags, JSTL library elements. These JSP elements are responsible for generating dynamic contents. Pure Servlet

The Morgan Kaufmann Practical Guides Series Series Editor, Michael J. Donahoo JSTL: Practical Guide for JSP Programmers Sue Spielman JSP: Practical Guide for Java Programmers . 2.2 Using the Book Examples 24 2.3 JSP Scopes 25 2.4 JSTL Scoped Variables 27 2.4.1

suport (Beginning JSP, JSF and Tomcat) Capitolul 1 -Introducing JSP and Tomcat notiuni necesare SO HTTP Tehnologii Web . JavaServer Pages (JSP) JavaServer Pages (JSP) este o tehnologie care ajută la crearea paginilor generate dinamic prin conversia fișierelor

the user clicks a contact in the contact listing. (This tutorial covers it when discussing the JSP.) As in Part 1, addStatusMessageadds status messages so you can display them with h:messages . Contacts view The JSP page uses a h:dataTable (a component not covered in Part 1), as shown in Listing 2: Listing 2. contacts.jsp

12 dimana manajer menggeser laba tahun berjalan dengan kemungkinan laba di masa mendatang. Sedangkan menurut Kustono (2009), perataan laba dapat didefinisi sebagai suatu cara yang dipakai manajemen untuk mengurangi variabilitas laba di antara deretan jumlah laba yang timbul karena adanya perbedaan antara jumlah laba yang seharusnya dilaporkan dengan laba yang diharapkan (laba normal). 2.2.2 .