A PRACTICAL TRAINING REPORT ON
“North-Western Railway, Ajmer”
Submitted in the partial fulfillment of the award of
BACHELOR OF TECHNOLOGY [ Rajasthan Technical University, Kota ] In COMPUTER ENGINEERING 2011-12
Submitted By: ABHISHEK VIJAYVARGIA College No: 08CE06 Final Year (VII Sem)
Department of Computer Engineering
Govt. Engineering College, Ajmer 1|Page
ACKNOWLEDGEMENT
I have also taken training at Supervisors Training Centre (North.Western. Railway, Ajmer Division), Ajmer. It was highly educative and interactive to take training at this centre. In technical field, theoretical knowledge is incomplete without practical knowledge and I couldn’t find any place better than this to update myself. I am highly thankful to our training Coordinator as well Principal of STC Mr. A. K. Abrol Sir to grant me permission to take training at such a coveted industry. And rewarding me by extra certificate for project, Apart from him, there was always a friendly guidance from Mr. Shakti Singh Sir, for the better maanagement of the project. I would also like to take this opportunity to acknowledge the guidance and support From Mrs. Prakriti Trivedi (H.O.D. of CS & IT Engg.) and Mr. Dinesh Khunteta sir (Seminar coordinator) for undergoing training at a reputed public sector company like S.T.C.
ABHISHEK VIJAYVARGIA B.TECH,VII SEM (08CE06)
2|Page
ABSTRACT
I have done my Summer Training under Indian Railways Supervisor Training Center, Information Technology Department, Ajmer Division. I have worked on various Web technologies used in the project provided to me to work upon, under professional guidance. The project, I worked on is based on the information about Supervisor Training Center, Northern Western Railway, Ajmer. We have learn many things like basic web design fundamentals, creating useful and reusable design patterns by Templets, proper use of xHTML and CSS, efficient implementation of javascripts and benefits and workflow of AJAX. We use xml data source for storing data for our future needs. We use CGI and realize that it is not so much efficient and then we shift over to java servlets in which we use MVC architecture and struct framework. We then focus on jsp pages and it’s syntax. Finally we learn RIA to make our design more versatile and reusable. The course is mostly focused on java server pages and RIA. On the above technologies our project is based. The project is about a “National Railway Museum”. This project is based on the railway museum. Various types of rail engines are included in a photo gallery. Railway history and Palace of wheels also included in the project.
3|Page
TABLE OF CONTENTS S. No.
Contents
1.
Acknowledgement
2.
Abstract
3.
Table of Contents
4.
List of Tables
5.
List of figures
6.
Chapter 1
Introduction To Northern Western Railway and STC Office Ajmer
7.
4|Page
1.1
Northern Western Railway
1.2
System Technical School
1.3
Aims
1.4
Need Of Training
1.5
Objectives
1.6
Labs
Chapter 2
Basic Web Design Fundamentals
2.1
URL
2.2
Domain Name System
Page No.
8.
9.
10.
5|Page
2.3
Common Web Protocol
2.4
HTML and CSS
2.5
XML
2.6
Java script
2.7
AJAX
2.8
Application Programming Interface
Chapter 3
Web Application Technologies
3.1
HTTP Client Server Architecture
3.2
HTTP Request Method
3.3
Execution of CGI Program
3.4
MVC Architecture
Chapter 4
JAVA Servlet
4.1
Introduction
4.2
Advantage over CGI
4.3
Servlet Life Cycle
4.4
Struct Framework
Chapter 5
JSP
5.1
Introduction
11.
12.
5.2
JSP Page Life Cycle
5.3
Components of JSP
5.4
Benefits Of JSP
Chapter 6
Rich Internet Application
6.1
Java FX
6.2
Microsoft Silverlight
6.3
ActionScript 3.0
6.4
Flash Builder
Chapter 7
Railway Museum
7.1
Home Page
7.2
Palace Of Wheels
7.3
Feedback
7.4
History
7.5
Photo Gallery
13.
Conclusion
14.
Bibliography & References
6|Page
LIST OF FIGURES
7|Page
FIGURE NO.
TITLE OF FIGURE
Figure 2(a)
Domains
Figure 2(b)
Domain Name System
Figure 2(c)
Common Web Protocol
Figure 2(d)
HTML And CSS
Figure 2(e)
Benefits Of JavaScript
Figure 2(f)
AJAX Application Workflow
Figure 2(g)
Application Programming Interface
Figure 3(a)
HTTP Client Server Architecture
Figure 3(b)
Execution Of CGI Program
Figure 3(c)
CGI Request And Response
Figure 3(d)
MVC Architecture
Figure 4(a)
JAVA Servlet
Figure 4(b)
Advantage over CGI
Figure 4(c)
Servlet Life Cycle
Figure 4(d)
Struct Framework
Figure 4(e)
Struct Class Mapping
PAGE NO.
8|Page
Figure 5(a)
JSP Page Life Cycle
Figure 5(b)
JSP Classes
Figure 6(a)
Rich Internet Application
Figure 7(a)
Homepage
Figure 7(b)
Palace On Wheels
Figure 7(c)
Feedback
Figure 7(d)
History- I
Figure 7(e)
History - II
Figure 7(f)
Photo Gallery- I
Figure 7(g)
Photo Gallery - II
LIST OF TABLES TABLE NUMBER
DESCRIPTION
Table 1.1
Labs in STC Office Ajmer
Table 2.1
Development of HTML and xHTML
Table 5.1
JSP Tages
9|Page
PAGE No
Chapter 1 INTRODUCTION TO NORTH-WESTERN RAILWAYS AND STC , AJMER
1.1 NORTH WESTERN RAILWAYS : North Western Railways which is overseen by the Ministry of Railways of the Government of India came being on 1st October, 2002.It was carved out of 2 divisions each from Northern and Western Railways. Jaipur Division: This division was formed after merging parts of BB&CI, Jaipur State Railways and Rajputana Malwa Railway. Jaipur Division serves the states of Rajasthan, Uttar Pradesh and Haryana. The total no. of stations on this division are 128 and the total no. of trains run are 146. Jaipur station alone deals with 88 BG & 22 MG trains and 35,000 passengers in a day. Bikaner Division: This division was established in 1924 and it serves the states of Rajasthan, Punjab and Haryana. The total no. of situations in these divisions is 198 and the total no. of trains dealt with are 142 including the rail bus and BG and MG mail/exp and passenger trains. Bikaner division has 12 Computerized Passenger Reservation System functioning. The staff strength of this division in all categories is 13728. Jodhpur Division: This division was up in the year 1882 and it consists primarily of semi–urban districts of Rajasthan. It covers areas of Jodhpur, Pali Marwar, Nagaur Jalore, Barmer, Jaisalmer. It 10 | P a g e
also covers certain districts of Gujarat state. This division also serves certain sensitive areas of Rajasthan such as Jaisalmer, Barmer and Pokaran. This division has a total of 144 stations and deals with 92 trains in the inward and outward directions. Fifteen Computerized Passenger Reservation System Centers exist over this division. The staff strength of this division in all categories is 10231. Ajmer Division: This division is spread over the states of Rajasthan and Gujarat. It is predominantly a cement loading division as many cement plants of Rajasthan are located within the jurisdiction of Ajmer. This division has 130 stations and the total no. of trains run over the division amounts to 36 in both the passenger and mail/exp category. At present there are 12 Computerized Passenger Reservation System Centers functioning over this division. The staff strength of this division in all categories is 9046. 1.2 SYSTEM TECHNICAL SCHOOL, AJMER System Technical School Ajmer, renamed as Supervisors Training Centre, was inaugurated on
10th of July 1957. Ajmer City was chosen for establishing a Supervisors
Training Centre, as it is the only city where all the important workshops of the then Western Railway are situated i.e. Diesel Locomotive workshop, Wagon shop, Carriage shop, Electrical Power House, Electric Production Workshop and Signal workshop. Supervisors Training Centre, Ajmer is one of the most prestigious training centre of Indian Railways. It has the pride of imparting training to all Supervisors of North Western Railway and Western Railway of Mechanical & Electrical Departments.
1.3 AIMS
Our country has a tremendous scope for continuous growth in the field of Railway transportation that too with the positive competition with road transportation. Hence technology up-gradation, improved productivity, enhanced safety etc. are the keys to take over the challenge of growth in the true sprit. The training is the only mode which can
11 | P a g e
prepare the newly inducted railway supervisors for making them a positive asset to the organization.
More over the refresher courses are meant for updating the knowledge of the supervisors representing the middle management as per the latest technical instructions from R.D.S.O. and Railway Board from time to time. The supervisors can even have an idea that why and on what ground the instructions have been issued to enable them to implement the same in the field in the best of its sprit.
Further the field units are having their own needs for imparting training in various fields like Welding Technology, Supervisors Development Programme, Computer know how, Internal Audit Course plan for ISO as well as pre-selection training of the reserved candidates appearing in LDCE examination.
1.4 NEED FOR TRAINING Training is an investment and not expenditure: A trained man is an asset. The need of training has become more essential with the development of Electric locomotive, Diesel locomotives, Super Fast Trains, Introduction of rolling stocks with Air brake system etc. Training is always carried out for a purpose. It is the means of maintenance and improving the level of performance of a trainee by systematically increasing the ability and aptitude of the trainee by giving him planned tasks, coupled with continuous appraisal, advice and counseling. Growing transportation needs of our country, productivity of manpower employed, modern technologies, knowledge of safety knowledge of our production system and Railway Organization Present Status of Railways are all co related terms, which need a proper and serially organized and systematized training. Such training can only be imparted if we have a plan for this.
12 | P a g e
1.5 OBJECTIVES
The following are the main objectives of Supervisors Training Centre, Ajmer :-
To impart induction training to newly recruited supervisor from RRBs. To impart training to the candidates inducted as supervisors on the basis of departmental examination. To conduct courses as per need of the divisions and workshops like supervisor development courses, courses of contract management, courses on stores procurement, courses on computer, pre-selection courses for the reserved candidates. To conduct refresher courses for the posted supervisors to update their knowledge on the basis of recent technological developments induced in the system.
1.6 Labs 1.
C&W Lab
2. RAC Lab
3. Computer Lab
4. Welding lab
5. Diesel Lab
6. Electrical Lab
So to manage all information of various labs and trainees Computerized System is required Which keeps all records of labs and faculties, trainees.
13 | P a g e
CHAPTER 2 BASIC WEB DESIGN FUNDAMENTALS 2.1 URL a Uniform Resource Locator or Universal Resource Locator (URL) is a character string that specifies where a known resource is available on the Internet and the mechanism for retrieving it. Every URL consists of some of the following: the scheme name (commonly called protocol), followed by a colon, two slashes, then depending on scheme, a domain name (alternatively, IP address), a port number, the path of the resource to be fetched or the program to be run, then, for programs such as Common Gateway Interface (CGI) scripts and a query string The syntax is scheme://domain:port/path?query_string
Fig.2(a)
14 | P a g e
2.2 DOMAIN NAME SYSTEM The Domain Name System (DNS) is a hierarchical distributed naming system for computers, services, or any resource connected to the Internet or a private network. It associates various information with domain names assigned to each of the participating entities. Most importantly, it translates domain names meaningful to humans into the numerical identifiers associated with networking equipment for the purpose of locating and addressing these devices worldwide. An often-used analogy to explain the Domain Name System is that it serves as the phone book for the Internet by translating humanfriendly computer hostnames into IP addresses.
Fig. 2(b)
2.3 COMMON WEB PROTOCOL
A.) HTTP (HyperText Transfer Protocol ):
It is a standard over the internet for
transferring data. Browser is an HTTP Client which sends request to the HTTP server which gives response back to the client. HTTP is an stateless protocol which makes it more efficient to work. 15 | P a g e
B.) FTP (File Transfer Protocol): Typically used to transfer large files and is ideal for uploading and downloading files C.) SMTP (Simple Mail Transfer Protocol ): The standard web protocol for sending emails. POP (Post Office Protocol) is used to receive emails. D.) RTP (Real Time Transfer Protocol): Standard Protocol for serving audio and video on the web.
Fig. 2(c)
2.4 HTML AND CSS HTML: Hypertext Markup Language (HTML) is the markup language for web pages. HTML elements are the basic building-blocks of WebPages. HTML is written in the form of HTML elements consisting of tags, enclosed in angle brackets (like ), within the web page content. HTML tags normally come in pairs like
and
. The first tag in a pair is the start tag, the second tag is the end tag (they are also called opening tags and closing tags). In between these tags web designers can add text, tables, images, etc. The purpose of a web browser is to read HTML documents and compose them into visible or audible web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page. HTML elements form the building blocks of all websites. HTML allows images and objects to be embedded and can be used to create interactive forms. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. It can embed scripts in languages such as JavaScript which affect the behavior of HTML WebPages. 16 | P a g e
CSS: Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML. CSS is designed primarily to enable the separation of document content (written in HTML or a similar markup language) from document presentation, including elements such as the layout, colors, and fonts. This separation can improve content accessibility, provide more flexibility and control in the specification of presentation characteristics, enable multiple pages to share formatting, and reduce complexity and repetition in the structural content (such as by allowing for tableless web design). CSS can also allow the same markup page to be presented in different styles for different rendering methods, such as on-screen, in print, by voice. Name
Version Year
Descrription
HTML
2.0
1995
Standard Specification
HTML
3.2
1997
Browsers Start Supporting
HTML
4.0
1998
More Browsers Supporting it
xHTML 1.0
2000
Designers Approch
xHTML 2.0
2001-2009
Structural Modification
HTML
2010
Future Possibilities
5.0
Table 2.1
17 | P a g e
Fig. 2(d)
2.5 XML (Extensible Markup Language )
A semantic markup language containing rules for defining document structure and data. The design goals of XML emphasize simplicity, generality, and usability over the Internet. It is a textual data format with strong support via Unicode for the languages of the world. Although the design of XML focuses on documents, it is widely used for the representation of arbitrary data structures, for example in web services. Common use of XML: A.) RSS Feeds – allow for the syndication of online content. B.) AJAX Application – XML often serves as a way to store and write data. C.) Flash – XML is used to move data in or out to the flash application. D.) External APIs – XML is used to expose API data.
18 | P a g e
2.6 JAVA SCRIPT
A scripting language used to add functionality and interactivity to the web site. JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. •
JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages
•
JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
•
JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element
•
JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing
19 | P a g e
•
JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser
•
JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer
Fig. 2(e)
2.7 AJAX (Asynchronous JavaScript and XML) Ajax is a group of interrelated web development methods used on the client-side to create interactive web applications. With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data is usually retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not needed (JSON is often used instead), and the requests don't need to be asynchronous.
20 | P a g e
Fig. 2(f)
2.8 APPLICATION PROGRAMMING INTERFACE
An application programming interface (API) is a particular set of rules ('code') and specifications that software programs can follow to communicate with each other. It serves as an interface between different software programs and facilitates their interaction, similar to the way the user interface facilitates interaction between humans and computers. An API can be created for applications, libraries, operating systems, etc., as a way of defining their "vocabularies" and resources request conventions (e.g. function-calling conventions).
Fig. 2(g)
21 | P a g e
CHAPTER 3 WEB APPLICATION TECHNOLOGIES HyperText Transfer Protocol, the underlying protocol used by the World Wide Web. HTTP defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands. For example, when you enter a URL in your browser, this actually sends an HTTP command to the Web server directing it to fetch and transmit the requested Web page. The other main standard that controls how the World Wide Web works is HTML, which covers how Web pages are formatted and displayed. HTTP is called a stateless protocol because each command is executed independently, without any knowledge of the commands that came before it. This is the main reason that it is difficult to implement Web sites that react intelligently to user input. This shortcoming of HTTP is being addressed in a number of new technologies, including ActiveX, Java, JavaScript and cookies. 3.1 HTTP Client Server Architecture HTTP functions as a request-response protocol in the client-server computing model. In HTTP, a web browser, for example, acts as a client, while an application running on a computer hosting a web site functions as a server. The client submits an HTTP request message to the server. The server, which stores content, or provides resources, such as HTML files, or performs other functions on behalf of the client, returns a response message to the client. A response contains completion status information about the request and may contain any content requested by the client in its message body. The HTTP protocol is designed to permit intermediate network elements to improve or enable communications between clients and servers. High-traffic websites often benefit from web cache servers that deliver content on behalf of the original, so-called origin server to improve response time. HTTP proxy servers at network boundaries facilitate 22 | P a g e
communication when clients without a globally routable address are located in private networks by relaying the requests and responses between clients and servers.
Fig. 3(a) 3.2 HTTP REQUEST METHODS HTTP defines nine methods (sometimes referred to as "verbs") indicating the desired action to be performed on the identified resource. What this resource represents, whether pre-existing data or data that is generated dynamically, depends on the implementation of the server. Often, the resource corresponds to a file or the output of an executable residing on the server. HEAD Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content. GET Requests a representation of the specified resource. Requests using GET (and a few other HTTP methods) "SHOULD NOT have the significance of taking an action other than retrieval". The W3C has published guidance principles on this distinction, saying, "Web application design should be informed by the above principles, but also by the relevant limitations." See safe methods below. POST
23 | P a g e
Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both. PUT Uploads a representation of the specified resource. DELETE Deletes the specified resource. TRACE Echoes back the received request, so that a client can see what (if any) changes or additions have been made by intermediate servers. OPTIONS Returns the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource. CONNECT Converts the request connection to a transparent TCP/IP tunnel, usually to facilitate SSL encrypted communication (HTTPS) through an unencrypted http. PATCH Is used to apply partial modifications to a resource 3.3 EXECUTION OF CGI PROGRAMS Early in the development of HTML, the designer created a mechanism to permit a user to invoke a program on a web server. This mechanism is called Common Gateway Interface (CGI). When a web site includes CGI processing, this is called web application. Usually the browser needs to send data to the CGI program on the server. The CGI specification defines how the data is packaged and sent in the http request to the server. This data is usually typed into the web browser in an HTML form. The URL determines which CGI program to execute. This might be a script or an executable file. The CGI program parse the CGI data and generates a response. The CGI
24 | P a g e
response is sent back to the web server, which wraps the response in HTTP response. The HTTP response is sent back to the web browser.
Fig. 3(b) At runtime a CGI program is launched by the web server as a separate OS shell. The shell includes an OS environment and process to execute code of the CGI program, which resides in servers file system. However this will create much load on the server because each request create a separate OS shell for communication. So load increase on the server.
25 | P a g e
Fig. 3(c)
Advantages of CGI Script
CGI programs supports good web browser compatibility as compared to other technologies .While main advantage you will notice with the CGI that it has no limitation of browser and firewall. It means CGI is language Independent . -Perl is the language of choice for CGI development because of its string processing capabilities and cross-platform support. -CGI is easy to learn and use. Infact ere are many commercial and freely available scripts that provide shopping carts, credit card processing, template systems, discussion forums, and so on. -Cgi Doesn’t require any special library to create a CGI program, or write programs using a particular API.
26 | P a g e
-CGI supports many development languages, including those that can be compiled to executable code. This is important for companies that need to distribute software applications for the Web, but do not want to distribute their source code. Disadvantage of CGI script -CGI programs are slow since they need to fork a new process for every HTTP request and the database connection must be reopened for the next instance of the program, which is quite costly. It means greatest disadvantage of the CGI scripts is that they put excessive pressure or loads on the server. Programs which are poorly written create much problem.
3.4 MVC ARCHITECTURE Model–view–controller (MVC) is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns). The model manages the behaviour and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react. The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
27 | P a g e
The controller receives user input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input. MVC is often seen in web applications where the view is the HTML or XHTML generated by the app. The controller receives GET or POST input and decides what to do with it, handing over to domain objects (i.e. the model) that contain the business rules and know how to carry out specific tasks such as processing a new subscription, and which hand control to (X)HTML-generating components such as templating engines, XML pipelines, Ajax callbacks, etc. The model is not necessarily merely a database; the 'model' in MVC is both the data and the business/domain logic needed to manipulate the data in the application. Many applications use a persistent storage mechanism such as a database to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the model. Models are not data access objects; however, in very simple apps that have little domain logic there is no real distinction to be made. Active Record is an accepted design pattern that merges domain logic and data access code — a model which knows how to persist itself.
Fig. 3(d
28 | P a g e
CHAPTER 4 JAVA SERVLETS 4.1 INTRODUCTION A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers. Thus, it can be thought of as a Java Applet that runs on a server instead of a browser. A Servlet is a Java class in Java EE that conforms to the Java Servlet API, a protocol by which a Java class may respond to requests. They are not tied to a specific client-server protocol, but are most often used with the HTTP protocol. Therefore, the word "Servlet" is often used in the meaning of "HTTP Servlet". Thus, a software developer may use a servlet to add dynamic content to a Web server using the Java platform. The generated content is commonly HTML, but may be other data such as XML. Servlets are the Java counterpart to non-Java dynamic Web content technologies such as CGI and ASP.NET. Servlets can maintain state in session variables across many server transactions by using HTTP cookies, or URL rewriting.
29 | P a g e
Fig. 4(a) To deploy and run, the Apache Tomcat Server may be used. It is an open source servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a "pure Java" HTTP web server environment for Java code to run. The servlet API, contained in the Java package hierarchy javax.servlet, defines the expected interactions of a Web container and a servlet. A Web container is essentially the component of a Web server that interacts with the servlets. The Web container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights. A Servlet is an object that receives a request and generates a response based on that request. The basic servlet package defines Java objects to represent servlet requests and responses, as well as objects to reflect the servlet's configuration parameters and execution environment. The package javax.servlet.http defines HTTP-specific subclasses of the generic servlet elements, including session management objects that track multiple requests and responses between the Web server and a client. Servlets may be packaged in a WAR file as a Web application. Servlets can be generated automatically from JavaServer Pages (JSP) by the JavaServer Pages compiler. The difference between Servlets and JSP is that Servlets typically embed HTML inside Java code, while JSPs embed Java code in HTML. While the direct usage of Servlets to generate HTML (as shown in the example below) is relatively rare nowadays, the higher level MVC web framework in Java EE (JSF) still explicitly uses the Servlet technology for the low level request/response handling via the FacesServlet. A somewhat older usage is to use servlets in conjunction with JSPs in a pattern called "Model 2", which is a flavor of the model-view-controller pattern
30 | P a g e
4.2 ADVANTAGE OVER CGI The advantages of using servlets are their fast performance and ease of use combined with more power over traditional CGI(Common Gateway Interface). Traditional CGI scripts written in Java have a number of disadvantages when it comes to performance: When an HTTP request is made, a new process is created for each call of the CGI script. This overhead of process creation can be very system-intensive, especially when the script does relatively fast operations. Thus, process creation will take more time than CGI script execution. Java servlets solve this, as a servlet is not a separate process. Each request to be handled by a servlet is handled by a separate Java thread within the Web server process, omitting separate process forking by the HTTP daemon. Simultaneous CGI request causes the CGI script to be copied and loaded into memory as many times as there are requests. However, with servlets, there are the same amount of threads as requests, but there will only be one copy of the servlet class created in memory that stays there also between requests. Only a single instance answers all requests concurrently. This reduces memory usage and makes the management of persistent data easy. A servlet can be run by a servlet engine in a restrictive environment, called a
sandbox. This is similar to an applet that runs in the sandbox of the Web browser. This makes a restrictive use of potentially harmful servlets possible.
31 | P a g e
Fig. 4(b) 4.3 SERVLET LIFE CYCLE 1. The container calls the no-arg constructor. 2. The Web container calls the init() method. This method initializes the servlet and must be called before life of a servlet, the init() method is called only once. 3. After initialization, the servlet can service client requests. Each request is serviced in its own separate thread. The Web container calls the service() method of the servlet for every request. The service() method determines the kind of request being made and dispatches it to an appropriate method to handle the request. The developer of the servlet must provide an implementation for these methods. If a request for a method that is not implemented by the servlet is made, the method of the parent class is called, typically resulting in an error being returned to the requester. 4. Finally, the Web container calls the destroy() method that takes the servlet out of service. The destroy() method, like init(), is called only once in the lifecycle of a servlet.
Fig. 4(c)
32 | P a g e
4.4 STRUCT FRAMEWORK Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model-view-controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May, 2000. Formerly located under the Apache Jakarta Project and known as Jakarta Struts, it became a top-level Apache project in 2005.
Fig. 4(d)
In a standard Java EE web application, the client will typically submit information to the server via a web form. The information is then either handed over to a Java Servlet that processes it, interacts with a database and produces an HTML-formatted response, or it is given to a JavaServer Pages (JSP) document that intermingles HTML and Java code to achieve the same result. Both approaches are often considered inadequate for large projects because they mix application logic with presentation and make maintenance difficult. The goal of Struts is to separate the model (application logic that interacts with a database) from the view (HTML pages presented to the client) and the controller 33 | P a g e
(instance that passes information between view and model). Struts provides the controller (a servlet known as ActionServlet) and facilitates the writing of templates for the view or presentation layer (typically in JSP, but XML/XSLT and Velocity are also supported). The web application programmer is responsible for writing the model code, and for creating a central configuration file struts-config.xml that binds together model, view and controller. Requests from the client are sent to the controller in the form of "Actions" defined in the configuration file; if the controller receives such a request it calls the corresponding Action class that interacts with the application-specific model code. The model code returns an "ActionForward", a string telling the controller what output page to send to the client. Information is passed between model and view in the form of special JavaBeans. A powerful custom tag library allows it to read and write the content of these beans from the presentation layer without the need for any embedded Java code. Struts is categorized as a request-based web application framework. Struts also supports internationalization by web forms, and includes a template mechanism called "Tiles" that (for instance) allows the presentation layer to be composed from independent header
34 | P a g e
CHAPTER 5 JAVA SERVER PAGES
5.1 INTRODUCTION JavaServer Pages (JSP) is a Java technology that helps software developers serve dynamically generated web pages based on HTML, XML, or other document types. Released in 1999 as Sun's answer to ASP and PHP, JSP was designed to address the perception that the Java programming environment didn't provide developers with enough support for the Web. To deploy and run, a compatible web server with servlet container is required. The Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems and the JCP must both be met by the container. Architecturally, JSP may be viewed as a high-level abstraction of Java servlets. JSP pages are loaded in the server and are operated from a structured special installed Java server packet called a Java EE Web Application, often packaged as a .war or .ear file archive. JSP allows Java code and certain pre-defined actions to be interleaved with static web markup content, with the resulting page being compiled and executed on the server to deliver an HTML or XML document. The compiled pages and any dependent Java libraries use Java bytecode rather than a native software format, and must therefore be executed within a Java virtual machine (JVM) that integrates with the host operating system to provide an abstract platform-neutral environment. JSP syntax is a fluid mix of two basic content forms: scriptlet elements and markup. Markup is typically standard HTML or XML, while scriptlet elements are delimited blocks of Java code which may be intermixed with the markup. When the page is requested the Java code is executed and its output is added with the surrounding markup to create the final page. JSP pages must be compiled to Java bytecode classes before they 35 | P a g e
can be executed, but such compilation is needed only when a change to the source JSP file has occurred. Java code is not required to be complete (self contained) within its scriptlet element block, but can straddle markup content providing the page as a whole is syntactically correct (for example, any Java if/for/while blocks opened in one scriptlet element must be correctly closed in a later element for the page to successfully compile). This system of split inline coding sections is called step over scripting because it can wrap around the static markup by stepping over it. Markup which falls inside a split block of code is subject to that code, so markup inside an if block will only appear in the output when the if condition evaluates to true; likewise markup inside a loop construct may appear multiple times in the output depending upon how many times the loop body runs. The JSP syntax adds additional XML-like tags, called JSP actions, to invoke built-in functionality. Additionally, the technology allows for the creation of JSP tag libraries that act as extensions to the standard HTML or XML tags. JVM operated tag libraries provide a platform independent way of extending the capabilities of a web server. Note that not all commercial Java servers are Java EE specification compliant. 5.2 JSP PAGE LIFE CYCLE A.)
First the jsp page is translated to its respective servlet code.
B.)
Then the servlet is compiled and the bytecode is generated.
C.)
Servlet Class is loaded.
D.)
Servlet instace is created.
E.)
jspinit() method is called for initialization.
F.)
_jspService() method is used while the page is in execution.
G.)
jspDestroy() method is used to destroy it and remove it from memory.
36 | P a g e
Fig. 5(a)
5.3 COMPONENTS OF JSP JSP syntax is almost similar to XML syntax. The following general rules are applicable to all JSP tags. 1. Tags have either a start tag with optional attributes, an optional body, and a matching end tag or they have an empty tag possibly with attributes. 2. Attribute values in the tag always appear quoted. The special strings ' and " can be used if quotes are a part of the attribute value itself. Any whitespace within the body text of a document is not significant, but is preserved, which means that any whitespace in the JSP being translated is read and preserved during translation into a servlet. The character \ can be used as an escape character in a tag, for instance, to use the % character, \% can be used. JavaServer Pages are text files that combine standard HTML and new scripting tags. JSPs look like HTML, but they get compiled into Java servlets the first time they are invoked. The resulting servlet is a combination of HTML from the JSP file and embedded dynamic content specified by the new tags. Everything in a JSP page can be divided into two categories: 37 | P a g e
1. Elements that are processed on the server 2. Template data or everything other than elements, that the engine processing the JSP engines. Element data or that part of the JSP which is processed on the server, can be classified into the following categories: 1. Directives 2. Scripting elements 3. Standard actions JSP directives serve as messages to the JSP container from the JSP. They are used to set global values such as class declaration, methods to be implemented, output content type, etc. They do not produce any output to the client. All directives have scope of the entire JSP file. That is, a directive affects the whole JSP file, and only that JSP file. Directives are characterized by the @ character within the tag and the general syntax is: The three directives are page, include and taglib. Scripting
Element Example
Comment
<%--comment--%>
Directive
<%@ directive%>
Declaration
<%! Declaration >
Scriptlet
<%code>
Expression
<%= expression %>
Table 5(i) 38 | P a g e
Scripting elements are used to include scripting code (Java code) within the JSP. They allow to declare variables and methods, include arbitrary scripting code and evaluate an expression. The three types of scripting element are: Declaration, Scriptlets and Expressions. A declaration is a block of Java code in a JSP that is used to define class-wide variables and methods in the generated class file. Declarations are initialized when the JSP page is initialized and have class scope. Anything defined in a declaration is available throughout the JSP, to other declarations, expressions or code. A scriptlet consists of one or more valid Java statements. A scriptlet is a block of Java code that is executed at request-processing time. A scriptlet is enclosed between "<%" and "%>". What the scriptlet actually does depends on the code, and it can produce output into the output stream to the client. Multiple scriptlets are combined in the compiled class in the order in which they appear in the JSP. Scriptlets like any other Java code block or method, can modify objects inside them as a result of method invocations. An expression is a shorthand notation for a scriptlet that outputs a value in the response stream back to the client. When the expression is evaluated, the result is converted to a string and displayed, An expression is enclosed within <%= and %> "<%=" and "%>". If any part of expression is an object, the conversion is done using the toString() method of the object. Standard actions are specific tags that affect the runtime behavior of the JSP and affect the response sent back to the client. The JSP specification lists some standard action types to be provided by all containers, irrespective of the implementation. Standard actions provide page authors with some basic functionality to exploit; the vendor is free to provide other actions to enhance behavior.
39 | P a g e
Fig. 5(b)
5.4 BENEFITS OF JSP One of the main reasons why the JavaServer Pages technology has evolved into what it is today and it is still evolving is the overwhelming technical need to simplify application design by separating dynamic content from static template display data. Another benefit of utilizing JSP is that it allows to more cleanly separate the roles of web application/HTML designer from a software developer. The JSP technology is blessed with a number of exciting benefits, which are chronicled as follows: 1. The JSP technology is platform independent, in its dynamic web pages, its web servers, and its underlying server components. That is, JSP pages perform perfectly without any hassle on any platform, run on any web server, and web-enabled application server. The JSP pages can be accessed from any web server. 2. The JSP technology emphasizes the use of reusable components. These components can be combined or manipulated towards developing more purposeful components and page design. This definitely reduces development time apart from the At development time, JSPs are very different from Servlets, however, they are precompiled into Servlets at run time and executed by a JSP engine which is installed on a Web-enabled application server such as BEA WebLogic and IBM WebSphere.
40 | P a g e
CHAPTER 6 RICH INTERNET APPLICATION RIAs or Rich Internet Application are web applications that work like fully fledged desktop application in many ways. They are delivered to the user through a site specific browser either through a plug or a virtual machine. A site-specific browser is a browser minus the menus and controls. With more and more services moving to the cloud and with increased internet connectivity among mobile devices RIAs are becoming increasingly popular on desktop as well as mobile devices. RIAs provide better ways of interacting with the users and with better efficiency than ever before. In contrast RIAs let you perform in-line editing, drag and drop items or interact directly with the elements. Popular browser based RIAs include Flickr, Google Maps and eBay.
Rich Internet Applications (RIA)
Fig. 6(a)
41 | P a g e
6.1 JAVA FX javaFX is a software platform for creating and delivering rich Internet applications that can run across a wide variety of connected devices. The current release (JavaFX 1.3, April 2010) enables building applications for desktop, browser and mobile phones. TV set-top boxes, gaming consoles, Blu-ray players and other platforms are planned. To build JavaFX apps developers use a statically typed, declarative language called JavaFX Script; Java code can be integrated into JavaFX programs. JavaFX is compiled to Java bytecode, so JavaFX applications run on any desktop and browser that runs the Java Runtime Environment (JRE) and on top of mobile phones running Java ME. On desktop, the current release supports Windows XP, Windows Vista and Mac OS X operating systems. Beginning with JavaFX 1.2, Oracle has released beta versions for Linux and OpenSolaris. On mobile, JavaFX is capable of running on multiple mobile operating systems, including Symbian OS, Windows Mobile, and proprietary real-time operating systems. Commentators have speculated JavaFX will compete on the desktop with Adobe AIR, Apache Pivot, OpenLaszlo and Microsoft Silverlight.
6.2 MICROSOFT SILVERLIGHT Microsoft Silverlight is an application framework for writing and running rich internet applications, with features and purposes similar to those of Adobe Flash. The run-time environment for Silverlight is available as a plug-in for most web browsers. While early versions of ilverlight focused on streaming media, current versions support multimedia, graphics and animation, and give developers support for CLI languages and development tools. Silverlight is also one of the two application development platforms for Windows Phone .
42 | P a g e
By mid 2011 Microsoft will have released 5 versions over the course of 4 years: the first version was released in 2007; the current version, 4, was released in April 2010 and the 5th version is scheduled for release in the second half of 2011. It is compatible with multiple web browsers used on Microsoft Windows and Mac OS X operating systems. Mobile devices, starting with Windows Phone 7 and Symbian (Series 60) phones, were expected to be supported in 2010. A free software implementation named Moonlight, developed by Novell in cooperation with Microsoft, is available to bring Silverlight versions 1 and 2 functionality to Linux, FreeBSD and other open source platforms - although some Linux distributions do not include it, citing redistribution and patent concerns. 6.3 MXML MXML (shorts for ‘Macromedia eXtensible Markup Language’) is an xml based markup language used in flex for defining the user interface. MXML is used primarily in combination with Actionscript to develop RIAs on the flex platform. MXML is primarily used for laying out interfaces while building applications and can be used to deploy business logic and internet application behaviors. It usually might constitute within its chunks of ActionScript code, either when creating the body of an event handler function or with data binding. 6.4 ACTIONSCRIPT 3.0 ActionScript 3.0 is an object oriented language developed primarily by Adobe for creating application or multimedia content which can be run in Flash client runtimes like Flash Player and AIR. AS3 has very good support for common object oriented constructs such as classes, objects and interfaces. It also has runtime type checking. It includes dynamic features such as runtime creation of new constructor function and variables. It offers direct support for XML as a built in data type. All flash client runtime that supports ActionScript 3.0 share the feature of the core language in common.
43 | P a g e
There are two primary routes we can take while handling ActionScript. The first method which is more commonly used by earlier flash developers is to simply put in your ActionScript directly into the timeline. The second method of coding in ActionScript and inserting it into our flash files is by a class file. While inserting a class file we can specify both public and private classes. Using the keyword ‘private’ will restrict the access of attribute you defined to just that class and it will not be shared with other classes. This is very useful when we develop instruction that needs to be executed privately in a secure environment. 6.5 FLASH BUILDER Adobe flash builder 4.5 formerly adobe flex builder is an Integrated Development Environment ( IDE ) from adobe system for ActionScripts and flex development. It is built on the top of eclipse, an open source extensible development environment and a popular java IDE. Because of this flash builder 4.5 inherits an immersive list of capabilities and is a familiar tool for many developers. With the latest version now adobe includes support for building mobile application as well as many developer productivity features. Flash builder 4.5 is adobe’s preferred development tool for building application with the flex 4.5 SDK. Flash builder is available for both Windows and Mac OS. Although we can develop and deploy flex application to the web or to the desktop with the free flex SDK. Flash builder is a worthwhile investment that can increase developer productivity, reduce bugs, speed up coding and generally make the process of developing a flex application much more enjoyable.
44 | P a g e
CHAPTER 7 PROJECT – RAILWAY MUSEUM
Home page of the application
Fig. 7(a) 45 | P a g e
Palace On wheels
Fig. 7(b)
Fig. 7(c) 46 | P a g e
History Of Railway
Fig. 7(d)
Fig. 7(e) 47 | P a g e
Photo Gallary
Fig. 7(f)
Fig. 7(g)
48 | P a g e
CONCLUSION
Engineering student will have to serve in the public and private sector industries and workshop based training and teaching in classroom has its own limitation .The lack of expo sure real life, material express and functioning of industrial organization is the measure hindrance in the student employment. In the open economy era of fast modernization and tough competition, technical industries Should procedure pass out as near to job function as possible. Practical training is one of the major steps in this direction. I did my training from NORTH-WESTERN RAILWAY, AJMER. The training helps me in gaining depth knowledge about technologies used in development of real life projects. I gain the knowledge of working as a team member in the team of developers and they give me very good knowledge of how to work on different type of tools and software environment. The use of RIA is most common and needed in the present scenario. RIA used with java servlet, jsp and struct gives the complete package for developing any website efficiently and reliably. In the end, I hereby conclude that I have successfully completed my industrial training on the above topics.
49 | P a g e
BIBLOGRAPHY & REFRENCES I. BIBLOGRAPHY Web Style Guide: Basic Design Principles For Creating Web Sites By P.J. Lynch, S. Horton, S. Horton Learning Web design: a beginner's guide to HTML, graphics, and beyond By Jennifer Niederst, Jennifer Niederst Robbins Ajax: the definitive guide By Anthony T. Holdener Java Advanced How to Program (redistilled in one book) 2001 by H. M. Deitel Deitel & Associates, Inc.,P. J. DeitelDeitel & Associates, Inc.,S. E. Santry Deitel & Associates, Inc.
II. REFERENCES:
50 | P a g e
www.wikipedia.com www.books.google.com www.codeproject.com www.sun.java.com www.lynda.com