Parameters passed by client

Slides:



Advertisements
Similar presentations
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Advertisements

Server Side Programming Common Gateway Interface (CGI): Scripts generate Web pages or other files dynamically by processing form data and returning documents.
Video, audio, embed, iframe, HTML Form
J.Sant Servlets Joseph Sant Sheridan Institute of Technology.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
Servlets Stoney Jackson
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
SKT-SSU IT Training Center Servlet and JSP. Chapter Three: Servlet Basics.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
Servlet Lifecycle Lec 28. Servlet Life Cycle  Initialize  Service  Destroy Time.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Chapter 2 Web app architecture. High-level web app architecture  When a client request coming in and needs servlet to serve dynamic web content, what.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
S ERVLETS Hits Counter 21-Nov-15. S ERVLETS - H ITS C OUNTER Many times you would be interested in knowing total number of hits on a particular page of.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
Servlets Part 3. Topics Session Tracking ServletToServletCommunication-Servlet Chaining ServerSideIncludes AppletToServlet.
S ERVLETS Cookies Handling 5-Dec-15. S ERVLETS - C OOKIES H ANDLING Cookies are text files stored on the client computer and they are kept for various.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
+ FORMS HTML forms are used to pass data to a server. begins and ends a form Forms are made up of input elements Every input element has a name and value.
Configuration Web Server Tomcat - Install JDK Install Tom cat Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java and the Web CSE 3330 Southern Methodist University.
Introduction To HTML Dr. Magdi AMER. HTML elements.
How CGI and Java Servlets are Run By David Stein 14 November 2006.
J2EE/Java EE Apache Tomcat v9 IBM Websphere v8 Redhat JBoss EAP v6 Oracle Weblogic v12 Fusion Web Tier ServletsJSPJSF Business Tier JMXJMSEJB.
S ERVLETS Form Data 19-Mar-16. F ORM P ROCESSING You must have come across many situations when you need to pass some information from your browser to.
Programming with Java Lecture 6 Elements of a Java Servlet
Introduction to Servlets
LECTURE 8 (ETCS-308) Subject teacher : Ms. Gunjan Beniwal
Building Web Apps with Servlets
Net-centric Computing
Introduction to HTML Forms and Servlets
JDBC & Servlet CSE 4504/6504 Lab.
Forms Web Design Ms. Olifer.
Servlets Hits Counter 20-Jul-18.
Session Tracking in Servlets
Introducing Forms.
HTML: Basic Tags & Form Tags
Creating Form Elements
Jagdish Gangolly State University of New York at Albany
Servlets and Java Server Pages
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
Web Development & Design Foundations with H T M L 5
Servlets CEN /28/2018 Copyright 2001 Ege Consulting, Inc.
Handling FORM Data using Servlets
Web Search Interfaces.
Web Search Interfaces by Ray Mooney
Servlets.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Java Servlets Servlet Overview Servlets and HTML Forms Servlet Basics
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Parameters passed by client
Ejemplo 4 Modificar el servlet contador de modo de generar una respuesta que muestre la IP de todos los computadores que lo han contactado hasta ahora.
Basic servlet structure
Servlets: Servlet / Web Browser Communication I
HTML: Basic Tags & Form Tags
Presentation transcript:

Parameters passed by client One of the most important features to make the web an interactive environment is the passing of parameters from client so the server The client can pass parameters with the request according to the following format http://host:port/servlet?param1=value1&param2=value2 This means the server will receive 2 parameters: one with name param1 and value value1 and the other with name param2 and value value2 The servlet can ask for those values in the following way: String valueOfParam1 = request.getParameter(“param1”); String valueOfParam2 = request.getParameter(“param2”); Parameter names and values are strings Names of parameters are case sensitive (Param1 != param1)

http://host:port/ServletParameter1?firstname=Nelson&lastname=Baloian import javax.servlet.http.*; import javax.servlet.*; import java.io.*; public class ServletParameter1 extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { PrintWriter out = null; response.setContentType("text/html"); // obtaining parameter value for parameter named “firstname" String fname = request.getParameter(“firstname"); // obtaining parameter value for parameter named “lastname" String lname = request.getParameter(“lastname"); out = response.getWriter(); out.println(<h1> "Hello "+fname+" “+lname</h1"); out.close(); }

