1 / 71

HTML

HTML. Sites for self-study Tag reference (also Hebrew, Russian?) http://www.werbach.com/barebones/download.html Tutorials (English) http://www.cwru.edu/6532680/help/introHTML/toc.html http://www.utoronto.ca/webdocs/HTMLdocs/NewHTML/htmlindex.html

rudolf
Télécharger la présentation

HTML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HTML • Sites for self-study • Tag reference (also Hebrew, Russian?) • http://www.werbach.com/barebones/download.html • Tutorials (English) • http://www.cwru.edu/6532680/help/introHTML/toc.html • http://www.utoronto.ca/webdocs/HTMLdocs/NewHTML/htmlindex.html • http://www.davesite.com/webstation/html/index.shtml

  2. HTML versions • Current version HTML 4.0 (W3C) • Primarily for compatibility • Tags that aren’t XML conformant deprecated • XHTML is recommended version • Concurrent with HTML 4.0 • Conforms to XML rules • Use it.

  3. Points to remember • Case insensitive • XHTML: requires lower case • XHTML is “elements” • Containers with start/end tags • Some HTML tags don’t need close • <p>, <li>, etc. • XHTML: always close tags • XHTML attributes always in quotes

  4. HTML Doc Structure <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <Title>Let's Play Collaboration</Title> <META NAME="AUTHOR" CONTENT="Israel Gottlieb"/> </HEAD> <BODY> <!--body goes here (does all the work of the page) --> <!--these are comments in XHTML --> </BODY> </HTML>

  5. Lists • <UL> • <LI>Monday • <LI>Tuesday • <LI>Wednesday • <LI>Thursday • <LI>Friday • </UL> • Monday • Tuesday • Wednesday • Thursday • Friday

  6. Lists (cont’d) • Monday • Tuesday • Wednesday • 6am - 9am • 9am - 12n • 12n - 3pm • 3pm - 6pm • Thursday • Friday • <UL> • <LI>Monday <LI>Tuesday <LI>Wednesday • <UL> • <LI>6am - 9am <LI>9am - 12n <LI>12n - 3pm <LI>3pm - 6pm • </UL> • <LI>Thursday <LI>Friday • </UL>

  7. More Lists • <OL> • <LI>Monday • <LI>Tuesday • <LI>Wednesday • <LI>Thursday • <LI>Friday • </OL> • Monday • Tuesday • Wednesday • Thursday • Friday

  8. More Lists • <DL> • <DT>File: • <DD>Operations on the open document • <DT>Edit: • <DD>Changes to the document text • <DT>View: • <DD>Options to display the document • <DT>Insert: • <DD>Adding external content • </DL>

  9. More Lists File: Operations on the open document Edit: Changes to the document textView: Options to display the document Insert: Adding external content

  10. Anchors & Images <A HREF="tcopy.html"> <IMG SRC="pix/warning.gif"> Unauthorized duplication is prohibited! </A> Unauthorized duplication is prohibited!

  11. Tables <TABLE border> <TR> <TH>Course</TH> <TH>Like</TH> <TH>Don’t Like</TH> </TR> <TR> <TD>Robotics</TD> <TD>82%</TD> <TD>18%</TD> </TR> <TR> <TD>SW Engineering</TD> <TD>24%</TD> <TD>76%</TD> </TR> <TR> <TD>Linear Systems</TD> <TD>34%</TD> <TD>66%</TD> </TR> </TABLE>

  12. Tables TABLE border> <TR> <TH>Course</TH> <TH>Like</TH> <TH>Don’t Like</TH> </TR> <TR> <TD>Robotics</TD> <TD>82%</TD> <TD>18%</TD> </TR> <TR> <TD>SW Engineering</TD> <TD>24%</TD> <TD>76%</TD> </TR> <TR> <TD>Linear Systems</TD> <TD>34%</TD> <TD>66%</TD> </TR> </TABLE>

  13. Tables – Global Attributes <TABLE width="75%“ <!--percent of browser width--> border="8" cellpadding="10" cellspacing="10“ > Tables – Alignment <Table align="right"> <!--Entire table to right margin--> <TR align="right" valign="top"> <!--Default for cells in row--> <TD align="right" valign="top"> <!--Override row default--> Tables – Cell Width <TD width="150"> <!–-in pixels--> <TH width="50%"> <!–-in percent of table width-->

  14. Tables -- Spanning <TH colspan="2"> <-- grows to right--> <TD colspan="2"> <TD rowspan="2"> <!-- grows down-->

  15. Example Web Page OPEN BROWSER

  16. Example File <BODY> <FONT FACE="Arial"> <p align="center"><H1>Let's Play Collaboration</H1></p> <TABLE WIDTH="90%" cellspacing="0"> <caption align=bottom align=left> <p align="left"><br/><br/><br/> Here's our first attempt at a Distributed, Web-based Collaboration support system. This is the Home page, and it includes a real-time list of current Collaborations. Enjoy! </p> </caption> <TR> <th bgcolor="#FFC266"><i>Let's Get Going!</i></th> <th align="center" valign="bottom"> <font color="#C66D40">Click to Enter a Collaboration</font> <HR/> </th> </TR>

  17. Example file (cont’d) <TR> <td height="50" bgcolor="#85D9FF"> <font size="3"> <A HREF=search.parms.html>Search Collaborations</A> </font> </td> <td align="center" rowspan="4"> <font color="#FFC266" size="7"> Collaboration Entries will List Here </font> </td> </TR> <TR> <td height="50" bgcolor="#85D9FF"> <font size="3"> <A HREF=new.parms.html>Create New Collaboration</A> </font> </td> </TR>

  18. Example File (cont’d) <TR> <td height="50" bgcolor="#85D9FF"> <font size="3">Test Link 1</font> </td> </TR> <TR> <td height="50" bgcolor="#85D9FF"> <font size="3">Test Link 1</font> </td> </TR> </TABLE> </FONT> </BODY>

  19. <HTML> <HEAD> <TITLE>Tsirkin Evgeny</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-8"> </HEAD> <FRAMESET COLS="150,*"> <FRAME SRC="menu.html" > <FRAME SRC="local.html" name="window"> </FRAMESET> </HTML>

  20. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Evgeny Tsurkin</title> </head> <body bgcolor="#ffcc00" link="#0000ee" vlink="#551a8b" alink="#33cc00"> <center><font size="+1"> <u><i><b><font face="Helvetica, Arial, sans-serif"color="#505050"> Hi ,this is Evgeny's home page. </center> </font></b> </i></u> To see my <a href="cv_r.htm">CV</a> please click here. </body> </html>

  21. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Evgeny's Page</title> </head> <body text="#000000" bgcolor="#ffffff" link="#3333ff" vlink="#cc6600" alink="#009900"> <i><font color="#009900"><cite><font face="Times New Roman, Times, serif" size="-1"><b> <ul> <li><a href="passwd.htm" target="window">JCT Work</a> <li><a href="ps/PostScript/postscript.html" target="window">Postsrcipt</a> <li><a href="emacs.html" target="window">Emacs Settings</a> <li><a href="courses/index.htm" target="window">Courses</a> </ul> </b></font></strike></cite></font> </i><hr><br> <center><font face="Times New Roman, Times, serif" size="-1"><b> <a href="mailto:tsurkin(at)mail.jct.ac.il" align="center"> mail to Evgeny</a> </b></font></center> <br> </body> </html>

  22. Java OO • Interfaces ,abstract classes and packages • Exceptions • Essential classes

  23. Interfaces and abstract classes

  24. public • By default, a class can be used only by other classes in the same package. The public modifier declares that the class can be used by any class regardless of its package • abstract • Declares that the class cannot be instantiated • final • Declares that the class cannot be subclassed • extends Super • The extends clause identifies Super as the superclass of the class, thereby inserting the class within the class hierarchy • implements Interfaces • To declare that your class implements one or more interfaces, use the keyword implements followed by a comma-separated list of the names of the interfaces implemented by the class

  25. Abstract class • abstract class className { . . . } • No instantiation is allowed • AbstractTest.java:6: class AbstractTest is an abstract class. • It can't be instantiated. • new AbstractTest(); ^ • 1 error • An abstract class may contain abstract methods

  26. abstract class GraphicObject { int x, y; . . . void moveTo(int newX, int newY) { . . . } abstract void draw(); } class Circle extends GraphicObject { void draw() { . . . } } class Rectangle extends GraphicObject { void draw() { . . . } }

  27. Final Class/Method • Class that cannot be subclassed • Why? • Security • Design • Declaration: • final class myClass { . . . } • Chess.java:6: Can't subclass final classes: class myClass • class myClass extends myClass{ • ^ • 1 error • Final Method • Method that can’t be overridden by subclasses • class ChessAlgorithm { . . . • final void myMethod(); • }

  28. Interface • Definition:An interface is a named collection of method definitions (without implementations). An interface can also declare constants • Interface versus Abstract class • 1. An interface cannot implement any methods, whereas an abstract class can. • 2. A class can implement many interfaces but can have only one superclass. • 3. An interface is not part of the class hierarchy. Unrelated classes can implement the same interface

  29. The interface body contains method declarations for all the methods included in the interface. All methods declared in an interface are implicitly public and abstract • An interface can contain constant declarations in addition to method declarations. All constant values defined in an interface are implicitly public, static, and final.

  30. A class that implements an interface adheres to the protocol defined by that interface. To declare a class that implements an interface, include an implements clause in the class declaration. • public class myClass extends Applet implements Interface • When you define a new interface, you are defining a new reference data type. • public void method(Inteface object)

  31. Exception • Definition: • An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions. • Why? • Separating Error Handling Code from "Regular" Code • Propagating Errors Up the Call Stack • Grouping Error Types and Error Differentiation

  32. errorCodeType readFile { initialize errorCode = 0; open the file; if (theFileIsOpen) { determine the length of the file; if (gotTheFileLength) { allocate that much memory; if(gotEnoughMemory) { read the file into memory; if (readFailed) { errorCode = -1; } } else { errorCode = -2; } } … return errorCode; }

  33. readFile { try { open the file; determine its size; all ocate that much memory; read the file into memory; close the file; } catch (fileOpenFailed) { doSomething; } catch (sizeDeterminationFailed) { … }

  34. method1 { errorCodeType error; error = call method2; if (error) doErrorProcessing; else proceed; } errorCodeType method2 { errorCodeType error; error = call method3; if (error) return error; else proceed; } errorCodeType method3 { errorCodeType error; error = call readFile; if (error) return error; else proceed; }

  35. method1 { try { call method2; } catch (exception) { doErrorProcessing; } } method2 throws exception { call method3; } method3 throws exception { call readFile; }

  36. catch(InvalidIndexException e) { . . . } catch (ArrayException e) { . . . } catch (Exception e) { . . . }

  37. Throwing Exception public Object pop() throws emptyStackException { Object obj; if (size == 0) throw new EmptyStackException(); obj = objectAt(size - 1); setObjectAt(size - 1, null); size--; return obj; }

  38. Essential Classes import java.io.*; public class Copy { public static void main(String[] args) throws IOException { File inputFile = new File("farrago.txt"); File outputFile = new File("outagain.txt"); FileReader in = new FileReader(inputFile); FileWriter out = new FileWriter(outputFile); int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } }

  39. Buffered I/O BufferedReader in = new BufferedReader(source); ... PrintWriter out = new PrintWriter(target);

  40. Strings • The String class provides for strings whose value will not change • If you are not going to modify the string – use • it it is faster. • The StringBuffer class provides for strings that will be modified . • You use string buffers when you know that the value of the character data will change.

  41. String palindrome = "Dot saw I was Tod"; StringBuffer sb = new StringBuffer("Drink Java!"); char[] helloArray = { 'h', 'e', 'l', 'l', 'o' }; String helloString = new String(helloArray); System.out.println(helloString); String palindrome = "Dot saw I was Tod"; int len = palindrome.length(); StringBuffer dest = new StringBuffer(len);

  42. Modifying StringBuffers class ReverseString { public static String reverseIt(String source) { int i, len = source.length(); StringBuffer dest = new StringBuffer(len); for (i = (len - 1); i >= 0; i--) { dest.append(source.charAt(i)); } return dest.toString(); } }

  43. Forms and Servlets <FORM method="post" action="/servlets/program1"> <INPUT type="text" name="ID" size="10" maxlength="8"> <!–- above input field has no visible label! --> <P> Which of these courses have you taken?<BR> <INPUT type="checkbox" name="courses_taken" value="1">EE101<BR> <INPUT type="checkbox" name="courses_taken" value="2">CS201<BR> <INPUT type="checkbox" name="courses_taken" value="3">OP210<BR> </P> </FORM> Which of these courses have you taken? EE101 CS201 OP210

  44. Forms <INPUT type="hidden" <!-- not visible in browser --> name="mailTarget" Value="sargamon@mail.jct.ac.il" > <SELECT name="access"> <!–- drop-down list --> <OPTION value="0"> modem </OPTION> <OPTION value="1"> direct </OPTION> </SELECT> <INPUT type="submit"> <!–- send form data --> <INPUT type="reset"> <!–- reset form -->

  45. Servlet API Intro. • Servlet intro. • User Input • Session • Servlet context Java Servlet Technology Documentation http://java.sun.com/products/servlet/docs.html API Specifications http://java.sun.com/products/servlet/reference/api/index.html

  46. A servlet is a Java technology based web component, managed by a container, that generates dynamic content. • The servlet container is a part of a web server or application server that provides the network services over which requests and responses are sent, decodes MIME based requests, and formats MIME based responses. A servlet container also contains and manages servlets through their lifecycle.

  47. 1. A client (e.g., a web browser) accesses a web server and makes an HTTP request. 2. The request is received by the web server and handed off to the servlet container. The servlet container can be running in the same process as the host web server, in a different process on the same host, or on a different host from the web server for which it processes requests. 3. The servlet container determines which servlet to invoke based on the configuration of its servlets, and calls it with objects representing the request and response. 4. The servlet uses the request object to find out who the remote user is, what HTTP POST parameters may have been sent as part of this request, and other relevant data. The servlet performs whatever logic it was programmed with, and generates data to send back to the client. It sends this data back to the client via the response object. 5. Once the servlet has finished processing the request, the servlet container ensures that the response is properly flushed, and returns control back to the host web server.

More Related