Form Handling. Server-side Web Development and Programming. Form Handling. Server Page Model. Form data appended to request string



Similar documents
An introduction to web programming with Java

Java Server Pages combined with servlets in action. Generals. Java Servlets

Getting Started with Mal s. Adding Buy Now buttons to your web page

7 Web Databases. Access to Web Databases: Servlets, Applets. Java Server Pages PHP, PEAR. Languages: Java, PHP, Python,...

Setup and Administration for ISVs

Form Validation. Server-side Web Development and Programming. What to Validate. Error Prevention. Lecture 7: Input Validation and Error Handling

SSC - Web development Model-View-Controller for Java web application development

Introduction to Web Technologies

Handling the Client Request: Form Data

Internet Technologies

Specialized Programme on Web Application Development using Open Source Tools

2. Follow the installation directions and install the server on ccc

1.264 Lecture 19 Web database: Forms and controls

JavaServer Pages Fundamentals

Modeling Presentation Layers of Web Applications for Testing

Database System Concepts

Pure server-side Web Applications with Java, JSP. Application Servers: the Essential Tool of Server-Side Programming. Install and Check Tomcat

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Building Web Applications, Servlets, JSP and JDBC

How To Create A Website In Vablet (For Web) With Html And Html (For Html) On A Pc Or Mac) With A Web Browser (For Mac) On Your Computer Or Ipad Or Ipa (For Pc Or Ip

Specialized Programme on Web Application Development using Open Source Tools

Creating Java EE Applications and Servlets with IntelliJ IDEA

<head> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <title>my First PHP Lab</title> </head>

Short notes on webpage programming languages

Web Container Components Servlet JSP Tag Libraries

CREATING WEB FORMS WEB and FORMS FRAMES AND

J2EE Web Development. Agenda. Application servers. What is J2EE? Main component types Application Scenarios J2EE APIs and Services.

Welcome to CSE 330 Crea0ve Progamming and Rapid Prototyping. Course Informa0on

Grails 1.1. Web Application. Development. Reclaiming Productivity for Faster. Java Web Development. Jon Dickinson PUBLISHING J MUMBAI BIRMINGHAM

Java Server Pages and Java Beans

AD Phonebook 2.2. Installation and configuration. Dovestones Software

Introduction to the. Barracuda Embedded Web-Server

Server-Side Web Development JSP. Today. Web Servers. Static HTML Directives. Actions Comments Tag Libraries Implicit Objects. Apache.

Microsoft Advertising adcenter Campaign Analytics Getting Started Guide

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Glassfish, JAVA EE, Servlets, JSP, EJB

How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post

Introduction to web development using XHTML and CSS. Lars Larsson. Today. Course introduction and information XHTML. CSS crash course.

Virtual Credit Card Processing System

HTML Redirect Integration Guide

Absorb Single Sign-On (SSO) V3.0

Web Application Development

CS108, Stanford Handout #33 Young. HW5 Web

Webserver TiXML Manual WEB-EN. Tixi Alarm Modem Tixi.Com GmbH, Berlin

Google AdWords TM Conversion Tracking Guide

Java Servlet and JSP Programming. Structure and Deployment China Jiliang University

Webapps Vulnerability Report

InternetVista Web scenario documentation

Lecture 9. Semantic Analysis Scoping and Symbol Table

JSP Java Server Pages

SmartPad4i Solution Guide

Create dynamic sites with PHP & MySQL

WESTERNACHER OUTLOOK -MANAGER OPERATING MANUAL

A Simple Shopping Cart using CGI

Customer Profile Report for ABC Hosting Ltd

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

Recommended readings. Lecture 11 - Securing Web. Applications. Security. Declarative Security

In this chapter, we lay the foundation for all our further discussions. We start

PROCESSES LOADER 9.0 SETTING. Requirements and Assumptions: I. Requirements for the batch process:

JBoss Portlet Container. User Guide. Release 2.0

ISI ACADEMY Web applications Programming Diploma using PHP& MySQL

Developer Guide To The. Virtual Merchant

Developing WCM based WebSphere Portal application using IBM Rational Application Developer

Crystal Reports for Borland JBuilder

Download: Server-side technologies. WAMP (Windows), MAMP (Mac),

PHP and XML. Brian J. Stafford, Mark McIntyre and Fraser Gallop

NGASI AppServer Manager SaaS/ASP Hosting Automation for Cloud Computing Administrator and User Guide

Web Application Programmer's Guide

Contents. Downloading the Data Files Centering Page Elements... 6

HTML Lesson 7. Your assignment:

Real SQL Programming 1

lectures/6/src/blink.html blink.html David J. Malan Computer Science S-75 Harvard Summer School 10. <!DOCTYPE html> 12. </script> 16.

IUCLID 5 Guidance and Support

IP Phone Service Administration and Subscription

CREATING AND PROCESSING HTML FORMS

Tutorial: Building a Web Application with Struts

Esigate Module Documentation

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Tagging Guide: Website and Implementation. Contents

CS506 Web Design and Development Solved Online Quiz No. 01

HTML Forms and CONTROLS

Web Application Architecture (based J2EE 1.4 Tutorial)

Specify the location of an HTML control stored in the application repository. See Using the XPath search method, page 2.

Checkout FAQs. What are my Pay Now Button Options? These options define the end user experience of your buyers during checkout.

Japan Communication India Skill Development Center

CS346: Database Programming.

Ligero Content Delivery Server. Documentum Content Integration with

Introduction to Web Development

Server-side: PHP and MySQL (continued)

Python and MongoDB. Why?

HTTPParameter Pollution. ChrysostomosDaniel

OCS Training Workshop LAB13. Ethernet FTP and HTTP servers

ANZ egate Virtual Payment Client

The Web Web page Links 16-3

Transcription:

Form Handling Server-side Web Development and Programming Lecture 3: Introduction to Java Server Pages Form data appended to request string <FORM NAME="purchaseform" METHOD=GET ACTION= http://localhost:8080/widgetsite/receipt.jsp > Quantity: <INPUT TYPE="text" SIZE="8" NAME="quantity" /> <BR /><BR /> <INPUT TYPE="submit" VALUE="SUBMIT"> </FORM> Generates the request: 2 Form Handling Goal: Extract values of parameters from the request Generate appropriate response page based on parameter values Take other appropriate action based on request Add to shopping cart Modify or query database 3 Server Page Model Html document with executable code interspersed When page requested: Code executed Html generated and inserted in its place Final all html document sent back as response request for somepage.jsp Tomcat server resulting html page somepage.jsp html html Java html Java html Java html html 4

Java Server Pages JSP Syntax <HTML> <HEAD><TITLE>Widget Purchase Page </TITLE></HEAD> <BODY> <P> Thank you for your order of <%= request.getparameter( quantity ) %> widgets! </P> </BODY> </HTML> Basic tag form: <% %> Simplest form: <%= some Java expression %> Tomcat evaluates expression to get value Insertsthat value in place of expression in generated html page 5 6 Simple example: JSP Simple Example Two plus two is <%= 2 + 2 %>. Two plus two is 4. Java Server Page 2 + 2 evaluated to value of 4 Resulting html Page 7 JSP Syntax Basic tag form: <% %> Executes code inside brackets without generating html Set variables later used to generate html later Store/access values in session/databases <% int sum = 2 + 2; %> Two plus two is <%= sum %>. 8

JSP Syntax JSP Scoping <% int sum = 2 + 2; %> Two plus two is <%= sum %>. Two plus two is 4. No html here Stores value of 4 in sum variable Value of 4 in sum used in this JSP 9 Variable declared in a block of JSP on a page May be accessed by any other JSP on same page No access to variable from any other page (purpose of sessions) <% int sum = 2 + 2; %> Two plus two is <%= sum %>. 10 Html Forms The FORM tag <form action= url of response page method= get or post > </form> Method by which form data is passed Relative url if response page is part of same webapp 11 Get method Default method Get vs. Post Method Appends form data to end of URL Faster No fixed limit to length of form data passed Allows bookmarking of pages Post method Must specify in FORM Form data not visible (some security against shoulder surfing, but still need encryption for total security) Parameters limited to ~4k of data Prevents bookmarking (good if part of session that user should no be able to enter in middle) 12

Simple Form Elements Form Element Example TEXT tag <input type= text name= elementname /> Necessary for value to be sent to server SUBMIT tag <input type= submit value= buttonlabel /> 13 <form action="orderreply.jsp" method="get"> <table cellspacing="5"> <tr> <td align="right">number to purchase:</td> <td><input type="text" name="quantity"></td> </tr><tr> <td align="right">your name:</td> <td> <input type="text" name="customername"></td> </tr><tr> <td align="right">your email:</td> <td> <input type="text" name="customeremail"></td> </tr><tr> <td></td> <td><input type="submit" value="place Order"></td> </tr> </table> <form> 14 Form Element Example Form Parameter Passing 15 Parameter string passed: quantity=137&customername=john+sullins& customeremail=john@cis.ysu.edu 16

Handling Form Data request object in JSP Java object created from request string Contains request data and methods to easily access that data Accessed by JSP code Data from form Other data about request request methods to access data about the request Code in JSP Handling Form Data Most useful method: String request.getparameter(string) Returns the corresponding value passed to the server Takes name of form element as parameter Example: String name = request.getparameter("customername"); sets the value of name to John Sullins 17 18 Example JSP Acquiring Form Data <% String name = request.getparameter("customername"); String email = request.getparameter("customeremail"); String quantity = request.getparameter("quantity"); %> <h2>order Confirmation</h2> Thank you for your order of <%= quantity %> widgets, <%= name %>. You will shortly receive an email confirmation at <%= email %>. 19 Statements to get and store form data: <% String name = request.getparameter("customername"); String email = request.getparameter("customeremail"); String quantity = request.getparameter("quantity"); %> name email quantity John Sullins john@cis.ysu.edu 137 20

Displaying Values in Response Thank you for your order of <%= quantity %> widgets, <%= name %>. John Sullins 137 You will shortly recieve an email confirmation at <%= email %>. john@cis.ysu.edu Commenting JSP Files Crucial to future maintenance of site Inside of JSP code (between <% and %>): // comment /* comment */ Outside of JSP code (that is, in html) <!-- comment --> 21 22 Importing Library Classes Much of Java classes in separate libraries Must be imported to be used in JSP Syntax: <%@ page import= list of Java classes %> Example: <%@ page import= java.util.date, java.io.* %> All classes in the io library Date class in the util library 23