Você está na página 1de 7

function startsWith() { var input = prompt(Enter search value : ); var regex = ^+input; var arr = new Array(Ajax Books,

Javascript, Java, JSP & Servlet, MySQL, Regular Expression); for(i=0; i<arr.length; i++){ str=arr[i]; if( str.match(regex) == input){ alert(Matching string is : +str); } } }

XML Schema An XML Schema defines how to structure an XML document and it can be used in place of DTD. XML Schema is based on XML. XML Schema language is known as XML Schema Definition (XSD). The Purpose of XML Schema Some of the main purposes of XML Schema are to define: 1. Elements which can occur in the xml document. 2. The child elements for an elements 3. The order of child elements 4. The number of child elements 5. Whether the element is empty or it can have some text 6. The type of data elements or attributes can have 7. Attributes which can be used for the elements used in a document 8. Default and fixed values for elements and attributes <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="book"> <xs:complexType> <xs:sequence> <xs:element name="book-name" type="xs:string"/> <xs:element name="book-author" type="xs:string"/> <xs:element name="short-desc" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

What is the DOM?


DOM stands for Document Object Model, and allows programmers generic access - adding, deleting, and manipulating - of all styles, attributes, and elements in a document. It can be

accessed via any language available in the browser, including Java, JavaScript/ECMAScript/JScript, and VBScript (MSIE only). For practicality's sake, the syntax used in this tutorial will be that of JavaScript. The DOM is supported most completely starting in IE 5 and Gecko (NS6 and upwards, such as Firefox.) Every tag, attribute, style, and piece of text is available to be accessed and manipulated via the DOM -- the possibilities are endless. This tutorial will cover the basics of the DOM: adding and removing tags, attributes and styles, animating existing elements, and hiding/ showing elements on a page. Obviously, to cover the entire scope of all that the DOM has to offer, an entire book is needed. This tutorial simply serves as an introduction to the subject. Just so you know. The DOM is constantly being revised by the W3C, with browsers at the same time constantly trying to support the latest recommended version of the DOM. As of IE6 and Firefox 1.0, DOM 2 best encompasses what the two browsers currently support. DOM 3 is the next major version in the works. Before you get started, you need to know a few terms that we will use: Node: A reference to an element, its attributes, or text from the document. Element: A representation of a <TAG>. Attribute: A property of an element. HREF is an attribute of <A>, for example. With that said, lets discuss browser compatibility now.

Advantages of using XML schemas instead of DTDs


DTDs are easier to code and validate than an XML schema. However, the advantages to using an XML schema are shown in the following list: XML schemas are valid XML documents that can be processed by tools such as the XSD Editor in WebSphere(R) Studio Application Developer, XML Spy, or XML Authority. XML schemas are more powerful than DTDs. Everything that can be defined by the DTD can also be defined by schemas, but not vice versa. XML schemas support a set of data types, similar to the ones used in most common programming languages, and provide the ability to create additional types. XML schemas support regular expressions to set constraints on character data, which is not possible if you use a DTD. XML schemas provide better support for XML namespaces, which enable you to validate documents that use multiple namespaces, and to reuse constructs from schemas already defined in different namespaces. XML schemas provide better support for modularity and reuse with include and import elements. XML schemas support inheritance for element, attribute, and data type definitions.

Applet Security Restriction


Each applet viewer has a SecurityManager object that checks for applet security violations. When a SecurityManager detects a violation, it creates and throws a SecurityException object. Generally, the SecurityException constructor prints a warning message to the standard output. File Access Restrictions Java Applets are not allowed to read the local file system. They cant even read files in a read only mode. This protects the end user form hidden applets browsing their local hard drive(s) for information. Network Restrictions An Applet is not allowed to listen for connections. They also cannot send data back to any other source other then the originating home server. These security restrictions are there to protect

organizations that run a firewall. The problem with Applets is that they run inside the firewall so these restrictions help prevent malicious code. Other Security Restrictions Non-local Applets may not access the system properties. This keeps websites with Applets from reading information from your local computer. Only locally run Applets can do these advanced things. Applets cannot execute other files on your local machine. This prevents an applet from deleting files or running malicious code on your local machine. Applets may not be able to define classes that belong to certain packages. Typically, they cannot define classes for the java and sun packages. Also, Netscape does not permit applets to define classes in the Netscape package.

EVENT DELEGATION MODEL


Event Delegation Model: Whenever we want to develop any windows applications one must deal with event delegation model. Event delegation model contains four properties. They are: In order to process any active components, we must know either name or caption or label or reference of the component (object). Whenever we interact any active component, the corresponding active component will have one predefined Event class, whose object will be created and that object contains two details: 1. Name of the component. 2. Reference of the component. The general form of every Event class is xxx event. For example: Component name Event name print java.awt.event.ActionEvent choice java.awt.event.ItemEvent textField java.awt.event.TextEvent textArea java.awt.event.TextEvent scrollbar java.awt.event.AdjustmentEvent In order to perform any action or operation when an interactive component is interacted we must write some set of statements into the appropriate methods. These methods are not defined or developed by SUN micro system, but they have supplied those methods with no definition i.e., undefined methods. In JAVA purely undefined methods are abstract methods present in interfaces. Interfaces in awt are called listeners. Hence, every interactive component must have a predefined listener whose general notation is xxx listener. For example: Component name Listener name Button java.awt.event.ActionListener Choice java.awt.event.ItemListener TextField java.awt.event.TextListener TextArea java.awt.event.TextListener Scrollbar java.awt.event.AdjustmentListener Identity what is the undefined method or abstract method in xxx Listener. For example: Component name Undefined method name Button public void actionPerformed (java.awt.event.ActionEvent) Choice public void actionPerformed (java.awt.event.ItemEvent) TextField public void actionPerformed (java.awt.event.TextEvent) TextArea public void actionPerformed (java.awt.event.TextEvent)

