IGNOU BCS-053 Free Solved Assignment by Ignoujugaad
Course Title : Web Programming
Assignment Number : BCA(V)-053Assign/13-14
Weightage : Â Â Â Â Â Â Â Â Â Â 25%
Last Date of Submission : 15th October, 2013/15th April, 2014
This assignment has two questions of 80 marks Rest 20 marks are for viva voce.
ANS-1 (A) Web 2.0 describes web sites that use technology beyond the static pages of earlier web sites. The term was coined in 1999 by Darcy DiNucci and was popularized by Tim OâReilly at the OâReilly Media Web 2.0 conference in late 2004. Although Web 2.0 suggests a new version of the World Wide Web, it does not refer to an update to any technical specification, but rather to cumulative changes in the way web pages are made and used. A Web 2.0 site may allow users to interact and collaborate with each other in a social media dialogue as creators of user-generated content in a virtual community, in contrast to websites where people are limited to the passive viewing of content. Examples of Web 2.0 include social networking sites, blogs, wikis, folksonomies, video sharing sites, hosted services, web applications, and mashups. The key features of Web 2.0 include: 1. Folksonomy; free classification of information 2. A rich user experience 3. A user as a contributor 4. Long tail 5. User participation 6. Basic trust 7. Dispersion 8. Mass participation What is CSS? CSS(Cascading Style Sheets) was one of the W3Câs(W3 Consortium is the organization which provides standards for web oriented programming and scripting) most primitive efforts at untying the formatting and style applying details from document structure in HTML. This persistent subject has been at the heart of most W3C HTML activity since HTML 4.0â˛s launch, and CSS is a critical factor in executing that project. Role of CSS in web designing: By providing a simple set of tools that implement much more thorough control over presentation than HTML itself, CSS was supposed to attract web developers away from the millions of FONT tags used in HTML documents. HTML 4.0â˛s (and XHTMLâs) criticism of the FONT element is the stick. CSS provides the web document designers a number of key aspects that are nearly impossible to implement effectively with straight HTML (even if the FONT element is used). Features and Advantages of CSS: 1. CSS provides reusability. The formatting descriptions applied to documents can be applied to any document with the same vocabulary. 2. CSS even lets you create style sheets that address particular situations within a given vocabulary, specifying the page design and layout based on nested element structures or attribute values. You can make tens of thousands of HTML documents use the same formatting just by connecting one line of code in each document to the same CSS style sheet. This also makes it easy to change formatting across all of those documents because changes made to the master style sheet are replicated in all the documents that use it. 3. Organization appearance of the web document is much straightforward as it takes just a adjustment or change in a style sheet rather than a explore-and-substitute method or find and replace strategy across thousands of documents. Aspects to build a fine style sheet : 1. Keep your style sheet documents in a safe place! Any time your documents refer to a central style sheet, you can use that resource to modify the presentation for all your documents. It makes it easier for you to make the changes, but invaders possibly could alter the style sheet to graffiti your documents. 2. Although a single master style sheet for a site is smart and attractive, sometimes you need to change a presentation for a particular unit of a website, a certain document, or even a certain element in the document. 3. The âcascadeâ in Cascading Style Sheets enables you to handle this problem easily without requiring constant cut-and-paste to make personalized style sheets. 4. Style sheets and documents can refer to multiple style sheets, and CSS provides a set of rules and protocols for determining where to use each style. 5. HTML and XHTML provide extra features like the class and style attributes called as hooks, for connecting style-based formatting to particular elements. 6. Cascading Style Sheets also enables designers to get out of the complex dealing of formatting HTML generated by server-side program codes. Rather than having to edit templates packed with programming code, web designers can agree with programmers on what the output of those programs should look like and then design style sheets to match without getting directly involved in the code. 7. On the client side, CSS makes it simple to reach into the formatting created by web document designers and change it when apt; thus, there is no need to make styling particularly for a page. 8. Designers and programmers sometimes have to work closely together in both client- and server-side development. 9. CSS makes it easy to divide tasks cleanly. CSS offers methods that enable users to state how content should be formatted and designed. Combined with the importance on user-friendliness and accessibility which has influenced much of the CSS process, this enables users to access information in a format thatâs comfortable and convenient for them. (B) XML is a text-based markup language that is fast becoming the standard for data interchange on the web. As with HTML, you identify data using tags (identifiers enclosed in angle brackets: ). Collectively, the tags are known as markup. Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all freeopen standards. The design goals of XML emphasize simplicity, generality, and usability over the Internet. It is a textual data format with strong support via Unicodefor 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. Many application programming interfaces (APIs) have been developed to aid software developers with processing XML data, and several schema systems exist to aid in the definition of XML-based languages. The Difference Between XML and HTML XML is not a replacement for HTML. XML and HTML were designed with different goals: ⢠XML was designed to transport and store data, with focus on what data is ⢠HTML was designed to display data, with focus on how data looks HTML is about displaying information, while XML is about carrying information. Friends.xml
Frnd.Xml <!ELEMENT Friend-Data (Friend+)> <!ELEMENT Friend (FriendName,Dob,Address,PhoneNo)> <!ELEMENT FriendName (#PCDATA)> <!ELEMENT Dob (#PCDATA)> <!ELEMENT Address (#PCDATA) > <!ELEMENT PhoneNo (#PCDATA)> (C) A Document object represents the HTML document that is displayed in that window. The Document object has various properties that refer to other objects which allow access to and modification of document content. The way that document content is accessed and modified is called the Document Object Model, or DOM. The Objects are organized in a hierarchy. This hierarchical structure applies to the organization of objects in a Web document. ⢠Window object: Top of the hierarchy. It is the outmost element of the object hierarchy. ⢠Document object: Each HTML document that gets loaded into a window becomes a document object. The document contains the content of the page. ⢠Form object: Everything enclosed in the
tags sets the form object. ⢠Form control elements: The form object contains all the elements defined for that object such as text fields, buttons, radio buttons, and checkboxes. Here is a simple hierarchy of few important objects: There are several DOMs in existence. The following sections explain each of these DOMs in detail and describe how you can use them to access and modify document content. ⢠The Legacy DOM: This is the model which was introduced in early versions of JavaScript language. It is well supported by all browsers, but allows access only to certain key portions of documents, such as forms, form elements, and images. ⢠The W3C DOM: This document object model allows access and modification of all document content and is standardized by the World Wide Web Consortium (W3C). This model is supported by almost all the modern browsers. ⢠The IE4 DOM: This document object model was introduced in Version 4 of Microsoftâs Internet Explorer browser. IE 5 and later versions include support for most basic W3C DOM features. What are events? Events occur when some sort of interaction takes place in a web page. This can be the end user clicking on something, moving the mouse over a certain element or pressing down certain keys on the keyboard. An event can also be something that happens in the web browser, such as the web page completing the loading of a page, or the user scrolling or resizing the window. Through the use of JavaScript, you can detect when certain events happen, and cause things to occur in response to those events. How events work When events happen to an HTML element in a web page, it checks to see if any event handlers are attached to it. If the answer is yes, it calls them in respective order, while sending along references and further information for each event that occurred. The event handlers then act upon the event. There are two types of event order: event capturing and event bubbling. Event capturing starts with the outer most element in the DOM and works inwards to the HTML element the event took place on and then out again. For example, a click in a web page would first check the HTML element for onclick event handlers, then the body element, and so on, until it reaches the target of the event. Event bubbling works in exactly the opposite manner: it begins by checking the target of the event for any attached event handlers, then bubbles up through each respective parent element until it reaches the HTML element. A JavaScript can be executed when an event occurs, like when a user clicks on an HTML element. To execute code when a user clicks on an element, add JavaScript code to an HTML event attribute: onclick=JavaScript Examples of HTML events: ⢠When a user clicks the mouse ⢠When a web page has loaded ⢠When an image has been loaded ⢠When the mouse moves over an element ⢠When an input field is changed ⢠When an HTML form is submitted ⢠When a user strokes a key PROGRAM
 â (D) WAP is the de facto worldwide standard for providing Internet communications and advanced telephony services on digital mobile phones, pagers, personal digital assistants and other wireless terminals â WAP Forum WAP stands for Wireless Application Protocol. Per the dictionary definition for each of these words, we have: ⢠Wireless: Lacking or not requiring a wire or wires: pertaining to radio transmission. ⢠Application: A computer program or piece of computer software that is designed to do a specific task. ⢠Protocol: A set of technical rules about how information should be transmitted and received using computers. WAP is the set of rules governing the transmission and reception of data by computer applications on, or via, wireless devices like mobile phones. WAP allows wireless devices to view specifically designed pages from the Internet, using only plain text and very simple black-and-white pictures. WAP is a standardized technology for cross-platform, distributed computing, very similar to the Internetâs combination of Hypertext Markup Language (HTML) and Hypertext Transfer Protocol (HTTP), except that it is optimized for: ⢠low-display capability ⢠low-memory ⢠low-bandwidth devices, such as personal digital assistants (PDAs), wireless phones, and pagers. WAP is designed to scale across a broad range of wireless networks, like GSM, IS-95, IS-136 and PDC. WML (Wireless Markup Language), formerly called HDML (Handheld Devices Markup Languages), is a language that allows the text portions of Web pages to be presented oncellular telephones and personal digital assistants (PDAs) via wireless access. WML is part of the Wireless Application Protocol (WAP) that is being proposed by several vendors to standards bodies. The Wireless Application Protocol works on top of standard data link protocols, such as Global System for Mobile communication, code-division multiple access, and Time Division Multiple Access, and provides a complete set of network communication programs comparable to and supportive of the Internet set of protocols. ⢠WML is an application of XML, which is defined in a document-type definition. ⢠WML is based on HDML and is modified so that it can be compared with HTML. ⢠WML takes care of the small screen and the low bandwidth of transmission. ⢠WML is the markup language defined in the WAP specification. ⢠WAP sites are written in WML, while web sites are written in HTML. ⢠WML is very similar to HTML. Both of them use tags and are written in plain text format. ⢠WML supports client-side scripting. The scripting language supported is called WMLScript. To Create a webpage for mobile:- LAYOUT ⢠LOGO: One of the main things in the layout. You should try to make it as attractive as you can but at the same time take care of its size. Make sure that the size doesnât exceed 2 KBs of size because images always take forever to load on mobile networks and you donât want your site to load incompletely for different people! ⢠WEBSITE NAVIGATION: One of the most important things in the design. No matter what, you need to have the links to main pages/places/things on your website on this bar and this should always be at the top. As you know, typing on most mobile devices using the small QWERTY or the virtual QWERTY keypads is not easy to work with at all. Therefore, creating a thorough navigation for your website is a key aspect to making your website mobile friendly. ⢠CONTENT: This is the main thing on your mobile website. People actually come to websites on their mobile devices just to view the content. So make sure that you donât make any single change to your content for mobile devices otherwise you might just end up losing a user. While on Mobile Devices, people are usually on the go, so they donât really have much time to view content. As a solution to this, you should cut down your content to some major value points but at the same time you should provide your user with a Link to the main article containing all of your content. (If you have an active blog then you can ignore this as you canât really cut down content for each post separately every day!!) We all know that images in content are a must. But in the mobile version of your website, you should make sure that you donât have much graphics because most mobile phones would take forever to load heavy images. So use images and graphics as little as possible, only where contextually relevant. And if you do wish to put images on your mobile website, it should be in .JPEG or .GIF or .PNG format as these files are pretty much light-weight. Plus make sure to compress your pictures to avoid zooming. And one more, today nearly all current devices display images, however, users may browse with the images turned off. So always use the ALT text property for the images which is a recommended practice. Also, you must properly size your images to avoid a situation where the reader/visitor has to zoom into the image to see it properly. ⢠FOOTER: Thereâs an old saying, âA Man is not recognized by the clothing heâs wearing but by the condition of his shoes!â This goes true for many websites. I always see blogs, marketing websites etc. OVER-LOADED with âgarbage and dirtyâ Hyper-links in Footer. Like me, many others donât like it and on mobile websites where the screen size is small, this could be one thing where you could lose a client or a reader. So make an attractive Footer! So if you want your applications/websiteâs mobile-interface going successful, you should lay focus on its Layout. It should just be error-free as âWeb-Browsing on Mobile Devicesâ will be the next big thing. CODING This is one thing where many new mobile-interface developers hesitate. Below are some tips that can help remove that hesitation: ⢠VALID CODE: Use proper code and make sure that its 100% valid because most mobile browsers arenât as good as their PC (Personal-Computer) counterparts so you should make sure that itâs valid. ⢠FLUID LAYOUTS: Itâs not always easy to discover how your layout will look on all mobile browsers as there are far too many mobile devices used for web browsing and to track them all can be a big pain. One way to address/bypass this problem is the use fluid layouts that will automatically adjust to the screen size. To accomplish this avoid setting widths in pixels and use percentages or ems instead. For instance, instead of: 1 width: 400px; use 1 width: 100% or 1 width: 1.0ems You can find more about the fluid mobile layouts and also download some pre-built ones by going to this link: Perfect multi-column CSS liquid layouts â iPhone compatible ⢠SPECIFIC STYLESHEETS You can always target various mobile devices for better user-experience. For example, for targeting users browsing your site using Handheld devices you can use this in your websiteâs: 1 You can find more about these media types at this link: W3.org â Media Types. ⢠SAY âNOâ TO FANCY SCRIPTS For your mobile website to go successful, donât use Javascript or Flash or any other of those fancy scripts available out there. Because majority of mobile devices fail to interpret these and end up either freezing the device or just doing something stupid! If you really want to use these then should give your user a Polite Option so that your user knows what his/her mobile handset is loading and opening up (and if anything goes wrong, itâs their fault and not yours because you already warned them). ⢠TAKE IT EASY WITH THE ADS This is one thing that almost everyone should take care of! Donât fill up your mobile page with ads. And this is not only for the mobile page but also for the original website. Itâs an old saying, âOne rotten Apple in a basket makes all others dirtyâ. It goes true for these websites which are full of ads. These websites donât care about User-Experience but only care about the money that comes into their pockets (because CPM is high on mobile devices). So my suggestion, just donât fill it up with ads! âJust donât make your page with colourful ads.â ⢠MOBILE BROWSER DETECTION (AUTOMATIC) For making your brand successfull you should also include an automatic âMobile Browser Detection & Redirectionâ server-side script (eg. PHP). You might also use this as User Agent detection, where a server makes a decision on what to serve based on how an incoming browser describes its capabilities. You might also want to use this as an alternative or fallback method to the previous one Mobile Browser Detection in PHP. Other implementations feature real-time JavaScript requests to databases like DeviceAtlas or WURFL that also supply information on what a device can do. A mobile version is not complete until itâs automatically triggered for every mobile user! ⢠MAKE A DEDICATED APPLICATION CLIENT (if necessary) Yes! You read it correctly. If you have a really high user-base, make a dedicated application targeting various mobile interfaces. Facebook, Gmail, Twitter, Yahoo and many other big-companies have done this and this is why they have been so successful. If you make an application for specific handsets then you no longer have to care about all the Fancy scripts etc. because you can then enhance the application your own way (you canât change the mobile browser but definitely your own application). ANS-2 (A) Client/server architecture This approach introduced replacement of file server by database server. User queries could be answered directly by using a relational database management system. The client/server architecture significantly decreased network traffic by providing a query response rather than total file transfer. It allows multi-user updating through a GUI front end to a shared database. Remote Procedure Calls (RPCs) or standard query language (SQL) statements are typically used to communicate between the client and server. The following are the examples of client/server architectures. 1) Two tier architectures In two tier client/server architectures, the user interface is placed at userâs desktop environment and the database management system services are usually in a server that is a more powerful machine that provides services to the many clients. Information processing is split between the user system interface environment and the database management server environment. The database management server supports for stored procedures and triggers. Software vendors provide tools to simplify development of applications for the two tier client/server architecture. 2) Three tier architectures The three tier architecture is introduced to overcome the drawbacks of the two tier architecture. In the three tier architecture, a middleware is used between the user system interface client environment and the database management server environment. These middleware are implemented in a variety of ways such as transaction processing monitors, message servers or application servers. The middleware perform the function of queuing, application execution and database staging. In addition the middleware adds scheduling and prioritization for work in progress. The three tier client/server architecture is used to improve performance for large number of users and also improves flexibility when compared to the two tier approach. The drawback of three tier architectures is that the development environment is more difficult to use than the development of two tier applications. i) Three tier with message server. In this architecture, messages are processed and prioritized asynchronously. Messages have headers that include priority information, address and identification number. The message server links to the relational DBMS and other data sources. Messaging systems are alternative for wireless infrastructures. ii) Three tier with an application server This architecture allows the main body of an application to run on a shared host rather than in the user system interface client environment. The application server shares business logic, computations and a data retrieval engine. In this architecture applications are more scalable and installation costs are less on a single server than maintaining each on a desktop client. Uses Client/server architectures are used in industry as well as in military. They provide a versatile architecture that allows insertion of new technology more readily than earlier software designs. GET The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process. The semantics of the GET method change to a âconditional GETâ if the request message includes an If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring multiple requests or transferring data already held by the client. The semantics of the GET method change to a âpartial GETâ if the request message includes a Range header field. A partial GET requests that only part of the entity be transferred, as described in section 14.35. The partial GET method is intended to reduce unnecessary network usage by allowing partially-retrieved entities to be completed without transferring data already held by the client. POST The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions: â Annotation of existing resources; â Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles; â Providing a block of data, such as the result of submitting a form, to a data-handling process; â Extending a database through an append operation. The actual function performed by the POST method is determined by the server and is usually dependent on the Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a database. The action performed by the POST method might not result in a resource that can be identified by a URI. In this case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the response includes an entity that describes the result. Example POST /path/script.cgi HTTP/1.0 From: [email protected] User-Agent: HTTPTool/1.0 Content-Type: application/x-www-form-urlencoded Content-Length: 32 home=Mosby&favorite+flavor=flies (B) Program to show use of scripting elements <%@page language=âjavaâ import=âjava.io.*â %> <%@page import=âjavax.servlet.*â %> <%@page import=âjavax.servlet.http.*â %> <%! int a,b,c; %> <% a=10; b=20; c=a+b; %> <%=c%> Create a web page using JSP that stores the number of times a button is clicked on to the server <%! int clicks = 0; %> <% String param = request.getParameter(âintegerâ); try { int i = Integer.parseInt(param); clicks ++; } catch (NumberFormatException e) { } %>