The normal way is to gather parameters with forms A Form is an HTML page which may contain graphical objects to gather information which is sent to the server automatically in an URL <HTML> <H1> Collecting parameters </H1> <FORM ACTION=“ServletParameter1”> Nombre: <INPUT TYPE=TEXT NAME=firstname><BR> Apellido: <INPUT TYPE=TEXT NAME=lastname><BR> <INPUT TYPE=SUBMIT VALUE=“MANDAR”> </HTML>

<H1> Collecting parameters</H1> <HTML> <H1> Collecting parameters</H1> <FORM ACTION=“ServletParameter1”> Nombre: <INPUT TYPE=TEXT NAME=fistname><BR> Apellido: <INPUT TYPE=TEXT NAME=lastname><BR> <INPUT TYPE=SUBMIT VALUE=“MANDAR”> </FORM> </HTML> <FORM> y </FORM> define the beginning and end of a Formulary which will be filled in order to transfer data to the server ACTION= “…” defines the action that will be taken when the input button is pressed In this case, the URL that will be called

<H1> Collecting parameters</H1> <HTML> <H1> Collecting parameters</H1> <FORM ACTION=“ServletParameter1”> Nombre: <INPUT TYPE=TEXT NAME=fistname> <BR> Apellido: <INPUT TYPE=TEXT NAME=lastname> <BR> <INPUT TYPE=SUBMIT VALUE=“MANDAR”> </FORM> </HTML> <INPUT … defines an input (interaction) element This element will be transfered as a parameter to the server with the URL TYPE defines the type of element (TEXT) NAME defines the name of the element, which will also be transfered

<H1> Collecting parameters</H1> <HTML> <H1> Collecting parameters</H1> <FORM ACTION=“ServletParameter1”> Nombre: <INPUT TYPE=TEXT NAME=fistname> <BR> Apellido: <INPUT TYPE=TEXT NAME=lastname> <BR> <INPUT TYPE=SUBMIT VALUE=“MANDAR”> </FORM> </HTML> TYPE=SUBMIT defines a button element which will trigger the ACTION defined VALUE=“……” label of the button

When pressing the button the URL Shown will be sent The parameters will be automatically added

Other Input types we will use Radio: only one element between various alternatives can be chosen Select: like radiobutton but with puldown menu TextArea: like text but can contain many lines. Password: like text but does not show the content (***** instead of what you really input)

Radio <h2> Elija una laternativa </h2> <HTML> <input type=radio name=radio1 value=valor1> Alternativa 1 <br> <input type=radio name=radio1 value=valor2> Alternativa 2 <br> <input type=radio name=radio1 value=valor3> Alternativa 3 <br> <input type=radio name=radio1 value=valor4> Alternativa 3 <br> </HTML>

Radio Código para chequear cuál alternativa se seleccionó <h2> Elija una laternativa </h2> <HTML> <input type=radio name=radio1 value=“valor1”> Uvas <br> <input type=radio name=radio1 value=“valor2”> Peras <br> <input type=radio name=radio1 value=“valor3”> Higos <br> <input type=radio name=radio1 value=“valor4”> Mangos <br> </HTML> Código para chequear cuál alternativa se seleccionó String alt = request.getParameter(“radio1”); if (alt.equals(“valor1”)) out.println(“Ud. Eligió Uvas”); else if (alt.equals(“valor2”)) out.println(“Ud. Eligió Peras”); else if(alt.equals(“valor3”) out.println(“Ud. Eligió Higos”); else out.println(“Ud. Eligió Mangos”);

(Elección entre varias alternativas con pul-down menu) Select (Elección entre varias alternativas con pul-down menu) HTML SERVLET Preview

Text Area HTML SERVLET <h2>Ingrese aqui su opinion </h2> <TEXTAREA NAME=“Ta1" ROWS=10 COLS=40> lo que se excriba aca saldra en el area pero se puede editar </TEXTAREA> SERVLET String texto; texto = request.getParameter(“Ta1”);