Each and every interactive component must be registered and unregistered with particular event and Listener. The general form of registration and un-registration methods is as follows: public void addxxxListener (xxxListener); public void removexxxListener (xxxListener);

Java vs JavaScript
Java and JavaScript are programming languages. Java is an object oriented programming language whereas JavaScript is more of a scripting language. Both can be used to make web pages more interactive. However, Java is also used to develop server side applications and standalone programming. Java Java is an object oriented programming language. In early 1990s, Sun Microsystems developed the Java language. Initially, it was designed to make small programs for the web browser called applets. But later on, Java was used to create applications based on e-commerce. There are five main features of Java language: Provides more flexibility to develop software applications because of object oriented approach. Easy to use as it combines the best properties of other programming languages. Allows code written in Java to run on different platforms or Java code is independent of platform. The code from the remote source can be executed securely. Built-in support for computer networks. Java also supports automated memory management model that allows developers to get rid of the time consuming method called manual memory management. Programmers can easily do this by implementing automatic garbage collection. But according to some people, Java is slow as well as consumes more memory than other programming languages such as C++. JavaScript JavaScript is also a programming language which is used to make web pages more dynamic as well as interactive. Constant downloads from the server are not required in case of JavaScript as it runs on the users computer. JavaScript is different from the Java programming language. Most modern day web browsers have built-in JavaScript. However, JavaScript based web pages can run only if JavaScript is enabled on the web browser and the browser supports it. JavaScript is enabled in most browsers by default. No special program is required in order to write code in JavaScript as it is an interpreted language. You can use any text editor such as Notepad in order to write JavaScript code. You can also use other text editor that colorizes the different codes making it easier to detect any error. JavaScript is different from HTML because JavaScript is used to create more dynamic web pages while HTML is a markup language that is used to create static content on the web page. You can insert the JavaScript code in a HTML file by using the <script> tag. But if you want to use the script in different pages of the website then you can save the scripts in different files with .js extension.

Difference between Java and JavaScript


Java is an object oriented programming language whereas JavaScript is more of a scripting language. JavaScript is used to make the web pages more interactive. However, Java can be used not only to make interactive web pages but can also be used to create server side applications and standalone programming. Java uses the concept of classes and objects that makes reuse of the code easier but there is no such thing in JavaScript. Java exhibits the properties like inheritance, data encapsulation and polymorphism whereas JavaScript does not.

What is XML?

XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined. You must define your own tags XML is designed to be self-descriptive XML is a W3C Recommendation

Nine Rules for Creating Good XML


Rule 1: All XML Must Have a Root Element Rule 2: All Tags Must Be Closed Rule 3: All Tags Must Be Properly Nested Rule 4: Tag Names Have Strict Limits Rule 5: Tag Names Are Case Sensitive Rule 6: Tag Names Cannot Contain Spaces Rule 7: Attribute Values Must Appear Within Quotes Rule 8: White Space Is Preserved Rule 9: Avoid HTML Tags (Optional) Key handling program import java.awt.*; import java.awt.event.*; public class KeyPress extends Frame{ Label label; TextField txtField; public static void main(String[] args) { KeyPress k = new KeyPress(); } public KeyPress(){ super("Key Press Event Frame"); Panel panel = new Panel(); label = new Label(); txtField = new TextField(20); txtField.addKeyListener(new MyKeyListener()); add(label, BorderLayout.NORTH); panel.add(txtField, BorderLayout.CENTER); add(panel, BorderLayout.CENTER); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent we){ System.exit(0); } }); setSize(400,400); setVisible(true); } public class MyKeyListener extends KeyAdapter{ public void keyPressed(KeyEvent ke){ char i = ke.getKeyChar(); String str = Character.toString(i); label.setText(str); } } }

JApplet a class that enables applets to use Swing components. JApplet is a subclass of
java.applet.Applet, which is covered in the Java Applets trail. Any applet that contains Swing components must be implemented with a subclass of JApplet.Because JApplet is a top-level Swing container, each Swing applet has a root pane.JApplet has a single content pane.The default layout manager for a Swing applet's content pane is BorderLayout. init, start, stop, and destroy

controls in AWT
an awt conrols is a component that allows the end users to interact with applications created in java.All AWT controls in java are subclass of component class. the component class provides the add() method to add awt components to containers such as applet windows. The components are: LAbel,Button, heckboxes, radio buttons choice, textr field text areas scroll bar

Difference between Applet and Swing?


1. Swing is light weght Component. Applet is heavy weight Components 2. Swing Using UIManager. Swing have look and feel according to user view u can change look and feel. Applet Does not provide this facility 3.Swing uses for stand lone Applications ,Swing have main method to execute the program. Applet need HTML code for Run the Applet 4. Swing uses MVC Model view Controller. Applet not 5. Swing have its own Layout ..like most popular Box Layout Applet uses Awt Layouts..like flowlayout 6. Swing have some Thread rules. Applet doent have any rule. 7. To execute Swing no need any browser By which we can create stand alone application But Here we have to add container and maintain all action control with in frame container. To execute Applet programe we should need any one browser like Appletviewer,web browser. Because Applet using browser container to run and all action control with in browser container.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>My first styled page</title> <style type="text/css"> body { padding-left: 11em; font-family: Georgia, "Times New Roman",

Times, serif; color: purple; background-color: #d8da3d } ul.navbar { position: absolute; top: 2em; left: 1em; width: 9em } h1 { font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif } </style> </head> <body>

Você também pode gostar