Number of clicks untill now: <%= clicks %>
 (C) Cookies Web applications are typically a series of Hypertext Transfer Protocol (HTTP) requests and responses. As HTTP is a stateless protocol, information is not automatically saved between HTTP requests. Web applications use cookies to store state information on the client. Cookies can be used to store information about the user, the userâs shopping cart, and so on. Types of Cookies The two types of cookies follow: ⢠Session cookies â Session cookies are stored in memory and are accessible as long as the user is using the web application. Session cookies are lost when the user exits the web application. Such cookies are identified by a session ID and are most commonly used to store details of a shopping cart. ⢠Permanent cookies â Permanent cookies are used to store long-term information such as user preferences and user identification information. Permanent cookies are stored in persistent storage and are not lost when the user exits the application. Permanent cookies are lost when they expire. Difference Between Cookie & Session The main difference between cookies and sessions is that cookies are stored in the userâs browser, and sessions are not. This difference determines what each is best used for. A cookie can keep information in the userâs browser until deleted. If a person has a login and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit. You can store almost anything in a browser cookie. The trouble is that a user can block cookies or delete them at any time. If, for example, your websiteâs shopping cart utilized cookies, and a person had their browser set to block them, then they could not shop at your website. Sessions are not reliant on the user allowing a cookie. They work instead like a token allowing access and passing information while the user has their browser open. The problem with sessions is that when you close your browser you also lose the session. So, if you had a site requiring a login, this couldnât be saved as a session like it could as a cookie, and the user would be forced to re-login every time they visit. A Webpage that asks your name and creates a cookie about your name
(D) JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases. The JDBC library includes APIs for each of the tasks commonly associated with database usage: ⢠Making a connection to a database ⢠Creating SQL or MySQL statements ⢠Executing that SQL or MySQL queries in the database ⢠Viewing & Modifying the resulting records Fundamentally, JDBC is a specification that provides a complete set of interfaces that allows for portable access to an underlying database. Java can be used to write different types of executables, such as: ⢠Java Applications ⢠Java Applets ⢠Java Servlets ⢠Java ServerPages (JSPs) ⢠Enterprise JavaBeans (EJBs) All of these different executables are able to use a JDBC driver to access a database and take advantage of the stored data. JDBC provides the same capabilities as ODBC, allowing Java programs to contain database-independent code. JSP Program to verify UserName & Password http://www.easywayserver.com/blog/user-login-in-jsp/ Refer to this link & write the code of 3 files:- ⢠Login.jsp ⢠Dologin.jsp ⢠Success.jsp