introduction to html dr. magdi amer. html elements
DESCRIPTION
TablesTRANSCRIPT
![Page 1: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/1.jpg)
Introduction To HTML
Dr. Magdi AMER
![Page 2: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/2.jpg)
HTML elements
![Page 3: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/3.jpg)
Tables
![Page 4: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/4.jpg)
<a href=‘www.ite.com’> click here </a>
Links
![Page 5: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/5.jpg)
Forms
![Page 6: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/6.jpg)
Forms
![Page 7: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/7.jpg)
7
Web Architecture
![Page 8: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/8.jpg)
8
• An HTTP request has three parts, separated by spaces:– A method name– The local path of the requested resource (URI)– The version of HTTP being used
GET /reports/sales/index.html HTTP/1.1• If parameters are required, they are passed by
appending a query string to the URIname1=value1&name2=value2&…&nameM=valueM
HTTP Get Request
![Page 9: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/9.jpg)
9
• In POST, the parameters are sent in the message body, unlike in GET, in which they are a part of the request URI.
• Post result cannot be bookmarked, while get result can be bookmarked.
HTTP Post Request
![Page 10: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/10.jpg)
10
package com.amer;import java.io.*;import javax.servlet.*;import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException { doGet(req, res);} public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException { res.setContentType("text/html");
PrintWriter out = res.getWriter(); out.println("<HTML>"); out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>"); out.println("<BODY>"); out.println("<BIG>Hello World</BIG>"); out.println("</BODY></HTML>"); }}
First Servlet
![Page 11: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/11.jpg)
11
– As a link: always GET<a href=‘/appName/HelloWorld?
var1=value&var2=value2’>go</a>
– As a form action can choose GETor POST<form method=‘GET’ action=‘/appName/HelloWorld’>
….</form>
Calling a Servlet
![Page 12: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/12.jpg)
12
//Single parameterString uname= request.getParameter("uname");String gender = request.getParameter(“gender”);If(gender == null) gender=“”;
//Multi parametersString[] langs = request.getParameterValues("lang");if(langs==null) langs = new String[0];
Reading Parameters
![Page 13: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/13.jpg)
13
Input type: text, password, hidden, single combo, text area single, never null
Input type: radio, submit single, may be null
Input type: checkbox, multi combo multi, may be null
Parameters Types
![Page 14: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/14.jpg)
14
<?xml version = '1.0' encoding = 'UTF-8'?><servlet> <servlet-name>HelloWorld</servlet-name> <servlet-class>eg.edu.ufe.tic4.HelloWorld</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloWorld</servlet-name> <url-pattern>/hi</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HelloWorld</servlet-name> <url-pattern>*.php</url-pattern> </servlet-mapping></web-app>
web.xml
![Page 15: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/15.jpg)
15
History of the web
![Page 16: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/16.jpg)
16
Class Variable(static)
Instance Variable
FunctionVariable
Single Threaded Shared Unique Unique
Multi-Threaded
Shared Shared Unique
Handling Multi-threads
![Page 17: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/17.jpg)
17
Handling Multi-treading
1- do not use instence variables or shared objects in servlets2- If really necessary use synchronized synchronized(this) { int y= x; // x is an instance variable, shared between multiple threads// y is a function variable, unique for each thread y = y+100; x = y; }
![Page 18: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/18.jpg)
18
<%@ page contentType="text/html;charset=UTF-8" import="com.amer.*”%><%@ page import=“java.util.*" %><select name=‘gov’><%//java codeout.println(“<BR/>NAME”);%></select><%=variable%> <%out.print(variable);%><%! //variable and function declaration %><BR>
JSP
![Page 19: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/19.jpg)
19
JSP to Servletimport com.amer.*;public class JspToServlet extends HttpServlet{ //variable and function declaration public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doGet(req, res);}
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { PrintWriter out = res.getWriter();
res.setContentType("text/html"); res.setCharacterEncoding(“UTF-8”); //java code out,print(“<BR/>NAME”): out.print(variable); out.println(“<BR>”); }
![Page 20: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/20.jpg)
20
Dispatching request from Servlet to JSP
RequestDispatcher dispatcher = this.getServletContext(). getRequestDispatcher("/Login.jsp"); dispatcher.forward(request, response);
![Page 21: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/21.jpg)
21
Passing data from Servlet to JSP//Servlet 1Vector<Employee> list = null;//…………request.setAttribute(“list”, list);
//JSP<%Vector<Employee> list = (Vector<Employee>)
request.getAttribute(“list”);%>
![Page 22: Introduction To HTML Dr. Magdi AMER. HTML elements](https://reader036.vdocument.in/reader036/viewer/2022062302/5a4d1b707f8b9ab0599b537c/html5/thumbnails/22.jpg)
22
Sessions
//to create a sessionHttpSession session = req.getSession(true);User u = new User(); //any object// to store a value in the sessionsession.setAttribute(“user”, u);//////////////////////////////////////To obtain an instance of an existing sessionHttpSession session = req.getSession();// to read a valueUser u = (User) session.getAttribute(“user”);