DT211/3 Internet Application Development JSP: Processing User input.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
DT228/3 Web Development WWW and Client server model.
Languages for Dynamic Web Documents
DT211/3 Internet Application Development Active Server Pages & IIS Web server.
Server-Side vs. Client-Side Scripting Languages
DT228/3 Web Development multi page applications/ sharing data.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: HTML and Client-side code.
DT211/3 Internet Application Development
Dynamic Web Pages. Web Programming  All our web pages so far have been static pages. 1. We create a web page 2. We upload it to the web server 3. People.
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
Web Page Behavior IS 373—Web Standards Todd Will.
DT228/3 Web Development JSP: Directives and Scripting elements.
Contrast with JavaScript HTML Formsto invoke Java Server Pages Structure of Forms Query strings Java Server Pages Sent From Browser To Serverfor JSP.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
UNIT-V The MVC architecture and Struts Framework.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
JavaScript Form Validation
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Author: DoanNX Version 2.0/Time: 30’. The ways to solve it There are 2 main ways:  Client-side: Using JavaScript (now one very good option is JQuery).
Validation Controls. Validation Server Controls These are a special type of Web server control. They significantly reduce some of the work involved in.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Server-side Scripting Powering the webs favourite services.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
1 VU. 2 CS101 Introduction to Computing Lecture 15 More on Interactive Forms (Web Development Lecture 5)
Introduction to JavaScript + More on Interactive Forms.
JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
JSP Java Server Pages Softsmith Infotech.
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
HTML Forms.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Creating PHPs to Insert, Update, and Delete Data CS 320.
JavaScript - A Web Script Language Fred Durao
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
CSCI 6962: Server-side Design and Programming Java Server Faces Scoping and Session Handling.
Introduction to JavaScript CS101 Introduction to Computing.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
Page 1 Controller Action2.java Struts- config. xml Mappings Business Logic Layer Data Layer View Layer Business Bean 1 Jsp Engine Jsp 1 Action3.java Action4.java.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Display Page (HTML/CSS)
DT228/3 Web Development JSP: Actions elements and JSTL.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
JSP: Actions elements and JSTL
PHP / MySQL Introduction
JavaScript Form Validation
Presentation transcript:

DT211/3 Internet Application Development JSP: Processing User input

Introduction Directive elements Action elements and JSTL Scripting elements Java Beans So far, have looked at these Will look at how to process user in put from forms using JSP using these techniques

User input Common requirement on the web to process info enter in by user e.g. User enter data onto a form, JSP page is called. JSP page needs to retrieve each piece of data entered. Each piece of data is called a request parameter (because it is passed to the server as part of the HTTP request) Will cover how to retrieve request parameters that user has entered (e.g. on a form)

Request parameters - example Each piece of data is called a request parameter (because it is passed to the server as part of the HTTP request) Please select the Honda 2000 features needed Aero Screen: CD Changer: Spoiler: 2mm Yes Blue

Please select the Honda 2000 features needed Aero Screen: CD Changer: Spoiler: Request parameters - example HTML code for form - 3 request paramters sent to server for processing by “somepage.jsp” Use param implicit object (remember?) to access request parameters (as shown overleaf)

Request parameters - example other head html etc…. Choices selected for your screen, cd changer and spoiler were: Screen: CD changer: Spoiler: Test.jsp Just use “ param.name_of_parameter” to retrieve the value

Request parameters - example Output webpage when test.jsp is run Choices selected for your screen, cd changer and spoiler were: Screen: 2mm CD changer: yes Spoiler: blue

Validing user input Need to be able to validate info entered by user (e.g. “you must enter your name”) Can use JSP to do this Looking at previous example: instead of using a HTML page for the form, use a JSP page so that dynamic validation can be included in it. If user has made an error, need to: --  re-display back the values to the user that they have entered in and display error message(s) see validation_example.jsp overleaf

Please select the Honda 2000 features needed Aero Screen: "> CD Changer: "> Spoiler: "> validation_example.jsp Validing user input - example But no actual validation logic included yet….

Please select the Honda 2000 features needed Aero Screen: CD Changer: Spoiler: 2mm Yes Blue Running validation_example.jsp: input boxes will re- display their contents Validing user input - example

Then, to verify whether user has entered in all input into the validation_example.jsp, need to Add in error message if any input boxes left empty -  Use tag to check contents of each box Only want to check for error messages after the user has pressed submit… need a way to check whether form is being loaded up for first time -  user a hidden form field to detect this… Validing user input - example

Please select the Honda 2000 features needed Aero Screen: "> validation_example.jsp Page 1 of 2 field alreadySent Used to determine whether error processing should take place Value of this request parameter is set to “true” when the form it submitted Validing user input - example

You must enter your choice of screen CD Changer: "> code for CD change validation etc etc Error processing for “screen” parameter validation_example.jsp Page 2 of 2 Validing user input - example

Aero Screen: You must enter your choice of screen CD Changer: Spoiler: Sample output from validation_example.jsp Validing user input - example

Validating user input – comments on example Example illustrated how to: (1) access request parameters (using param... (2) validate user input (by using to test values combined with a hidden flag to see if validation should happen (3) re-display values on a screen (using “value = “<c:out…etc” BUT: what happens when the user correctly entered all the data?.. Need to forward on to another page...

General comments about validation Here… used JSTL actions to do validation. Good for simple validation Multiple ways of doing more complex validation (e.g. value matches a list of valid values in a dB), could:  Use JSTL  Use a java servlet for validation, with JSP displaying back page  Use a java bean (developed by developer)  Use custom tags (built by developer) What about using client side?

General Comments - validation Be careful of server-side vs client-side validation: Client-side can be by passed (e.g. switch off client side scripting).. Security risk Alternative browsers may not process the client side script Generally, any data that will end up in database should be subject to server-side validation –Can be easier to keep validation logic together –No dependancy on browser settings or version –Server side allows for more complex validation. For important info, usually have server side only or serverside and client side For less critical info (e.g. search fields) – could have client side only