You are on page 1of 33
Technoglobe Organization of VSM InfoTech A SUMMER TRAI ON NG REPORT Advance java Submitted In partial fulfillment of the Requirement for the award of the degree of BACHELOR OF TECHNOLOGY In COMPUTER SCIENCE ENGINEERING Submitted to: Submitted by: Mr, YOGESH SHARMA NITESH SAINI Head of department I4EEJCSEO1S Department of Computer Science Engineering GOVERNMENT ENGINEERING COLLEGE JHALAWAR Jhalrapatan, Dist. Jhalawar-326023 September, 2017 Candidate’s Declaration | hereby dechre that the work, which is being presented in the Seminar report, entitled “Technoglobal organization” in partial fulfilment for the award of Degree of “Bachelor of Technology” in Dept. Of Computer science & Engineering and submitted to the Department of Computer science & Engineering, Government engineering college jhalawar, Rajasthan Technical University is a record of my own investigations carried under the Guidance ‘of Mr, yogesh Sharma Department of Computer science & Engineering, Government ‘engineering college jhaknwar. | have not submitted the matier presented in this report anywhere for the award of any other Degree. Nitesh saini Roll No: I4EEJCSO1S iti ABSTRACT ‘The Advance Java training done by the Publishing Systems and Solutions Unit in Teetnoglobe, jaipur, sets to ereate and develop Software or other web technology to enabk desktop access to Informition Technology sector. ‘The students’ project, which contributed 19 part of the Project, allowed the stidents to acquire the knowledge of Object Oriented Progamming and Sofiware Engineering. ‘The Text Editor Application, the inital part of the E-service problem set, served as an imroduction to object oriented programming in Java. The Text Editor Applet fices an applet security that severely restricts functionality, particutirly in file access and printing. ‘The project inroduced the use of servlet to handle these fictions. remtely instead, The Text Editing Service then imroduced a new clectronic service, which goes beyond the simple clemscrver imadel The former empkys many small service components and make sure of the e-speak framework to define the text cditor service and interface. From the resus af the successfil project, it is recommended that the Extensible Markup Language, XML, be used in place of the HTML, which has imited intemal structure, XSL, a transformation language for transforming a XML document into an HTML document, can be used to convert the Text Editing applet to talk to the e-speak service, iv ACKNOWLEDGEMENT am grateful to my training guide in Technoglobe Organization of VSM InfoTech whose encouragement and cooperation has been sources of great inspiration; | express my heartfid thanks to Mr. Narendra Kumar Sir for his pains taking effort and enthusiastic ‘cooperation to make my training possible | express heantly thanks to guide by Mr. Yogesh Sharma (Head of Computer Science Engineering Dept.) for giving me an opportunity the summer taining at Technoglobe Organization of VSM InfoTech Jaipur, Nitesh Saini I4EEICSO1S B.Tech. (IV Year) ‘Computer Science & Engineering COMPANY PROFILE ‘Tectmogibbe (International Accredited Organization [AO Authorized Institution) & a Flygship of VSM Infotech which is a Government of Rajasthan registered & ISQ 90012008. certified ‘ofishore Software Development & IT Training Company established in 2001 ‘This & the same company that has diiven TATA-CMC & abo HCL Ledming Lid in Jaipur fom ‘year 2005 to 2016, Technogibe is authorized parmer of HPE (Hewlett Packard Enterprise), MICROSOFT, ADOBE, AUTODESK, COMPTIA, IJT-TEAMLEASE & MONSTER.COM Technoglbe employs highly quilifed profssionas with PRD. M.Tech, B:Tech, and MCA & MBA. It have well disciplinary team comprising cdlucation experts, subject matter experts, instructional designers, quality ‘experts, Academic advisors, experienced Placement officers, Project Managers & Team lade Technogiobe is an innovative and cost effective world-class provider of Customize Application Development, Client Server, Mobile and Web Based Solution & IT Training in (NET, JAVA, PHP, Android, Networking, Embedded System, AuioCAD, Web Designing, and SEO, Testing ete.) Technoglobe reies on a pool of highly quiliied professionals anied with sound and diversified technical skill sets, Our team develops sofware sobtions for imemational tech giants and is trained to provide offshore, onshore and onsite services. For the best Pcement of our students we have tie-up with the biggest Pkrcement Giant that i Monster.com Enhance professional and socit! skills of each Jeamer through technology empowered karming in ‘campus, Institutional Allance program of Technogbe delivers training that are relevant for all core brinches of engineering viz, Civil, Mechanical, Electrical Electonics & Communication, ‘Computer Science & IT, These training programs provide the much needed industry skills that the student requires. to rmke them, ‘employment ready. vi TABLE OF CONTENTS Candiate declaration’s Centificat... Abstract .. Acknowledgement ‘Company Prof. ‘Table of Contents... List of Figures, CHAPTER | (CHAPTER 2 (CHAPTER 3 (CHAPTER 4 CHAPTER 5 (CHAPTER 6 (CHAPTER 7 CHAPTER 8 CHAPTER 9 CHAPTER 10 APPLET. (CHAPTER 11 PROJECT... INDEX TECHNOLOGY esi tavPvined as { COLLECTION... MULTITHREADING [4-5] JAVA NETWORKING. .....cc0.cccesseesenes [6] AWT occcccscccssssssessinsinneesonsasnns (TI SWING . 8] JAVA DATABASE CONNECTIVITY....... [9-11] JAVA SERVER PAGE. ............2-0:0000000 [12-16] JAVA SERVER PAGE. ...0........0cc0esc00c00 [17 = 18] ..[19 = 20] seosenenee (21 +23] CONCLUSION vil LIST OF FIGURES Figure no. Title 3 Multithreading life Cycle 3. Java AWT Hierarchy 61 Hierarchy of Java Swing classes Tl JDBC drivers 8.1 JSP 8.2 JSP compilation 83 JSP Tags OL Lifecycle of Servlet o1 Lifecyele of Servlet Wad Data flow diagram 112 Registration Page 113 Login page 1L4 Transfer money page Page no. CHAPTER -1 TECHNOLOGY 1, INTRODUCTION TO JAVA. Java isa programming language initially developed by Sun Microsystems by James Gosling and released as a principal component of Sun Microsystems’ Java platform in 1995, Although the language gets much of is syniax ffom Cand C++ it has a ss complicated abject model and lesser low-level services, Java applications are typically comp! to byte code (class fie) that ‘can rin on any Java Vitwil Machine (JVM) regardless of compiser architecture Java & a -generatpurpose, object-oriented knguige that i specifically designed 10 have as few implementation dependencies as possibe. Its intended to et appleation developers "write once, rim anywhere", Java is curently one of the most standard programming kimguages in use, and i cextensively used ffom application sofiware to web applications. ‘There were five primary goal in the creation of the Java language. It should be "simple, object-oriznled and Exnliar*, It should be "robust and secure". It should be "architecture-neutral and portable’. Ttsboukd execute with "high performance", It should be "iuerpreted, threaded, and dynamic" 2. J2EE Short for Java 2 Phuform Enterprise Edition, J2EE is a phtform-independent, Java- centric environment from Sun for developing building and deploying Web-based enlerprise applications online. The J2EE platform consists of a set of services, APIs, and protocols that provide the fimetionality for developing mukitier, Web-based appbeations, Some of the key features and services. of J2 At the client tier, J2EE supports pure HTML, as well as Java applets or applications. It relies on Java Server Pages and servist cade to create HTML or other formatted data for the chent Enterprise JavaBeans (EIBs) provie anather ayer where the platform's logic is stored. An EIB: server provides fiinctions such as threading, concurrency, security and memory management. ‘These services are transparent to the author, Java Database Connectivity (JDBC), which & the Java equivakm to ODBC, is the standard ivterfice for Java databases, ‘The Java serviet API enhances consistency for developers without requiring a graphical user interface, ‘CHAPTER -2 COLLECTION ‘Colkction famework provides a welldesigned sct of interfice and chisses for storing and manipulating groups of data as a signal unit a collection, It provides a standard programming iterfice to many of the most common abstractions, without blunlering the programmer with 100 many procedure and interfiees. Collocation tree part 1, List-Armay List 1.2. Set Tree set, Hash set, Link hash set 1.3, Map- Hash Map, Hash Table, Tree Map 2. Benefits of the Java Collections Framework 2.1 Reduces programming effort By providing usefil data structures and algorithms, the Collections Framework ffees you to- concentrate on the important parts of your progam rather than on the low-level "plunbing” equired to make it work. By ficilitating interoperability among unrelted APIs, the Java Colections Framework fees you from writing adapter objects or comersion code to comect APIs. 2.2 Increases program speed and quality This Colkctions Framework provides high-performance, high-quality impkmentations of usefil data sinictures. and algorithms, The various. implementations of each —inlerfice are interchangeable, so programs can be easily tumed by switching colection implementations, Because you're freed fom the drudgery of writing your own data structures, you'll have more time to devote to improving programs’ quality. and performance. 2.3. Allows interoperability among unrelated APIs ‘The collection interfaces are the vernacular by which APIs pass collections back and forth. If my network administration API fitmisbes a collection of node names an! if your GUI toolkit expects a collection of column headings, our APIs will interoperate seamlessly, even though they were \written independently. 2.4. Reduces effort to learn and to use new APIs Many APIs naturally take collections on input and furnish them as output, In the past, each such API had a small sub-API devoted to manipulating its collections. There was little consistency among these ad hoc collections sub-APIs, so you had to kam each one from scratch, and it was easy to make mistakes when using them. With the advent of standard collection interfaces, the problem went away. 2.5. Reduces effort to design new APIs ‘This i the flip side of the previous advantage. Designers and implementers don't have to reinvent the wheel cach time they create an API that relies on collections; instead, they can use standard collection interfaces, 2.6. Fosters software reuse New data structures that conform to the standard eolletion interfaces are by nature reusable. The same gocs for new algorithms that operate on objects that implement these interfaces CHAPTER -3 MULTITHREADING Java is a muki-threaded programming language which means we can develop ulithreaded ‘program using Java. A multi-threaded program contains two or more paris that can run ‘concurrently and each part can handle a different task at the same time making optimal use of the available resources especially when your computer has multiple CPUs. By definition, multitasking is when mutiple processes shure common processing. resources. such as a CPU, Multithreading extends the idea of rmititasking into applications. where you can Subdivide specific operations within a singk application into individual threads, Each of the threads can run in parallel The OS divides processing time not only among different applications, but ako among cach thresd within. an appbcation, Multithreading enables you 10 write in a way where nmitiple activities can proceed concurrently in the same program, 1. Life Cyele of a Thread AA thread goes through various stages in its fe cycle. For example, a thread is bom, started, runs, and then dies, The following diagram shows the complete life cycle of a thread, New Thresel() Fige3 Multithreading life Cyc! Following are the stages of the life cycle = New — A new thread begins its life cycle in the new state. It remains in this state until the program starts the thread. [tis also referred to asa born thread. Runnable ~ afler a newly bom Wiread & started, the Unread becomes munnable, A thread in this State is considered to be executing its task, Waiting — Sometimes, a thread transitions to the waiting state while the thread waits for another ibread to perform a task. A thread transitions back to the runnable state only when another thread signals the waiting. thread to continue executing. ‘Timed Waiting - A numable thiead can enter the timed waiting state for a specified interval of time. A thread in these state transitions back to the rumble state when tht time interval expires ‘or when the event it is waiting for occurs ‘Terminated (Dead) — A runable thread enters the terminated state when it comptes its task or ‘otherwise terminates. Thread Priorities Every Java thread has a priority that helps the operating system determine the order in which threads are scheduled. Java thread prioriies are in the range berween MIN PRIORITY (a constant of 1) and MAX PRIORITY (a constant of 10). By defiut, every thread is ghen priority NORM_PRIORITY (a constant of 5) Threads with higher priority are more important to a program and should be allocated processar time befdre lower-priority threads. However, thread priorities cannot guarantee the order in Which threads exeeute and are very much plutiorm dependent. Create a Thread by Implementing a Runmble Imerfice If your class is intended to be executed as a thread then you can achieve this by implementing 1 Runnable interface. You will need to follow three basic steps ~ Step. I- As a first step, you need to implement a run () method provided by a Runnable interfive, This method provides an entry point for the thread and you will put your complete business logic inside this method. Following is «simple syntax ofthe run () method ~ public void run () Step 2- As a second step, you will instantiate a Thread abject using the following constructor — ‘Thread (Rumable threadObj, String threadName), Step 3+ Once a Thread object is created, you can start it by calling start Q) method, which executes a call 1o run () method. Following is a simple syncax of start () Method ~ void start (); CHAPTER - 4 JAVA NETWORKING ‘The term Network programming refers to writing programs that execute across multiple devives (Computers), in which the devices are all comected to each other wing networks. The Java net ‘package of the J2se API contains a collection of classes and interfaces that provide the kiw-kvel communication detail, allowing you to write programs that focus on solving problem at hand, ‘The java net package provides support for the two common network protocols, 1, The java.net package provides support for the twe common network prolocoks TCP- TCP stands for transmission contol protocol, which allows for reliable communication between two applications. TCP 8 typically used over the Intemet Protocol, which is referred 10 as TCPAP, UDP (User Datagram Protocol) - UDP siands for User Daiagram Protocol, a connectioi-less protocol that allows tivr packets of data to be transmitters between applications. 2. This chapter gives a good understanding on the following two subjects — URL Processing- ‘This would he covered separately. Click here to lear about URL Processing in java kinguage. Socket Programming- Sockets provide the communication mechanism between two computers using TCP. A client program creates @ socket on its end of the communication and attempts 10 connect that socket to a server, When the connection is made, the server creates a socket abject ‘on its end of the communication, ‘The cent ad the server can now communicate by writing to and reading. frdm the socker. CHAPTER -5 AWT (ABSTRACT WINDOWING TOOLKIT) Java AWT (Abstract Windowing Toolkit) is an API to develop GUI or window-based application in java AWT components. are platform-dependent. AWT components” are heavyweight, AWT doesn!t support phugaible look and feel. AWT provides fewer components than Swing, AWT doesnt follow MVC (Model View Controller) where model represents data, view represenis preseniation and controller acts as an inierfice between model and view. 1. Java AWT Hierarchy ‘The hierarchy of Java AWT classes is given below. I pe Ca ] Ctotom Fig-5.1 Java AWT Hierarchy CHAPTER — 6 SWING Work Flow Java Swing is part of Java Foundation Chsses (FC) that is used to ereate window-based applications. It i built on the top of AWT (Absiract Windowing Toolkit) APL and entirely written in java. Java swing components. are platform-independent. Swing components are lightweight. Swing supports pluggable look and feel. Swing provides more powerful components such as tables, lists, and scroll Panes, color chooser, tabbed pane ete. Swing follows MVC. 1. Hierarchy of Java Swing classes ‘The hierarchy of java swing API is given below. as ee | Fig-6.1 Hierarchy of Java Swing classes ‘CHAPTER -—7 JAVA DATABASE CONNECTIVITY ‘The Java Database Connectivity (IDBC) API is the industry standand for database-independent connectivity between the Java programming Language and a wide range of databases — SQL databases and other tabukir data sources, such as spreadsheets or ft fils. The JDBC API provides a calhievel API for SQL-based database access, JDBC technology allows you to use the Java programming lnguage to exploit "Write Once, Run “Anywhere” capabilities for appheations that require access tw enterprise data, With a JDBC technology-enabled driver, you can connect all corporate dats even in a heterogeneous ‘environment 1. JDBC drivers ‘There are commercial and free drivers availible for most rebtional database servers, These drivers full into. one of the following types: ‘Type 1 That calls native cade of the locally avaikible ODBC driver. “Type 2 That calls database vendor native Rorary on a chent side. This code then talks to database cover network, ‘Type 3, the pure-java driver that talks with the server-side middleware those then talks to database. “Type 4 the puresjava driver that uses datahase native protocol eee ese ae a= Sk ire 7.1 JDBC drivers 2. Functionality and implementation JDBC allows smiple implementations to exist and be used by the same application The API provides a mechanism or dynamically foading the correct Java packages and registering them With the JDBC Driver Masager, The Driver Manager used as a connection factory for creating JDBC connections. JDHC conections support Creating and executing statements. These may be update statements sugh as SQLs CREATE, INSERT, UPDATE and DELETE, of they may be query statements such as SELECT, Additionally, stored procedures may be invoked through a JDBC comection. JDBC represents statements. using one of the following, classes ‘Statement - the statement sent to the database server each and every time. Prepared Statement - the statement is cached and then the executin path is predetermined on the database server allowing ito be executed multiple times in efficient manner, Callable Statement- used for executing Database. Updite statements such as IN that indicates: how many rows were affected xl procedure san ibe UPDATE and DEL the database. retin an upebite count ‘These statements do not return any other information, Query statements retumn a JDBC row result set, The row resuil set used to Wak over the result set, Individual columns in a row are retrieved either by name or by cohimn umber, There may be ary number of rows in the result set The row result set has metadata that describes the names of the columns and their types. ‘There is an extension to the basic JDBC API in the javexcsql The method: Class.sorName (String) is wsed to load the JDBC driver chss. Example- Chss.forName (sunidbe.odbe,JdbeOdbeDriver); Used (load the JDBC-ODBC bridge driver. When a Driver clss is loaded, it creates an iistance of itself and registers it with the Driver Manager, Now when a conection is needed, onc of the DriverManager.getConnection() incthods is used to create a JDBC connection Ifa database openiion fis, JDBC raises a SQLException. There is typically very lite one can do 10 recover from such an error, apart from loggmg i with es much detail as possible, It is recommended that the SQLException be tanskited ito an application domain exception (an unchecked onc) that eventually resus in a transaction rollback and a notification’ to the user. Finally to summarize, the following. points can be stated- JDBC API provides a database programming interfice for Java’ prograims, A Java program cait send queries to a database by wing. the JDBC driver. ‘The javasq! package comlains chistes that hely in corinectiig (0 a databuise, sending SQL statements to the database and processing the ejwety results, na ‘The Connection Object represents a connection with a database. 1 1 can be initialed using the get Connection () method ofthe Driver Manager class. ‘The Prepared Statement object allows you to execute parameterized queries. It ean be initialized wing the prepare Statement () method ofthe Consection object. The set String () method sets the query parameters of the PreparedStatementabject, ‘The execute Update () method executes the query statement present in the Prepared: Statement object and rétums the number of rows affected by the query. The Resul Set Meiadaia interfiee is used to obiain information about the columns stored in a Result Set object. 2 CHAPTER —8 JAVA SERVER PAGES Java Server Pages (JSP) is a technology that helps sofiware developers ereate dynamically ‘generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun Microsystems [1], JSP is similar to PHP, but it uses the Java programming language. To deploy and run Java Server Pages, a compatible web server with « servlet container, such as Apache ‘Tomeat or Jetty, és required. Java Server Pages is a technology which permits software developers to create dynamic: request like HTML, XML in order to answer to cent request in the net. This technology kets Java code and definte pre-defined procedures to be implanted into static content. The syntax in Java Server Pages inches a supplementary XML tag which is known as JSP actions, It is made use to evoke the utility of the built-in fimetions. Moreover JSP permits to establish and form the JSP tag Bbrares which operae as an extension to the stanard XML or HTML tags ‘These JSP tag libraries give a good technique to widen the potently of the Web server by providing an independent platform's. compiler compiles the JSPs into Java Servicts Figure 81 JSP A JSP compiler may possibly create a serviet in Java code and it is later compiked by the Java compiler, It might even directly produce the byte code for the servlet. Java Server Pages can be examined as a high level abstraction of servlets which is practiced as an extension of the Servie2.1APL Java Server Pages are HTML pages embedded with snippets of Java code, 1 is. an invene of a Java Servlet JSPs run in two phases ‘Translation Phase- In tanstition phase JSP page is compiked into s servlet called JSP Page Implementation class Execution Phase- In execution phase the compiked JSP is processed 3 Figure 8.2 JSP compilation ‘The Java Server Pages and the Servlets were ‘nitaly developed at Sun Microsystems. Opening with version 1.2 of the Java Server Page specification the JSPs have been built under the Java Community Process. There ate quite a ew JSP implicit objects that are represented by the JSP container and it could be mentioned! and iicated by the programmers Config - It gives the data of the servlet coniiguration Application ~ Data's are shared by the servlets and Java Server Pages in theapplication. Exception - Exceptions are not trapped by the codes in the application. ‘Out - The date’s are writen with the help oF ISP Writer to the response stream. Request - Here the Hypertext Transfer Protocol request the object. Response ~ Here the Hypertext Transfer Proiocol response the abject ‘Session - Its helpfill to trace the data's and information about a user from one request to another ‘request ‘There are several actions that are performed! in JSP actions. A JSP action is nothing but a XML ‘tags that invokes finctionality of the built-in web server. Some of the JSP action is given as lllows. Jsp: param - It indicates a parameter which will be added in addition to the request of the ‘existing parameters, It is used inside the jsp: params or jsp: include, jsp: forward blocks Jsp: include = Java Serviet provisionally gives the request and response off 10 the specie Java Server Page. ‘The Control will later come again to tbe existig JSP as soon as the other ISP: has complied. With the help of this the JSP code will be distrbuied among several other JSPs rather than rephea, Jsp: forward - This JSP action is used to give off the requesvresponse to the other servict or ASP. The control will not come back to the existing JSP. sp: plugin = The “ancient version of web browsers like Intemet Explorer and Netscape Navigator use various tgs to embed an applet. This action creates the definite tags thet are required for a browser to inchale an applet. Jsp: fallback - This action is used to confirm that if the browser Never gives support to applets. JSspigetProperty «it obtains a property fom the spocific Javalftean. Aspe set Property - It sets a property in the specific JavaBean ISP Tags Figure 8.3 JSP Tags 15 3. JSP scripting elements JSP scripting clements ket you insert Java code into the servlet that will be generated from the ceurent JSP page. There are three forms: Expressions of the form <%= expression %> that are evaluated and inserted into the output, Script lets of the form <% code %> that are inserted ito the Serviet’s. service method, and Declarations of the form <%! Code %> that are inserted into the body of the servket class, ‘outside of uny exiting method 4. ISP Directive A JSP Directive affects the overall structure of the servlet chiss. It usually has the following form < eli) directive attribute="value" %> However, you can ako combine muiple attribute setings for a single directive, as follows: %0@ directive attributel="valuel “attribute2="value2"..attribute="value” %> ‘There are two main types of directive: page, which kts you do things like import classes, customize the servlet superclsss, and the ike; and inchde, which lets you insert a file into the servlet ckiss at the time the JSP file is transited into a servlet. The specification alko mentions the table directive, which i not supported in JSP version 1.0, but s intended to kt ISP authors define their own tags. It is expected that this will be the main new contribution of ISP I-Imphcit ‘objects in jsp ate the objects thit are created by the coniainer automatically ark! the container makes them availible t the developers, the developer do not nced to create them explicitly, Since these objects are created aulomatically by the contamer and are accessed wing standard variables; henee, they are called implicit objects. ISP Implicit Objects are as follows: Request implicit object ‘The JSP implicit request object i an instance of a java class that implements the Javaxservlet.hup.HiipServietRequest imterice. It represents the request made by the chert, ‘The request implicit object is generally used to get request parameters, request atiribuies, header information and query string values, response implicit object ‘The JSP implicit response object i an instance of a java chs that implements: the 16 Javaxserviet.http.HttpServietResponse interfice. It represents the response to be given to the cchent. ‘The response: implicit object is generally used to set the response content type, add cookie and redirect the response. Cut implicit object ‘The JSP epic ou object & an instance of the javaxservetjsp.Jyp Writer class. It represents the ourput content 19 be sent to the client, The out implicit object is used 10. write the output content. Session implicit abject ‘The JSP implicit session object is ah instance of a java class that implements the juvaxservicthtp.HHipSession interface. It represents a client specific conversation. The session implicit. object & used to Store session state fora single user. Application. implicit object ‘The JSP impli application abject is an insane of a java chiss that implemeits the javaxservietServitContest interfice, It gives facilty for a JSP page t obtain and set informtion about the web application, in which itis runing, Exception implicit object ‘The JSP implicit exception object is an instance of the java.lang Throwable class. IL is available in ASP error pages only, It epresems the occured exception that caused the control to pass to the ISP ervor page, Config implicit object ‘The JSP. implicit config object is an instance of the java class tht javexserviet Servieonfig interface. It gives fciliy for a ISP page to obtain the i parameters available. Page irmplivit object ‘The JSP implicit page object & an instance of the java.king Object css. It represents the current JSP page. It is not advisable to use this page implicit object offen as it consumes: latge menory Page Context implicit object ‘The JSP implicit page Context object & an instance of the javax.servletjsp.PageContext abstract ‘class. It provides usc! contéxt inforniation. Also i contiiis the reference to implicit objects. v7 CHAPTER - 9 SERVLET Servkis are protocol and platform independent server-side sofware components, written in Java, ‘They nun inside a Java enabled server or application server, such as the Web Sphere Application ‘Server. Serviets are loaded and executed within the Java Virtual Machine (JVM) of the Web server or application server, in much the same way that applets are loaded and executed within the JVM of the Web client, Since serviets run inside the servers, however, they da not need a graphical user itlerfice (GUD). In this sense, servkets are abo ficekss objects, Servlets more closely resemble Common Gateway Interfice (CGN) scripts or programs than applets in terms of fimcfonalty. As in CGI programs, servlets ean respond t user events from an HTML request, and then dymamically construct an HTML response that i sent back to- the ‘client, 1) The Java Servlet API ‘The Java Servet API is a set of Java clisses which define a standard interface between a Web. cclent and a Web servet, Chemt requests are made to the Web server, which then inokes: the servlet to service the request through this intefuce. ‘The API & composed of two packages: Javaxserviet Javan servlet hip ‘The Servket interface class is the ceniral abstraction of the Java Servlet API. This class defines the methods which serviets must implement, inchiding a service ) method for the handling of requests. The Generic Serviet ckiss implements this interfice, and defines. a generic, protocol independent serviet. To write an HTTP servit for use on the Web, we will use an even More specialized class of Generic Servet called HtipServkt.HipServit provides additional methods fir the processing of HTTP requests such as GET (do Get method) andl POST (do Post method). Although our servlets may implement a service method, in most cases we will impkment the HTTP specific request handling methods of do get and do Post. 2) Serviet Life Cycle ‘The life cycle of a servlet can be categorized info four parts: Loading and Instantiation- The servet container loads the serviet during startup or when the first request is mide, The loading of the servlet depends on the attribute of 18 Web.xinl ie, If the attribute hus a positive value then the serves load with loading of the container otherwise it load when the first request comes for service: After loading, ‘ofthe servlet, the container creates the instances of the servlet Figure 9.1 Lifecyele of Servlet Initialization- After creating the instances, the serviet container calls the init () method and pisses the servet iitiaization parameters to the iit () method, The iit() must be called by the serviet container before the servt can service any request. The iniislzation parameters. persist until the serviet is destroyed. ‘The init) method is called only once throughout the li cycle of ibe servlet. The servlet will be availible for service if it is loaded successfilly otherwise the ‘serviet container unloads the servlet. Servicing the Request: After successfilly completing the initialization process, the servlet ‘will be avaible for service, Servet creates separate threads for each request. The servlet ‘container calls the service () method tor servicing any request. The service () method determines ibe kind of request and call) the appropriate method. (doGet () or doPost ()) for handling. the request and sends response to the client using the methods of the response object. Destroying the Servlet- If the servict is no longer needed for servicing any request, the serviet container calls the destroy () method, Like the imt() method this method is ako. culled ‘only onee throughout the lie eyeke of the servket, Calling the destroy() method indicates 10 the ‘servlet container not to sent the any request ior service and the servlet releases alll the resources associated with it. Java Viral Machine claims for the memory associated with the resources for garbage collection 19 CHAPTER - 10 APPLET Work An applet i a Java program that mins ina Web browser, An appkt can be a filly functional Java application because it has the entire Java API at is disposal ‘There are some important differences between an applet and a standalone Java application, inching the following ~ An applet is a Java chss that extends the java.applet. Applet class. A mind) method i not invoked on an applet, and an appket ekss will not define main(), Applets are designed to be embedded within an HTML page. When a user views an HTML page that coninins an applet, the code for the applet i downloaded to the user's machine. A JVM is required to view an appt, The JVM can be either a phig-in of the Web browser or a ‘separate runtime environme: ‘The JVM on the user's machine ereates an instance of the applet clss and invokes various methods during the apple's lifetime. Appts hive strict security rules that are enforced by the Web browser, The security of an applet is offen referred 0 as sandbox security, comparing the applet to a chil playing in a sandbox with various rules thit must be folowed, Other chsses that the applet needs can be downloaded in a singk: Java Archive (JAR) fil. Life Cycle of an Applet Four methods in the Applet class give you the ffamework on which you buikl amy serious applet. 1) init — This method is imended for whatever initialization is need for your applet. It is culled afer the param tags inside the applet tag have been processed. 2) start — This method is automatically called after the browser calls the init method. It is ais. ‘called whenever the user retums to the page containing the applet after having gone off to other pas. 3) stop — This method & automatically called when the user moves off the page on which the ‘appkt sits. It can, therefore, be called repeatedly in the same applet. 4) destroy - Ths method it only called when the browser shuts down normnily. Because applets are meant to live on an HTML page, you shoukl not normally keave resources. behind afer auser leaves the page that contains the applet. 20 5) paint — Invoked immediately afer the start() method, and abo any time the applet needs to fepaint itself in the browser, The: paint() method is actually inherited from the java.awt, A "Hello, Workl” Applet Following i asimpk applet named HelloWorkApplet java ~ Example import javaappkt; import javaawt*; public class HelloWorldAppkt extends Applet { public void paint (Graphics g) { gdrawString (ete Work, 25, $0); ‘Created a Text Editor Interface Application using the Java Applet. ‘This allows greater flexibility than HTML in terms of the layout and functionality. Having the knowledge of Java, HTML, XML, XSL, and UML proved to be immensely s had ako buik up the student's coniidence in dealing with ature-rich, user-friendly Windows application 2 CHAPTER = 11 Project My project is belongs to the intemet banking in which user can access their bank: account information and some transaction, “Internet banking” refers to systems that erable bank customers to acess accounts and general information on bank products and services through a personal computer (PC) or other inteligent device. ‘This project aims at creation of a secure Intemet banking system. This will be accessible 10 all ‘customers who have a valid User Id and Password. This is sn approach to provide an opportunity to the customers to have some important transactions to be done fom where they are at present Without moving to bank. In this project we are going to deal the existing ficts in the bank ic. the transactions which takes phice between customer and bank, We provide a real time environment for the existing system in the bank. We deal in the method transaction in the bank can be made fiister and casier that is our project & an internet based computerized approach towards banking The Project SAFE AND SECURE INTERNET BANKING SYSTEM provides comprebensive eketronic find transfer and payment solutions that enable thousands of Citizens, Financial Institutions and hundreds of businesses the convenience of receiving and transferring their finds ‘online, Its fist, easy and puts you in complete contral — you decide who to tansfer finds, checking of ibe account detais. Receive and pay all your paper bills at one site —at your bank, credit union. Functions of Intemet Banking: FigH1.1 Duta flow diagrim of intemet barking 2 Registration ofa user ‘To become a valid user all the user have to regiter om the system so they have their individual idemity in the system, So every wer have different. entity. ee a LoginsBei BANK Fig 11-2. registration page Login to Account:- A login, logging in or bguing on is the emering of identiier iaormation into a system by a user in onder to access that system (eg, a computer or a websie). It is an integral part of computer securty procedures. To aceess all the barkix Tight provided by the bank. rights user have to logged in the system so that he/she can use all the Leginsees Bat Fig. 11.3 Login page 23 Transfer money:- ‘Transfer money is a fimetion in which we can send finds to another bank by just providing, the account no if another user. Fig.11.4 transfer money web page CONCLUSION ‘This taining focused upon increasing our knowledge and interest in toward the java, Because java is most iteresting and most used language in these days. We kart how to create a web ‘sites and web pages. It was a great experience. It increases our practical skill that are the main which we karnt in the training session, ‘The Advance Java problem set, a step-by-step approach used by the student, has ensured tht the student aequired enough knowledge required in various aspeets fir all the stages, before proceeding on. During the 5 months attachment in Hewlett-Packard Lab, the student had done tbe following: Designed a business model (represented in XML) that enabled information in the form of XML documents to be shared between businesses. Implemented: a GUI that allowed a user 1 ew and modify the infomation in an XML document. XSL was used to transform XML into HTML for display in a browser. Wrote a Java Servet code to handle the file access application required by the web client. These are application that cannot be handled by a Java Applet. Impkinenied the Text Editor Interface (chen!) using HTML, a straightforward lngmge used to display certain imerfice program onto a web browser. Designed a class diagram using the Unified Modeling Langunge (UML) that defines the classes and their behavior ‘The application demonstrate the way to develop an onine banking system by using interactive ‘web client by using JSP, Servet with more secure way to access &encapsulate database by EJB component, This means the application server easily deployable and accessible as

You might also like